Solved

Looking for a basic batch file that will flash an image on the windows 2000 when launched

Posted on 2004-10-12
12
181 Views
Last Modified: 2010-04-14
I am needing to flash an image on a computer desktop to alert someone when new email arrives.  The standard Outlook notifications are not good enough and we cannot use audio.  So I thought I would just use a batch file that causes an image to flash on the desktop for a predetermined amount of time (say 30 seconds).  I can create a rule in outlook to lauch the batch file when new email arrives. (not a problem)  I just do not know how to write a batch that can flash an image and have it continue to flash that image for the set amount of time.  Also, it would be good to have it also include a prompt that would allow for the user to kill the batch file if they are already near the computer.  I guess I could use any image type for this batch file.
0
Comment
Question by:murryc
  • 7
  • 5
12 Comments
 

Author Comment

by:murryc
ID: 12298567
I can use a VB script also to complete this task..complete code only please as I am not a VB script person either
0
 
LVL 76

Expert Comment

by:David Lee
ID: 12301181
Hi, murryc.

From my perspective there's a bit of a problem with what you're looking to do.  Batch files, at least those that use native batch commands and don't rely on third-party products, don't have any means of displaying an image or graphic.  There has to be something to hold and display an image and by there very nature batch files don't have that capability.  The best a batch file could do would be to launch another program to display the image.  VBScript suffers from the same problem.  The only GUI element is a very simple dialog box a script can use to present a message with an OK button, or solicit input from the user.  To do what you've described you really need a program.  I can put one together for you in Visual Basic if you like and then post the source code, if you have access to VB, or post the source code here and place an executable on a web site where you can grab a copy.

Let me know if this is something you'd like to pursue.
0
 

Author Comment

by:murryc
ID: 12302957
I would love to pursue that solution BlueDevilFan.  I do have Visual Basic so you can just post the source code.  I do not have any experience with using the program so I might have to lean on you to tell me how to compile it.  The reason I want to compile it myself is because I want to create more than one program that displays different flashing images on the screen based on the email account the email arrives on.  Again, I want to note that I can get Outlook to execute the program with no problem when the email arrives.  I just need the program to call that flashes an image of some type on the desktop.  

Because of the complexity of this, I am increasing the points to 500.
0
 
LVL 76

Expert Comment

by:David Lee
ID: 12303731
What size image do you plan to use?  I can write the code so that you can use diifferent images and not have to have multiple versions of the program.  Also, do you want the popup to look like a standard dialog box or would you prefer a borderless window?  
0
 

Author Comment

by:murryc
ID: 12304110
The person monitoring the email will be about 15-20 feet away from the computer when they look to see if there are messages so I want it to be pretty large.  I would want an image about 600x600.  I am thinking of a solid color background with a few words in the middle to signify which email account has new email.  I would go with a different solid color for each email account.  A standard dialog box with a close button would be great.  After thinking about it, I would love to have both the source code (for future changes) and the compiled executable so that I can put it into action as soon as I get it.
0
 

Author Comment

by:murryc
ID: 12304117
also, not sure if this matters, but the Outlook program is setup to run a program when new email arrives in each account.  If the program is the same, how will it know which image to display.  Also, to mention again, I need the image to flash and I would prefer that it flashes until the person terminates it.  If we put a timer on it, the person might not see it during the timing period and the solution would be useless.
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 76

Expert Comment

by:David Lee
ID: 12304296
Ok.  I thought you already had an image you wanted to use.  If you just want the background of the dialog to flash, then that's even easier.  The way to have a single program and use it with multiple accounts is to not launch the program directly but instead launch it from a script file.  It's far easier to have multiple scripts than multiple executables.  This approach also allows you to expand the number of possible messages merely by creating a new script file.  Let me get the program put together and I'll show you what I mean.
0
 

Author Comment

by:murryc
ID: 12305107
I don't have the images files yet, but can make them really fast if you need.  If you can just make the background flash with text in the middle of the dialog then great.  Can you also add the function to play a sound file every 15 minutes until the entire flashing/sound is cancelled?
0
 

Author Comment

by:murryc
ID: 12305112
I have this question open on another topic area as well and will give you the points from both areas when done.  

http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_21166717.html

Please post your answer on this question as well.
0
 
LVL 76

Accepted Solution

by:
David Lee earned 500 total points
ID: 12314121
Ok, here it is.  What I've posted below is an entire Visual Basic form file.  The code is really very simple.  It pops up a dialog-box saying "New message for account AccountName" and flashes the background to draw attention to it.  To make the program flexible I've written it to accept five parameters which control the name of the account shown in the message, the flash color, the height of the window, the width of the window, and the speed at which it flashes.  This allows you to have a single executable that can behave differently for different accounts.

Usage: MsgNotify /a=Account Name /c=FlashColor /h=Height /w=Width /s=FlashSpeed
    Where:    AccountName = the name of the account that'll be shown in the dialog-box's message
                   FlashColor = a number (hex or decimal) representing the flashing color.  Here are some common colors,
                                      although you can use any color you want: 255 (Red)   65280 (Green)   65535 (Yellow)  
                                      524416 (Purple)   16711680 (Blue)
                   Height = the height of the dialog-box in pixels
                   Width = the width of the dialog-box in pixels
                   FlashSpeed = The flash rate in miliseconds

