Jump to content
Sign in to follow this  
AlmarM

ProcessExist Func Example

Recommended Posts

AlmarM

I made this to show what you can all do with ProcessExist and ProcessClose

Source:

#include <GUIConstants.au3>

$Checking_NORMAL = ProcessExists("msmsgs.exe")
$Checking_LIVE = ProcessExists("msnmsgr.exe")

$GUI = GUICreate("MSN Watcher Advanced", 380, 150, -1, -1)
GUISetState(@SW_SHOW)
$Label_1 = GUICtrlCreateLabel("MSN Watcher Advanced, a program to see if de MSN Process is still running.", 10, 10)
$Label_2 = GUICtrlCreateLabel("Just press the CHECK button to check if its running.", 10, 30)
$CHECK_NORMAL = GUICtrlCreateButton("CHECK NORMAL", 10, 50, 170, 30)
$CHECK_LIVE = GUICtrlCreateButton("CHECK LIVE", 200, 50, 170, 30)
$Checking_Label_NORMAL = GUICtrlCreateLabel("", 10, 80, 170, 15)
$Loading_Label_NORMAL = GUICtrlCreateLabel("", 10, 95, 170, 15)
$Checking_Label_LIVE = GUICtrlCreateLabel("", 200, 80, 170, 15)
$Loading_Label_LIVE = GUICtrlCreateLabel("", 200, 95, 170, 15)
$Close_NORMAL = GUICtrlCreateButton("CLOSE NORMAL", 10, 110, 170, 30)
$Close_LIVE = GUICtrlCreateButton("CLOSE LIVE", 200, 110, 170, 30)
GUICtrlSetState($Close_NORMAL, $GUI_DISABLE)
GUICtrlSetState($Close_LIVE, $GUI_DISABLE)

