Sign in to follow this  
Followers 0
Ices

Any way to exit a specific script with a script?

4 posts in this topic

I'm looking for a way to close a script when a hotkey is pressed in another script. The only way I know how is with processclose, but if my scripts aren't compiled, I can't use processclose. Is there any way to set a unique ID to a script when starting it, then using that ID to close it with another script? Any help would be appreciated.

Thanks in Advance,

Ices

Share this post


Link to post
Share on other sites



You can make something like a loop in the first script to check .ini file for a specific value every 5 secs for example and if the value is matched to exit the first script. And in the second script youcan set that value in the ini file whenever you want to exit the first script.

Share this post


Link to post
Share on other sites

Script 1:

#include <WinAPI.au3>

Global $iUniqueMSg
Global $hGUI

$iUniqueMSg = _WinAPI_RegisterWindowMessage('SomeUniqueLiteralMessageString')
$hGUI = GUICreate('Test', 100, 100)
GUIRegisterMsg($iUniqueMSg, '_QuitScript')

ToolTip('Script1 is running...', @DesktopWidth-150, 0)
While 1
    Sleep(20)
WEnd

Func _QuitScript($hwnd, $iMsg, $iwParam, $ilParam)
    GUIDelete()
    Exit
EndFuncoÝ÷ Ù'+vjëh×6#include <WinAPI.au3>
HotKeySet('{ESC}', '_CloseScripts')

Global Const $HWND_BROADCAST = 0xFFFF
Global $iUniqueMsg

$iUniqueMsg = _WinAPI_RegisterWindowMessage('SomeUniqueLiteralMessageString')
ToolTip('Script2 is running...', @DesktopWidth-150, 25)

While 1
    Sleep(20)
WEnd

Func _CloseScripts()
    DllCall('user32.dll', 'int', 'PostMessage', 'hwnd', $HWND_BROADCAST, 'uint', $iUniqueMsg, _
            'wparam', 0, 'lparam', 0)
    Exit
EndFunc

Share this post


Link to post
Share on other sites

Ahh, I didn't think of that. That will work great, thanks.

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