• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 197
  • Last Modified:

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

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.
  • 7
  • 5
1 Solution
murrycAuthor Commented:
I can use a VB script also to complete this task..complete code only please as I am not a VB script person either
David LeeCommented:
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.
murrycAuthor Commented:
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.
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

David LeeCommented:
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?  
murrycAuthor Commented:
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.
murrycAuthor Commented:
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.
David LeeCommented:
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.
murrycAuthor Commented:
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?
murrycAuthor Commented:
I have this question open on another topic area as well and will give you the points from both areas when done.  


Please post your answer on this question as well.
David LeeCommented:
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.

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
   Begin VB.CommandButton btnClose
      Appearance      =   0  'Flat
      Caption         =   "Close"
      Default         =   -1  'True
      Height          =   375
      Left            =   5760
      TabIndex        =   1
      Top             =   2640
      Width           =   1095
   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
      ForeColor       =   &H80000008&
      Height          =   375
      Left            =   240
      TabIndex        =   0
      Top             =   1200
      Width           =   6495
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
    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
End Sub
murrycAuthor Commented:
works perfect...thanks for taking the time to design a turnkey solution for me.  Job well done.
David LeeCommented:
Thanks!  Cheers.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 7
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now