Jump to content

Setting a HotKey to exit a loop


Recommended Posts

If that happened then the winwaitactive() will timeout and that will trigger the return.

:D

RK

But for that to work correctly you would have to add a timeout to every WinWaitActive(), correct?

Amp Energy Drink: the official sponsor of me scripting at 2AM.

Link to comment
Share on other sites

But for that to work correctly you would have to add a timeout to every WinWaitActive(), correct?

yes

"When the power of love overcomes the love of power, the world will know peace"-Jimi Hendrix

Link to comment
Share on other sites

yes

I think it would be easier, in that case, to just tell the IT department not to quit out of installs or tell them how to quit out of the program.

Amp Energy Drink: the official sponsor of me scripting at 2AM.

Link to comment
Share on other sites

Okay I will turn this into a challenge. Anyone who is up to it, copy this script and run the au3. the trick is to make the GUI responsive again after the "testing" option is selected from the box by any means necissary, as long as it can be performed by the user. I was using the example of a hot Key before becuase that is one way i thought it could be done, but I am sure there are other ways that I have not discovered. The way this one works is that the testing option sends a WinWaitActive() command for a window that will never be active. This would solve my problem becuase if an install gets quit out before a WinWaitActive() comes up somewhere, then the script becomes FUBAR. :D

The only parameter is that nothing be added within the pound signs unless really necissary. If it is an unobtrusive add, then by all means do it. I just want a solution that is minamalistic. Of course, in this case, any solution is going to be minamalistic, and I know that this particular case would take 15 seconds to fix, but try to imagine each "testing" selection being 15 WinWaitActives all with different window information, and you get how complicated a timeout could get (sorry rbhkamal!! :wacko: ) If it helps, it would be OK to change the way the loops are set up as long as it wont take 3 hours to fix. In my opinion, at my skill level, the more code there is the more problems could arise. :"> Please Help!

;Includes
#include <IE.au3>
#include <process.au3>
#include <GUIConstants.au3>
;Making the GUI
GUICreate("Puzzle", 250, 135)
$combo = GUICtrlCreateCombo("Selection 1", 25, 50, 200, 1000)
GUICtrlSetData(-1, "Selection 2")
$okbutton = GUICtrlCreateButton("Go!", 25, 80, 145, 30)
$cancelbutton = GUICtrlCreateButton("Cancel", 175, 80, 50, 30)
GUISetState()
$msg = GUIGetMsg()
;The while loop....
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $okbutton 
            $data = GUICtrlRead($combo)
;#########################################################################################
            If $data = "Testing" Then WinWaitActive("Testing 1", "Testing 1")
            If $data = "Testing 2" Then WinWaitActive("Testing 2", "Testing 2")
;#########################################################################################
        Case $msg = $cancelbutton
            ExitLoop
    EndSelect
    
WEnd

Amp Energy Drink: the official sponsor of me scripting at 2AM.

Link to comment
Share on other sites

BOOM! I finally got it!!!!!!!!! :whistle:

Func _ExitLoop()
        MsgBox(4096, "Exit", "Exiting Program.")
        GUIDelete()
        _OpeningGUI()
        GUISetState()
EndFunc

Basically I turned each chunk of my script into a Function, so my script is essentially 2 lines (setting the hotkey and telling it to open the first function).

I doubt anyone cares but I feel really relieved. I am supposed to present this thing to the rest of the department tomorrow and this was the biggest problem. :)

Edited by mike1305

Amp Energy Drink: the official sponsor of me scripting at 2AM.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...