weasel127 Posted August 19, 2006 Share Posted August 19, 2006 Hi, I have a program that constantly crashes for reasons that I'm not sure of (00Thothey.exe), so I decided to make a program to start it back up as a temporary fix. However, my problem occurs while Windows is starting up. Both this program and 00Thotkey start up at Windows. If this program starts up before 00Thotkey, then it will check the processes, see that 00Thotkey isn't there, and start it up. After that, 00Thotkey will also start up from the registry. Then there will be 2 00Thotkey processes open. As a temporary fix, I added a "sleep for 3 minutes" command as a rough approximation so that 00Thotkey has time to start up in case this program does first. Is there a better way to solve this problem? My code is at the bottom. (And I'm new to AutoIT and programming, so don't be too harsh ) #NoTrayIcon Sleep(180000);Sleep in case system is starting up HotKeySet("^!{F1}", "THotkeyStart") ;--------include Process.au3------- Func _RunDOS($sCommand) Return RunWait(@ComSpec & " /C " & $sCommand, "", @SW_HIDE) EndFunc ;---------------------------------- Func THotkeyStart() dim $msg1 $msg1 = MsgBox( 36, "Start hotkey", "Do you want to start 00THotkey.exe?") If $msg1=6 Then _RunDOS("start C:\windows\system32\00Thotkey.exe") EndIf If $msg1=7 Then sleep(1) EndIf EndFunc ;Auto monitor While 1 Sleep(7000);Save CPU If Not ProcessExists("00Thotkey.exe") Then _RunDOS("start C:\windows\system32\00Thotkey.exe") EndIf WEnd Link to comment Share on other sites More sharing options...
NELyon Posted August 19, 2006 Share Posted August 19, 2006 (edited) maybe look at the function _Singleton EDIT: Accidently named it _Simpleton (Refering to what i am!) Edited August 19, 2006 by codemyster Link to comment Share on other sites More sharing options...
Valuater Posted August 19, 2006 Share Posted August 19, 2006 not bad..., just cleaned up a little #NoTrayIcon HotKeySet("^!{F1}", "THotkeyStart") Sleep(180000);Sleep in case system is starting up ;Auto monitor While 1 Sleep(7000);Save CPU If Not ProcessExists("00Thotkey.exe") Then Run(@ComSpec & " /C start C:\windows\system32\00Thotkey.exe", "", @SW_HIDE) EndIf WEnd Func THotkeyStart() Local $msg1 = MsgBox( 36, "Start hotkey", "Do you want to start 00THotkey.exe?") If $msg1=6 Then Run(@ComSpec & " /C start C:\windows\system32\00Thotkey.exe", "", @SW_HIDE) EndFunc 8) Link to comment Share on other sites More sharing options...
Helge Posted August 19, 2006 Share Posted August 19, 2006 You could try to replace the long sleep with a ProcessWait.I noticed that you use _RunDos to launch the program, when you could just simply use Runinstead. Also, you could make your If's to just single-liners by doing something like this :If $msg1=7 Then sleep(1)Btw...do you have a Toshiba computer ? If not then you should check out this link :http://www.justtext.com/processes-tasks/00thotkey-exe.html Link to comment Share on other sites More sharing options...
weasel127 Posted August 19, 2006 Author Share Posted August 19, 2006 I just searched _Singleton on the forums for information about it and I saw that it will prevent multiple proceses from being loaded. But however if this program starts up first and _singleton does not see 00Thotkey.exe because it didn't open yet, then it will still start up the process again and i will have 2 00Thotkey.exe processes running again (unless _singleton does something else and I misread the posts). And thanks for cleaning up my program/ the suggestions. And yes I use a Toshiba laptop. 00Thotkey is a program from Toshiba which controls the special keys on the keyboard which is why I it bothers me when it crashes What I'm thinking of doing is checking if 00Thotkey is running at the beginning, and if it isn't, wait until it IS running and then keep checking if it is active or not (since 00Thotkey does not crash at startup) Link to comment Share on other sites More sharing options...
Helge Posted August 19, 2006 Share Posted August 19, 2006 As I suggested, you could try to use ProcessWait to "wait until it IS running". Link to comment Share on other sites More sharing options...
Valuater Posted August 19, 2006 Share Posted August 19, 2006 (edited) maybe #NoTrayIcon Dim $is_running = 0 HotKeySet("^!{F1}", "THotkeyStart") Sleep(180000);Sleep in case system is starting up ;Auto monitor While 1 Sleep(7000);Save CPU If $is_running And Not ProcessExists("00Thotkey.exe") Then Run(@ComSpec & " /C start C:\windows\system32\00Thotkey.exe", "", @SW_HIDE) EndIf WEnd Func THotkeyStart() Local $msg1 = MsgBox( 36, "Start hotkey", "Do you want to start 00THotkey.exe?") If $msg1=6 Then Run(@ComSpec & " /C start C:\windows\system32\00Thotkey.exe", "", @SW_HIDE) $is_running = 1 EndFunc once the hot is is pressed... then it will start checking 8) Edited August 19, 2006 by Valuater Link to comment Share on other sites More sharing options...
weasel127 Posted August 19, 2006 Author Share Posted August 19, 2006 As I suggested, you could try to use ProcessWait to "wait until it IS running".Oh, I didn't see that XD sometimes i can be absent-minded. Thanks everyone for helping me with this and cleaning up my script Link to comment Share on other sites More sharing options...
Helge Posted August 19, 2006 Share Posted August 19, 2006 (edited) Valuater.. I think you need some sleep. You're running "comspec", which again runs "start" which finally run "00Thotkey.exe". Why not just run "00Thotkey.exe" immediatelly ? Now, brush your teeth and go straight to the bed ! Edit : I knew there were something wrong with this post...start is a parameter for comspec. Seems like it's time for me to go to bed as well... Edited August 19, 2006 by Helge Link to comment Share on other sites More sharing options...
Valuater Posted August 19, 2006 Share Posted August 19, 2006 yepper... you are right!!!You're running "comspec", which again runs "start"i just kinda copied and pasted stuff from the _RunDos()8)i will be cleaning my teeth real soonlol 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