john_2019 Posted March 1, 2019 Posted March 1, 2019 To prevent multiple instances of the same script I use "_Singleton" function: #include <Misc.au3> If _Singleton("ScriptID", 1) = 0 Then Exit EndIf HotKeySet("{F2}", "_test") While 1 Sleep(100) WEnd Func _test() MsgBox(64, "Title", "Content") EndFunc However, if I double-click this script, then change "Content" to "New content" and then double-click again - it will not be updated. It will be just "Content". How to fix it? Also, another question: Is there more elegant way to prevent script from immediately exiting? Currently I use "while" for it.
Exit Posted March 1, 2019 Posted March 1, 2019 your first script does not end. The hotkey is allocated to the first script and work fine. The hotkeyset of the second script fails due to hotkey already defined. App: Au3toCmd UDF: _SingleScript()
john_2019 Posted March 1, 2019 Author Posted March 1, 2019 @Exit I understand. But how to fix it? I came here from AutoHotkey world, and it was quite easy there: just add "#SingleInstance, Force" line in the top of the script and that's all.
jdelaney Posted March 1, 2019 Posted March 1, 2019 Change script name for second script. IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Exit Posted March 1, 2019 Posted March 1, 2019 (edited) @john_2019 Just use my UDF "_SingleScript.au3" Here a sample code #include "_SingleScript.au3" ; http://www.autoitscript.com/forum/index.php?showtopic=178681 _SingleScript() HotKeySet("{F2}", "_test") MsgBox(64 + 262144, Default, "Press OK and then F2", 0) While 1 Sleep(1000) WEnd Func _test() MsgBox(64+262144, Default, "Test 1",0) ; change text here to see difference Exit EndFunc ;==>_test The _SingleScript.au3 code can be found here Edited March 9, 2019 by Exit point to new #include location App: Au3toCmd UDF: _SingleScript()
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