MrDeltaX Posted October 20, 2007 Share Posted October 20, 2007 (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 expandcollapse popup#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 October 20, 2007 by MrDeltaX Link to comment Share on other sites More sharing options...
PsaltyDS Posted October 20, 2007 Share Posted October 20, 2007 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: expandcollapse popup#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 Link to comment Share on other sites More sharing options...
MrDeltaX Posted October 20, 2007 Author Share Posted October 20, 2007 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 ?) Link to comment Share on other sites More sharing options...
PsaltyDS Posted October 20, 2007 Share Posted October 20, 2007 (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 October 20, 2007 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 Link to comment Share on other sites More sharing options...
JustinReno Posted October 20, 2007 Share Posted October 20, 2007 What do you plan to use this for? Link to comment Share on other sites More sharing options...
MrDeltaX Posted October 21, 2007 Author Share Posted October 21, 2007 I just wan't to play a little with autoit. That's why I make the programm Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now