nago Posted May 30, 2009 Share Posted May 30, 2009 (edited) Hi, I'm having some problems with the GUI modes conceptually. My goal is to have a small Gui frontend for a script which:A) Has a start button, Has a stop button,C) Has an exit button.D) Has a few settings fields, Apply/Save button (ETC).The "Start" button will start a long macro: A long series of keypresses, sleeps, WinWaitActive() functions, etcetera.The "Stop" button should stop the aforementioned function at any time.The "Exit" button -- the default window's "X", should close the gui and halt the script instantly at any time.The problem is, once the macro function has been started, the gui is no longer responsive... In either GUI mode. In the event mode, once one event has been triggered, none of the other buttons respond. Or, in the default mode, (with the case $button layout) the function with the macro sequence in it still prevents it from paying any attention from the gui, so.I'm at a loss for how to design something like this.I was considering actually putting this macro into its own .exe and calling it with Run(), but then there are issues of how to update the settings fields and variables and whatnot between the spawned script and the main settings window, etc.Any tips? Edited May 30, 2009 by nago Link to comment Share on other sites More sharing options...
dantay9 Posted May 31, 2009 Share Posted May 31, 2009 Try using a hot key and then use AdLibEnable(). See what you can do there. Link to comment Share on other sites More sharing options...
Valuater Posted May 31, 2009 Share Posted May 31, 2009 I suggest, due to the macros, to use HotKeySet() ... Be sure to see the demo at the bottom of the page, that may be exactly what you are looking for 8) Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted May 31, 2009 Share Posted May 31, 2009 (edited) What is happening is that your "macro" is a event so when it's executed any other events are queued. To solve that easily move your "macro" to the mainloop. See this (rather messy) example for OnEventMode: (run from SciTe and watch the console when you press the buttons) expandcollapse popup#include <GUIConstantsEx.au3> Opt("GUIOnEventMode", 1) Global $xyz = False GUICreate("Test") $start = GUICtrlCreateButton("start", 10, 10) GUICtrlSetOnEvent(-1, "_start") $stop = GUICtrlCreateButton("stop", 10, 50) GUICtrlSetOnEvent(-1, "_stop") GUISetState() GUISetOnEvent($GUI_EVENT_CLOSE, "_quit") While 1 If $xyz = True Then _SomeFunc() Sleep(10) WEnd Func _SomeFunc() While 1 If $xyz = False Then Return ConsoleWrite(Random() & @CRLF) Sleep(10) WEnd EndFunc Func _start() $xyz = True EndFunc Func _stop() $xyz = False EndFunc Func _quit() Exit EndFunc Edited May 31, 2009 by AdmiralAlkex .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
nago Posted May 31, 2009 Author Share Posted May 31, 2009 (edited) The HotKeySet() Is a good suggestion, though I am dead-set on using a stop button instead of a hotkey, if only for ease of use. I have always considered hotkeys, with regards to user interfaces, as secondary interfaces.As for the third reply, I will investigate this more deeply: I am not sure I understand what you mean just yet, so let me look into your example and digest it.Edit: OK, I see. I will still have to work the "Stop" functionality into my "Macro Function", however: the Exit button should at least now work with no further modifications. This is a good vector in which to solve this problem, I'll work on a version using your method. Very clever.In the meantime, any other suggestions are still welcome.For an example of my "Macro Function", it's something akin to the following:Func Macro WaitWinActive("Game Window") Sleep(200) Send('{ENTER}') sleep(20) Send('{ENTER}') sleep(20) Send('{DOWN}') sleep(30) ... EndFuncEtcetera. There are a lot of loops and various WinWaitActive()s in there, but the "main loop" of the macro function takes about two and a half minutes to complete.Second Edit: Since I'm only using Send() and Sleep() and WinWaitActive() in the 'Macro Function', I think what I can do to achieve an "instantaneous stop", is write a custom wrapper for each function, like _MacroSend(), _MacroSleep() and _MacroWinWaitActive(), and in those wrappers, just have a simple if/then, such as:If Not $STOP Then (Pass Arguments on to Proper Function)And so if "STOP" is pressed, all functions cease doing any actual work, achieving an emergency halt.Sound logic? Edited May 31, 2009 by nago 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