Sign in to follow this  
Followers 0
MrDeltaX

Need help ....

6 posts in this topic

#1 ·  Posted (edited)

Hi I am scripting a programm that checks if another programm is running.

I can use processexist to find the process but if you rename the programm I am searching for to something else you can't

find the programm anymore.

I know that the programm is using a DLL so is there a way to see if a specific DLL is running or another way to

check if a programm is running ?

Here's the script:

PS: there's some bug in it if the programm isn't running the statusbar is green but sometimes the red status bar displays for like 0,1 second and then it the statusbar get's green again.

Thanks alot for help <_<

#include <GUIConstants.au3>

Opt("GUIOnEventMode", 1)



;variables
$status = False 
$check=ProcessExists("switcherX.exe")
 $see="not running"
 

 
     


$nMsg = GUIGetMsg()



#Region ### START Koda GUI section ### Form=E:\Progamma's\AutoIt3\SciTE\Koda\Forms\Register.kxf
$Register = GUICreate("Switcher Check", 385, 200, 193, 115, $WS_EX_TOOLWINDOW)
GUISetBkColor(0x0054E3)
$Button1 = GUICtrlCreateButton("Close Switcher", 88, 128, 193, 25, 0)
$button4 = GUICtrlCreateButton("4", 336, 56, 40, 40, $BS_ICON)
GUICtrlSetImage(-132, "shell32.dll", -132)
GUICtrlCreateLabel("Check if Switcher is running with this programm. ", 8, 8, 330, 17)
GUICtrlSetBkColor(-1, 0x00FFFF)
$Label1 = GUICtrlCreateLabel("For more info see the README file.                                                     ", 8, 24, 330, 17)
GUICtrlSetBkColor(-1, 0x00FFFF)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

GUICtrlSetOnEvent($button4, "exitt")

GUICtrlSetOnEvent($button1, "closesw")


Func closesw()
    
    ProcessClose("switcherX.exe")

    EndFunc


Func exitt()
    Exit
EndFunc ;==>exitt



While 1
    Sleep(1000)




 If $check = 0 Then
     $status=False
      $see="not running"
 Else 
     $status=True
     $see="running"
 EndIf
 

$check=ProcessExists("switcherX.exe")

    If $status = True  Then
   $color = 0x800000
    ElseIf $status=False then
    $color = 0x00FF00
    EndIf

If $status = False Then
GuiCtrlSetState ($button1, $GUI_DISABLE)
Else
    GuiCtrlSetState ($button1, $GUI_ENABLE)
    EndIf

    $Label2 = GUICtrlCreateLabel("             Switcher is " & $see, 16, 72, 201, 17)
    GUICtrlSetBkColor(-1, $color)
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then
        ExitLoop
    EndIf






WEnd
Edited by MrDeltaX

Share this post


Link to post
Share on other sites



Hi I am scripting a programm that checks if another programm is running.

I can use processexist to find the process but if you rename the programm I am searching for to something else you can't

find the programm anymore.

I know that the programm is using a DLL so is there a way to see if a specific DLL is running or another way to

check if a programm is running ?

Here's the script:

PS: there's some bug in it if the programm isn't running the statusbar is green but sometimes the red status bar displays for like 0,1 second and then it the statusbar get's green again.

Thanks alot for help :)

First, you made the awfully hard to read with the random whitespace, and functions interspersed with the rest of the code.

Second, you can't have GuiOnEventMode set and use GuiGetMsg() in the same script.

Third, you are concerned the .exe might get renamed, but you are sure the .dll won't, and will only be in use by that same .exe???

Anyway, here is a shot at cleaning up the code and fixing the initial label color issue:

#include <GUIConstants.au3>

Opt("GUIOnEventMode", 1)

;variables
$status = False
$check = ProcessExists("switcherX.exe")
$see = "not running" 

$Register = GUICreate("Switcher Check", 385, 200, 193, 115, $WS_EX_TOOLWINDOW)
GUISetBkColor(0x0054E3)
GUISetOnEvent($GUI_EVENT_CLOSE, "exitt")

$Button1 = GUICtrlCreateButton("Close Switcher", 88, 128, 193, 25, 0)
GUICtrlSetOnEvent($Button1, "closesw")

$button4 = GUICtrlCreateButton("4", 336, 56, 40, 40, $BS_ICON)
GUICtrlSetImage(-1, "shell32.dll", -132)
GUICtrlSetOnEvent(-1, "exitt")

GUICtrlCreateLabel("Check if Switcher is running with this programm. ", 8, 8, 330, 17)
$Label1 = GUICtrlCreateLabel("For more info see the README file.                                                     ", 8, 24, 330, 17)
GUICtrlSetBkColor(-1, 0x00FFFF)

$Label2 = GUICtrlCreateLabel("               Switcher is " & $see, 16, 72, 201, 17)
GUICtrlSetBkColor(-1, 0x00FF00)

GUISetState(@SW_SHOW)

While 1
    Sleep(1000)

    If $check = 0 Then
        $status = False
        $see = "not running" 
    Else
        $status = True
        $see = "running" 
    EndIf

    $check = ProcessExists("switcherX.exe")

    If $status = True Then
        $color = 0x800000
    ElseIf $status = False Then
        $color = 0x00FF00
    EndIf

    If $status = False Then
        GUICtrlSetState($Button1, $GUI_DISABLE)
    Else
        GUICtrlSetState($Button1, $GUI_ENABLE)
    EndIf

    GUICtrlSetData($Label2, "               Switcher is " & $see)
    GUICtrlSetBkColor(-1, $color)
WEnd

Func closesw()
    ProcessClose("switcherX.exe")
EndFunc   ;==>closesw

Func exitt()
    Exit
EndFunc   ;==>exitt

<_<


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Sorry, Ye It's is dificul to read because it was a rewrite of another script of my.

And yes the programm uses a DLL named switcherx.dll and it's the only programm that uses that DLL.

(just another short question: What is registering a DLL ?)

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Sorry, Ye It's is dificul to read because it was a rewrite of another script of my.

And yes the programm uses a DLL named switcherx.dll and it's the only programm that uses that DLL.

(just another short question: What is registering a DLL ?)

Registering a DLL puts information about it in the registry. This is something like adding a program's directory to %PATH%. It makes it available without having to provide a bunch of location specific info like the path to the .DLL file.

You can use DLLs without registering them, but then you will have to fully path them out for every call. I haven't gone that deep on it, but there might be some Windows optimization gained from registering that allows a single copy of the DLL binary to service multiple processes too.

<_<

Edit: Typo

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

What do you plan to use this for?

Share this post


Link to post
Share on other sites

I just wan't to play a little with autoit.

That's why I make the programm <_<

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  
Followers 0