Bookman Posted November 13, 2005 Posted November 13, 2005 I am having trouble with this script. It works fine as long as there is only one instance of it running. Unfortunately, it doesnt close when $DB closes, so re-opening the $DB loads the script again. Sometimes I find three or four instances running, and have problems with it then. Any ideas? Thanks in advance Global Const $DB='FileMaker Pro Advanced - [Price_List]' ;Wait for the DB software to close WinWaitClose($DB) Exit ;Define the hot key set HotkeySet("{F5}", 'Search') HotkeySet("{F9}", 'Card') WinWait ($DB) Func Search() Local $Input = InputBox('Scanning', 'Incoming data:') If @Error Then Return WinActivate($DB) Send("^s") Sleep(300) Send($Input, 1) Send("{ENTER}", 0) EndFunc Func Card() WinActivate($DB) Send("^h") EndFunc
Moderators SmOke_N Posted November 13, 2005 Moderators Posted November 13, 2005 You could wrap them in an "If" statement. Global $DB = 'FileMaker Pro Advanced - [Price_List]' ;Define the hot key set HotkeySet("{F5}", 'Search') HotkeySet("{F9}", 'Card') WinWait($DB) While WinExists('FileMaker Pro Advanced - [Price_List]') Sleep(100) WEnd Func Search() If WinExists('FileMaker Pro Advanced - [Price_List]') Then Local $Input = InputBox('Scanning', 'Incoming data:') If @Error Then Return WinActivate($DB) Send("^s") Sleep(300) Send($Input, 1) Send("{ENTER}", 0) EndIf EndFunc Func Card() If WinExists('FileMaker Pro Advanced - [Price_List]') Then WinActivate($DB) Send("^h") EndIf EndFunc 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.
gspino Posted November 15, 2005 Posted November 15, 2005 (edited) Try adding this routine at the beginning of your script. It will exit the script immediately if one instance is already running. $sVersion = "Price_list" If WinExists($sVersion) Then Exit AutoItWinSetTitle($sVersion) Edited November 18, 2005 by gspino
Bookman Posted November 15, 2005 Author Posted November 15, 2005 Try adding this routine at the beginning of your script. It will exit the script immediately if once instance is already running.$sVersion = "Price_list"If WinExists($sVersion) Then ExitAutoItWinSetTitle($sVersion)I don't have a problem with more than one version of the price list running, I have hte problem with three or four instances of the script running at the same time. Is there any way to prevent this?
Valuater Posted November 15, 2005 Posted November 15, 2005 (edited) from the top FAQ's... and as gspino stated ( just used the term "price list")14. How can I make sure only one copy of my script is run?The easiest way is to rename the title of the hidden AutoIt window when your script first starts. Then in the same script check for that window title existing - if it does then another copy of the script is running.; Place at the top of your script$g_szVersion = "My Script 1.1"If WinExists($g_szVersion) Then Exit ; It's already runningAutoItWinSetTitle($g_szVersion); Rest of your script goes here Back To Top8) Edited November 15, 2005 by Valuater
MHz Posted November 15, 2005 Posted November 15, 2005 This is perhaps the changes inserted that the others have mentioned. ; Only 1 instance. <-- as gspino mentioned $sVersion = "Price_list" If WinExists($sVersion) Then Exit AutoItWinSetTitle($sVersion) ;Define the hot key set HotKeySet("{F5}", 'Search') HotKeySet("{F9}", 'Card') WinWait($DB) ; Idle until $DB closes. <-- hotkeys will still work fine While WinExists($DB) Sleep(500) WEnd Func Search() Local $Input = InputBox('Scanning', 'Incoming data:') If @Error Then Return WinActivate($DB) Send("^s") Sleep(300) Send($Input, 1) Send("{ENTER}", 0) EndFunc Func Card() WinActivate($DB) Send("^h") EndFunc
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