Jump to content

Recommended Posts

Posted

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 :P )

#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
Posted (edited)

maybe look at the function _Singleton

EDIT: Accidently named it _Simpleton (Refering to what i am!)

Edited by codemyster
Posted

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)

NEWHeader1.png

Posted

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 :P

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)

Posted (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 by Valuater

NEWHeader1.png

Posted

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 :P

Posted (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 ? :P

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 by Helge

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
  • Recently Browsing   0 members

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