AustrianOak Posted May 6, 2008 Share Posted May 6, 2008 What is the function or what will make my script run only once at a time. I know the code for this in autohotkey is #SingleInstance... Thanks in advance,.. Link to comment Share on other sites More sharing options...
SinkoDemio Posted May 6, 2008 Share Posted May 6, 2008 _SingleTon(@ScriptName) Link to comment Share on other sites More sharing options...
danielkza Posted May 6, 2008 Share Posted May 6, 2008 _SingleTon(@ScriptName)I don't think this will work because changing executable/script name will change the singleton identifier and allow a second instance.Try using a fixed phrase. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted May 6, 2008 Moderators Share Posted May 6, 2008 I don't think this will work because changing executable/script name will change the singleton identifier and allow a second instance.Try using a fixed phrase.You can use any string as the singleton identifier.... I wouldn't use the executable name, just type in something like: _SingleTon("MyUniqueStringToOnlyRunThisOnce") Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
AustrianOak Posted May 6, 2008 Author Share Posted May 6, 2008 what do you mean by a unique string? Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted May 6, 2008 Moderators Share Posted May 6, 2008 (edited) what do you mean by a unique string?I gave you an example of a "Unique" string, something you feel no other program would be using.Edit:You could even create a GUID to use with it, but you don't have to be so elaborate. Edited May 6, 2008 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Vindicator209 Posted May 6, 2008 Share Posted May 6, 2008 _SingleTon(@ScriptName) will work fine, I think ScriptName returns the name no matter what they change it to [center]"When you look at old, classic games like Snake, you often put it off because it's such a simple game, but it's only when you actually try and create your own unique game from scratch, do you finally appreciate those games."[/center][center]Don't ask for answers if you haven't TRIED yet![/center][center]Most answers can be answered in the help file! Use it![/center] Link to comment Share on other sites More sharing options...
danielkza Posted May 7, 2008 Share Posted May 7, 2008 _SingleTon(@ScriptName)will work fine, I think ScriptName returns the name no matter what they change it toFrom HelpFile:Filename of the running script.That means if you run the script,change it's name and run it again,the _Singleton strings will be different,and it will not detect the new instance.You must use a fixed,literal,non-changing string,such as "My Program Singleton that never changes",to make sure no 'cheating' is possible. Link to comment Share on other sites More sharing options...
PsaltyDS Posted May 7, 2008 Share Posted May 7, 2008 _SingleTon(@ScriptName) will work fine, I think ScriptName returns the name no matter what they change it to You are wrong and SmOke_N is right. Compile this script as Test.exe: #include <Misc.au3> If _Singleton(@ScriptName, 1) Then MsgBox(64, "Singleton", "Singleton") Else MsgBox(16, "Not Singleton", "Not Singleton") EndIf Now copy Test.exe to Test_New.exe and then run them both... They both say singleton. Repeat the experiment with this code: #include <Misc.au3> If _Singleton("MyUniqueStringToOnlyRunThisOnce", 1) Then MsgBox(64, "Singleton", "Singleton") Else MsgBox(16, "Not Singleton", "Not Singleton") EndIf Now the second instance reports "Not Singleton". 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...
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