Jump to content

MsgBox with an application loader1


Recommended Posts

Hello all and Happy New Year!

I'm hoping someone can help me out ... I've got an application loader script (below) which will check for an application window every 5 mins. If the window is closed then the application is started. That part is working great! What I'd like is a MsgBox or application window displayed on the taskbar which is showing that the script is loaded and running in the bg, but with the option of an exit button to terminate the app loader from memory. Basically if the window is visible the script is running. Click on an exit button and the script and window are terminated (the application which is being checked for can remain open).

#NoTrayIcon

While 1
If Not WinExists("Windows Title") Then
    Run("C:\Program Files\Application\BIF.exe")
Sleep("300000") ;5 Min

Else
Sleep("300000") ;5 Min

EndIf
WEnd
Exit

Thanks!

Link to comment
Share on other sites

What you need is a GUI

GUI have options that you can set for that

#include <GUIConstants.au3>

Opt("GUIOnEventMode", 1)
$mainwindow = GUICreate("Test", 300, 160)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
GUISetState()

Func CLOSEClicked()
  Exit
EndFunc

That code will create a blank GUI window that will close the script when you press the X button near the top of the window

Edited by BALA
[font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com
Link to comment
Share on other sites

What you need is a GUI

GUI have options that you can set for that

#include <GUIConstants.au3>

Opt("GUIOnEventMode", 1)
$mainwindow = GUICreate("Test", 300, 160)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
GUISetState()

Func CLOSEClicked()
  Exit
EndFunc

That code will create a blank GUI window that will close the script when you press the X button near the top of the window

BALA,

Thanks for the post, however when I run it I get a flash of a gui box then it disappears and the script ends. I've tried playing with it but everything either errors out or flashes a gui box.

Thanks,

MePH

Link to comment
Share on other sites

It should have an icon showing that your program is running next to the time in the lower right hand corner, unless you have hidden it.

If you did want to use a GUI, like BALA had suggested, then you would need to create a While statement that would run until the program was closed to keep it running/shown(depending on how you code it). There are some examples in the help file about how to use the GUI that should get you on the right track.

If you did use a message box, it will halt the program until the message box is closed. I don't think you want that.

Edited by TheCuz

[font="Verdana"]People who say it cannot be done should not interrupt those who are doing it. - George Benard Shaw[/font]

Link to comment
Share on other sites

If you still do not understand, try this:

#include <GUIConstants.au3>
#NoTrayIcon
$mainwindow = GUICreate("Test", 300, 160)
GUISetState()
$begin = TimerInit()
While 1
        $msg = GuiGetMsg()
                Select
                        Case $msg = $GUI_EVENT_CLOSE
                                Exit
                EndSelect
        If Not WinExists("Windows Title") AND TimerDiff($begin) > 300000 Then
                Run("C:\Program Files\Application\BIF.exe")
                $begin = TimerInit()
        EndIf
WEnd

-=UNTESTED=-

Hope it works :P

Kurt

Awaiting Diablo III..

Link to comment
Share on other sites

This is what I have :P ... I hope it can help someone out!

#NoTrayIcon
#include <GUIConstants.au3>
$title = "Application Loader v1.0"
$app_title = "Untitled - Notepad"
$app_link = "C:\windows\notepad.exe"
$time = "5000" ;5 Seconds

Opt("GUIOnEventMode", 1)
$MainWindow = GuiCreate($title, 300, 100)
$label = GUICtrlCreateLabel("Closing this windows will terminate the application loader!", 10, 40, 300, 90)

GUISetState()
GUISetOnEvent($GUI_EVENT_CLOSE, "_AppClose")

While 1
If Not WinExists($app_title) Then
    Run($app_link)
Sleep($time)

Else
Sleep($time)

EndIf
WEnd

Func _AppClose()
    Exit
EndFunc

Thanks for everyone's help!

MePH

Link to comment
Share on other sites

If I am not mistaken, by putting 5000 in quotes, you are converting the integer into a string and then are trying to use a string where an integer should be.

Why not just put it as Sleep(5000) instead of using a varaible? Or if you need to put it into a variable, do not use quotes around the number.

Hope this helps.

[font="Verdana"]People who say it cannot be done should not interrupt those who are doing it. - George Benard Shaw[/font]

Link to comment
Share on other sites

If I am not mistaken, by putting 5000 in quotes, you are converting the integer into a string and then are trying to use a string where an integer should be.

Why not just put it as Sleep(5000) instead of using a varaible? Or if you need to put it into a variable, do not use quotes around the number.

Hope this helps.

Thanks TheCuz ... Always learning :P

MePH

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...