The parameters can be passed in any order.  The program will still operate even if no parameters are passed sicne there are defaults for everything.  The only parameter that is really needed is the name of the account.  If you don't pass it, then the dialog-box will still operate, it just won't show an account name.  You can look at the properties of the Form to see the other defaults.  The paramaters don't have to be spaced out either.  But you do have to have the first three characters, e.g. /a= for the account parameter.  If the / is left off a parameter, then the program won't read the parameter at all.  If the letter is left out, then the program will ignore the parameter.  If the = is left out, then the parameter won't be parsed properly and the result will depend on which parameter it is.  All of this can be altered easily enough.  It be simple to do more editing, add parameters, etc.

Here's what you'll need to do to use the code.  

1.  Start Notepad.
2.  Block and copy all the code below, everything from VERSION 5.00 on down.
3.  Paste everything into Notepad.
4.  Save the file with a .frm extension and close Notepad.
5.  Double-click the file you just saved.  This should open it in VB.
6.  Click File->Save Project As and save the project.  Be sure and give it a name that's practical and meaningful.
7.  Click File->Make ProjectName and VB will create the executable.  You're ready to test.
8.  Create a couple of batch files (.bat or .cmd) and call the program with different parameters.  Launch one batch file for one account and another for a different account.

That should do it.  I appreciate the offer to post this in response to your other question, but I dont' feel comfortable doing that.  Save yourself 500 points and close that question.

I hope this helps.  If there's anything else I can do to help with this, then let me know.


VERSION 5.00
Begin VB.Form frmMain
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "Message Notification"
   ClientHeight    =   3120
   ClientLeft      =   45
   ClientTop       =   435
   ClientWidth     =   7065
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   208
   ScaleMode       =   3  'Pixel
   ScaleWidth      =   471
   ShowInTaskbar   =   0   'False
   StartUpPosition =   2  'CenterScreen
   Begin VB.Timer Timer1
      Enabled         =   0   'False
      Interval        =   1000
      Left            =   120
      Top             =   2520
   End
   Begin VB.CommandButton btnClose
      Appearance      =   0  'Flat
      Caption         =   "Close"
      Default         =   -1  'True
      Height          =   375
      Left            =   5760
      TabIndex        =   1
      Top             =   2640
      Width           =   1095
   End
   Begin VB.Label lblMessage
      Alignment       =   2  'Center
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      Caption         =   "New message for account"
      BeginProperty Font
         Name            =   "MS Sans Serif"
         Size            =   13.5
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H80000008&
      Height          =   375
      Left            =   240
      TabIndex        =   0
      Top             =   1200
      Width           =   6495
   End
End
Attribute VB_Name = "frmMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim arrParams As Variant, _
    lngRootColor As Long, _
    lngFlashColor As Long

Private Sub btnClose_Click()
    Unload Me
End Sub

Private Sub Form_Load()
    Dim strArguments As String, _
        intParamCount As Integer, _
        varTemp As Variant
    lngRootColor = frmMain.BackColor
    lngFlashColor = vbRed
    strArguments = Command()
    arrParams = Split(strArguments, "/", , vbTextCompare)
    For intParamCount = 0 To UBound(arrParams)
        varTemp = Trim(Mid(arrParams(intParamCount), 3))
        Select Case LCase(Left(arrParams(intParamCount), 1))
            Case "a"    'Account parameter
                lblMessage.Caption = lblMessage.Caption & " " & varTemp
            Case "c"    'Root color parameter
                lngFlashColor = Val(varTemp)
            Case "h"    'Height of the dialog-box parameter
                If IsNumeric(varTemp) Then
                    frmMain.Height = (Int(varTemp) * Screen.TwipsPerPixelX)
                End If
            Case "w"    'Width of the dialog-box parameter
                If IsNumeric(varTemp) Then
                    frmMain.Width = (Int(varTemp) * Screen.TwipsPerPixelY)
                End If
            Case "s"    'Speed parameter
                If IsNumeric(varTemp) Then
                    Timer1.Interval = CLng(varTemp)
                End If
        End Select
    Next
    btnClose.Top = frmMain.ScaleHeight - (btnClose.Height + 25)
    btnClose.Left = frmMain.ScaleWidth - (btnClose.Width + 25)
    lblMessage.Top = (frmMain.ScaleHeight - lblMessage.Height) / 2
    lblMessage.Left = (frmMain.ScaleWidth - lblMessage.Width) / 2
    Timer1.Enabled = True
End Sub

Private Sub Timer1_Timer()
    Static bolRoot As Boolean
    frmMain.BackColor = IIf(bolRoot, lngRootColor, lngFlashColor)
    bolRoot = Not bolRoot
    DoEvents
End Sub
0
 

Author Comment

by:murryc
ID: 12325920
works perfect...thanks for taking the time to design a turnkey solution for me.  Job well done.
0
 
LVL 76

Expert Comment

by:David Lee
ID: 12327038
Thanks!  Cheers.
0

Featured Post

Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Join & Write a Comment

NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
HOW TO: Upload an ISO image to a VMware datastore for use with VMware vSphere Hypervisor 6.5 (ESXi 6.5) using the vSphere Host Client, and checking its MD5 checksum signature is correct.  It's a good idea to compare checksums, because many installat…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now