GUISetState()
While 1
$nMsg = GUIGetMsg()
Select
Case $nMsg = $GUI_EVENT_CLOSE
Exit
Case $nMsg = $CHECK_NORMAL
GUICtrlSetData($Checking_Label_NORMAL, "Checking...")
GUICtrlSetData($Loading_Label_NORMAL, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
Sleep(50)
GUICtrlSetData($Loading_Label_NORMAL, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
Sleep(50)
GUICtrlSetData($Loading_Label_NORMAL, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
Sleep(50)
GUICtrlSetData($Loading_Label_NORMAL, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
Sleep(50)
GUICtrlSetData($Loading_Label_NORMAL, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
Sleep(50)
GUICtrlSetData($Loading_Label_NORMAL, "xxxxxxxxxxxxxxxxxxxxxxxxxxxx")
Sleep(50)
GUICtrlSetData($Loading_Label_NORMAL, "xxxxxxxxxxxxxxxxxxxxxxxxxxx")
Sleep(50)
GUICtrlSetData($Loading_Label_NORMAL, "xxxxxxxxxxxxxxxxxxxxxxxxxx")
Sleep(50)
GUICtrlSetData($Loading_Label_NORMAL, "xxxxxxxxxxxxxxxxxxxxxxxxx")
Sleep(50)
GUICtrlSetData($Loading_Label_NORMAL, "xxxxxxxxxxxxxxxxxxxxxxxx")
Sleep(50)
GUICtrlSetData($Loading_Label_NORMAL, "xxxxxxxxxxxxxxxxxxxxxxx")
Sleep(50)
GUICtrlSetData($Loading_Label_NORMAL, "xxxxxxxxxxxxxxxxxxxxxx")
Sleep(50)
GUICtrlSetData($Loading_Label_NORMAL, "xxxxxxxxxxxxxxxxxxxxx")
Sleep(50)
GUICtrlSetData($Loading_Label_NORMAL, "xxxxxxxxxxxxxxxxxxxx")
Sleep(50)
GUICtrlSetData($Loading_Label_NORMAL, "xxxxxxxxxxxxxxxxxxx")
Sleep(50)
GUICtrlSetData($Loading_Label_NORMAL, "xxxxxxxxxxxxxxxxxx")
Sleep(50)
GUICtrlSetData($Loading_Label_NORMAL, "xxxxxxxxxxxxxxxxx")
Sleep(50)
GUICtrlSetData($Loading_Label_NORMAL, "xxxxxxxxxxxxxxxx")
Sleep(50)
GUICtrlSetData($Loading_Label_NORMAL, "xxxxxxxxxxxxxxx")
Sleep(50)
GUICtrlSetData($Loading_Label_NORMAL, "xxxxxxxxxxxxxx")
Sleep(50)
GUICtrlSetData($Loading_Label_NORMAL, "xxxxxxxxxxxxx")
Sleep(50)
GUICtrlSetData($Loading_Label_NORMAL, "xxxxxxxxxxxx")
Sleep(50)
GUICtrlSetData($Loading_Label_NORMAL, "xxxxxxxxxxx")
Sleep(50)
GUICtrlSetData($Loading_Label_NORMAL, "xxxxxxxxxx")
Sleep(50)
GUICtrlSetData($Loading_Label_NORMAL, "xxxxxxxxx")
Sleep(50)
GUICtrlSetData($Loading_Label_NORMAL, "xxxxxxxx")
Sleep(50)
GUICtrlSetData($Loading_Label_NORMAL, "xxxxxxx")
Sleep(50)
GUICtrlSetData($Loading_Label_NORMAL, "xxxxxx")
Sleep(50)
GUICtrlSetData($Loading_Label_NORMAL, "xxxxx")
Sleep(50)
GUICtrlSetData($Loading_Label_NORMAL, "xxxx")
Sleep(50)
GUICtrlSetData($Loading_Label_NORMAL, "xxx")
Sleep(50)
GUICtrlSetData($Loading_Label_NORMAL, "xx")
Sleep(50)
GUICtrlSetData($Loading_Label_NORMAL, "x")
Sleep(50)
GUICtrlSetData($Loading_Label_NORMAL, "")
If $Checking_NORMAL = True Then
GUICtrlSetData($Checking_Label_NORMAL, "MSN NORMAL is running.") 
GUICtrlSetState($Close_NORMAL, $GUI_ENABLE)
Else
GUICtrlSetData($Checking_Label_NORMAL, "MSN NORMAL is not running.")
GUICtrlSetState($Close_NORMAL, $GUI_DISABLE)
EndIf
Case $nMsg = $CHECK_LIVE
GUICtrlSetData($Checking_Label_LIVE, "Checking...")
GUICtrlSetData($Loading_Label_LIVE, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
Sleep(50)
GUICtrlSetData($Loading_Label_LIVE, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
Sleep(50)
GUICtrlSetData($Loading_Label_LIVE, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
Sleep(50)
GUICtrlSetData($Loading_Label_LIVE, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
Sleep(50)
GUICtrlSetData($Loading_Label_LIVE, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
Sleep(50)
GUICtrlSetData($Loading_Label_LIVE, "xxxxxxxxxxxxxxxxxxxxxxxxxxxx")
Sleep(50)
GUICtrlSetData($Loading_Label_LIVE, "xxxxxxxxxxxxxxxxxxxxxxxxxxx")
Sleep(50)
GUICtrlSetData($Loading_Label_LIVE, "xxxxxxxxxxxxxxxxxxxxxxxxxx")
Sleep(50)
GUICtrlSetData($Loading_Label_LIVE, "xxxxxxxxxxxxxxxxxxxxxxxxx")
Sleep(50)
GUICtrlSetData($Loading_Label_LIVE, "xxxxxxxxxxxxxxxxxxxxxxxx")
Sleep(50)
GUICtrlSetData($Loading_Label_LIVE, "xxxxxxxxxxxxxxxxxxxxxxx")
Sleep(50)
GUICtrlSetData($Loading_Label_LIVE, "xxxxxxxxxxxxxxxxxxxxxx")
Sleep(50)
GUICtrlSetData($Loading_Label_LIVE, "xxxxxxxxxxxxxxxxxxxxx")
Sleep(50)
GUICtrlSetData($Loading_Label_LIVE, "xxxxxxxxxxxxxxxxxxxx")
Sleep(50)
GUICtrlSetData($Loading_Label_LIVE, "xxxxxxxxxxxxxxxxxxx")
Sleep(50)
GUICtrlSetData($Loading_Label_LIVE, "xxxxxxxxxxxxxxxxxx")
Sleep(50)
GUICtrlSetData($Loading_Label_LIVE, "xxxxxxxxxxxxxxxxx")
Sleep(50)
GUICtrlSetData($Loading_Label_LIVE, "xxxxxxxxxxxxxxxx")
Sleep(50)
GUICtrlSetData($Loading_Label_LIVE, "xxxxxxxxxxxxxxx")
Sleep(50)
GUICtrlSetData($Loading_Label_LIVE, "xxxxxxxxxxxxxx")
Sleep(50)
GUICtrlSetData($Loading_Label_LIVE, "xxxxxxxxxxxxx")
Sleep(50)
GUICtrlSetData($Loading_Label_LIVE, "xxxxxxxxxxxx")
Sleep(50)
GUICtrlSetData($Loading_Label_LIVE, "xxxxxxxxxxx")
Sleep(50)
GUICtrlSetData($Loading_Label_LIVE, "xxxxxxxxxx")
Sleep(50)
GUICtrlSetData($Loading_Label_LIVE, "xxxxxxxxx")
Sleep(50)
GUICtrlSetData($Loading_Label_LIVE, "xxxxxxxx")
Sleep(50)
GUICtrlSetData($Loading_Label_LIVE, "xxxxxxx")
Sleep(50)
GUICtrlSetData($Loading_Label_LIVE, "xxxxxx")
Sleep(50)
GUICtrlSetData($Loading_Label_LIVE, "xxxxx")
Sleep(50)
GUICtrlSetData($Loading_Label_LIVE, "xxxx")
Sleep(50)
GUICtrlSetData($Loading_Label_LIVE, "xxx")
Sleep(50)
GUICtrlSetData($Loading_Label_LIVE, "xx")
Sleep(50)
GUICtrlSetData($Loading_Label_LIVE, "x")
Sleep(50)
GUICtrlSetData($Loading_Label_LIVE, "")
If $Checking_LIVE = True Then
GUICtrlSetData($Checking_Label_LIVE, "MSN LIVE is running.") 
GUICtrlSetState($Close_LIVE, $GUI_ENABLE)
Else
GUICtrlSetData($Checking_Label_LIVE, "MSN LIVE is not running.")
GUICtrlSetState($Close_LIVE, $GUI_DISABLE)
EndIf
Case $nMsg = $Close_NORMAL
ProcessClose("msmsgs.exe")
Case $nMsg = $Close_LIVE
ProcessClose("msnmsgr.exe")
EndSelect
WEnd

Just playing with ProcessExist() and ProcessClose()...

I was bored as you see <_<

I just wanted to play some with AutoIT ^^


Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

Share this post


Link to post
Share on other sites
Jos

here is an example how to use loops <_<

#include <GUIConstants.au3>
$Checking_NORMAL = ProcessExists("msmsgs.exe")
$Checking_LIVE = ProcessExists("msnmsgr.exe")
$GUI = GUICreate("MSN Watcher Advanced", 380, 150, -1, -1)
GUISetState(@SW_SHOW)
$Label_1 = GUICtrlCreateLabel("MSN Watcher Advanced, a program to see if de MSN Process is still running.", 10, 10)
$Label_2 = GUICtrlCreateLabel("Just press the CHECK button to check if its running.", 10, 30)
$CHECK_NORMAL = GUICtrlCreateButton("CHECK NORMAL", 10, 50, 170, 30)
$CHECK_LIVE = GUICtrlCreateButton("CHECK LIVE", 200, 50, 170, 30)
$Checking_Label_NORMAL = GUICtrlCreateLabel("", 10, 80, 170, 15)
$Loading_Label_NORMAL = GUICtrlCreateLabel("", 10, 95, 170, 15)
$Checking_Label_LIVE = GUICtrlCreateLabel("", 200, 80, 170, 15)
$Loading_Label_LIVE = GUICtrlCreateLabel("", 200, 95, 170, 15)
$Close_NORMAL = GUICtrlCreateButton("CLOSE NORMAL", 10, 110, 170, 30)
$Close_LIVE = GUICtrlCreateButton("CLOSE LIVE", 200, 110, 170, 30)
GUICtrlSetState($Close_NORMAL, $GUI_DISABLE)
GUICtrlSetState($Close_LIVE, $GUI_DISABLE)
GUISetState()
While 1
    $nMsg = GUIGetMsg()
    Select
        Case $nMsg = $GUI_EVENT_CLOSE
            Exit
        Case $nMsg = $CHECK_NORMAL
            GUICtrlSetData($Checking_Label_NORMAL, "Checking...")
                GUICtrlSetData($Loading_Label_NORMAL, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
                While GUICtrlRead($Loading_Label_NORMAL) <> ""
                    GUICtrlSetData($Loading_Label_NORMAL, StringTrimRight(GUICtrlRead($Loading_Label_NORMAL),1))
                    Sleep(50)
                WEnd
                If $Checking_NORMAL = True Then
                GUICtrlSetData($Checking_Label_NORMAL, "MSN NORMAL is running.")
                GUICtrlSetState($Close_NORMAL, $GUI_ENABLE)
            Else
                GUICtrlSetData($Checking_Label_NORMAL, "MSN NORMAL is not running.")
                GUICtrlSetState($Close_NORMAL, $GUI_DISABLE)
            EndIf
        Case $nMsg = $CHECK_LIVE
            GUICtrlSetData($Checking_Label_LIVE, "Checking...")
            GUICtrlSetData($Loading_Label_LIVE, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
            While GUICtrlRead($Loading_Label_LIVE) <> ""
                GUICtrlSetData($Loading_Label_LIVE, StringTrimRight(GUICtrlRead($Loading_Label_LIVE),1))
                Sleep(50)
            WEnd
            If $Checking_LIVE = True Then
                GUICtrlSetData($Checking_Label_LIVE, "MSN LIVE is running.")
                GUICtrlSetState($Close_LIVE, $GUI_ENABLE)
            Else
                GUICtrlSetData($Checking_Label_LIVE, "MSN LIVE is not running.")
                GUICtrlSetState($Close_LIVE, $GUI_DISABLE)
            EndIf
        Case $nMsg = $Close_NORMAL
            ProcessClose("msmsgs.exe")
        Case $nMsg = $Close_LIVE
            ProcessClose("msnmsgr.exe")
    EndSelect
WEnd

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
gseller

Very nice!! Always nice to have a loop and onevent version... Thanks Both.. <_<

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.