boogieoompa Posted September 28, 2005 Share Posted September 28, 2005 I know someone is going to say "I got this right out of the help manual" but I looked and I don't see what I am doing wrong. Basically I want autoit to exit whenever I exit my app that I am using it for. But I don't know how to place the exit command since I already have a while loop running (that picks up hotkeys). I tried combing the two while statements if multiple ways (including an if winExists statment) Any suggestions? Thanks ahead ;way 1___________________________________________________ While 1 WinWaitClose("Freecell") Exit Wend While 1 HotKeySet("a", "Function_1") Wend ;way2__________________________________________ While 1 If WinExists("Freecell") Then HotKeySet("a", "Function_1") Else Exit Endif Wend Link to comment Share on other sites More sharing options...
Somerset Posted September 28, 2005 Share Posted September 28, 2005 Runwait??? Link to comment Share on other sites More sharing options...
peethebee Posted September 28, 2005 Share Posted September 28, 2005 Hi! You should set the hotkey at the beginning. No Loop is needed around it. So your script is necer interpreted as far as the start of the second loop, cause the first one is an infinite loop. peethebee vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvGerman Forums: http://www.autoit.deGerman Help File: http://autoit.de/hilfe vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv Link to comment Share on other sites More sharing options...
herewasplato Posted September 28, 2005 Share Posted September 28, 2005 Like this: HotKeySet("a", "Function_1") While 1 ; put your code in here ; ; ; If NOT WinExists("Freecell") Then Exit WEnd Func Function_1() ; put your code in here ; EndFuncThat code layout should exit the script when the window goes away... later [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
boogieoompa Posted September 28, 2005 Author Share Posted September 28, 2005 Thanks for all the input however I think I was a little unclear in how I asked the question. I need the while loop because of the way that I am sending over the hotkeys (so that they work with caps lock). I simplified the code I posted not expecting it to make a difference (sorry). Here is a more accurate representation of what I am doing. Thanks While 1 WinWaitActive("freecell") ;turns on hot keys HotKeySet("a", "Function_1") WinWaitNotActive("freecell");Turns off hotkeys by sending through windows HotKeySet("a") If NOT WinExists("Freecell") Then Exit Wend While 1 Sleep(100) WEnd Link to comment Share on other sites More sharing options...
AutoChris Posted September 28, 2005 Share Posted September 28, 2005 Thanks for all the input however I think I was a little unclear in how I asked the question. I need the while loop because of the way that I am sending over the hotkeys (so that they work with caps lock). I simplified the code I posted not expecting it to make a difference (sorry). Here is a more accurate representation of what I am doing.ThanksWhile 1 WinWaitActive("freecell") ;turns on hot keys HotKeySet("a", "Function_1") WinWaitNotActive("freecell");Turns off hotkeys by sending through windows HotKeySet("a") If NOT WinExists("Freecell") Then Exit Wend While 1 Sleep(100) WEnd There is no need for two While...WEnd loops. While 1 If WinWaitActive("freecell") Then HotKeySet("a", "Function_1") If WinWaitNotActive("freecell") Then HotKeySet("a") If Not WinExists("Freecell") Then Exit Sleep (100) WEnd Link to comment Share on other sites More sharing options...
boogieoompa Posted September 28, 2005 Author Share Posted September 28, 2005 Thanks but it didn't seem to work. It doesn't appear to be registering the IF statments. Link to comment Share on other sites More sharing options...
AutoChris Posted September 28, 2005 Share Posted September 28, 2005 (edited) Thanks but it didn't seem to work. It doesn't appear to be registering the IF statments. Actually, it isn't the "If" statements. It is because "FreeCell" was not capitalized. Here is another script to try: While 1 $active = WinWaitActive ("FreeCell") If $active = 1 Then HotKeySet ("a", "Function_1") $inactive = WinWaitNotActive ("FreeCell") If $inactive = 1 Then HotKeySet ("a") If Not WinExists ("FreeCell") Then Exit Sleep (100) WEnd Func Function_1() MsgBox (0, "", "Function 1") EndFunc Edited September 28, 2005 by SerialKiller 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