climberman Posted August 8, 2008 Posted August 8, 2008 Can you access the gui events from a function? GUICreate ( "TradeBotOpto", 200, 300, @DesktopWidth-200, @DesktopHeight-300) $run = GUICtrlCreateButton ( "Run Bot", 10, 30) $stop = GUICtrlCreateButton ( "Stop Bot", 10, 70) $update = GUICtrlCreateButton ( "Update Prices", 10, 110) GUISetState () While 1 $guimsg = GUIGetMsg() Select Case $guimsg = $run RunBot() Case $guimsg = $stop StopBot() Case $guimsg = $update Update() Case $guimsg = -3 StopBot() ExitLoop EndSelect Sleep(100) ; Idle around WEnd This is what I start with and I can use the stop button of the GUI but only before it goes into a function. The GUIGetMsg() in the function doesn't do anything I guess because the sepcific GUI wasn't created in that function so how do I check to see whether the GUI controls were pressed while inside the function?
martin Posted August 8, 2008 Posted August 8, 2008 Can you access the gui events from a function? GUICreate ( "TradeBotOpto", 200, 300, @DesktopWidth-200, @DesktopHeight-300) $run = GUICtrlCreateButton ( "Run Bot", 10, 30) $stop = GUICtrlCreateButton ( "Stop Bot", 10, 70) $update = GUICtrlCreateButton ( "Update Prices", 10, 110) GUISetState () While 1 $guimsg = GUIGetMsg() Select Case $guimsg = $run RunBot() Case $guimsg = $stop StopBot() Case $guimsg = $update Update() Case $guimsg = -3 StopBot() ExitLoop EndSelect Sleep(100); Idle around WEnd This is what I start with and I can use the stop button of the GUI but only before it goes into a function. The GUIGetMsg() in the function doesn't do anything I guess because the sepcific GUI wasn't created in that function so how do I check to see whether the GUI controls were pressed while inside the function? All you need to do is pass the value of $guimsg to the function Case $guimsg = $run RunBot($guimsg) Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
rasim Posted August 9, 2008 Posted August 9, 2008 climbermanExample:GUICreate ( "TradeBotOpto", 200, 300, @DesktopWidth-200, @DesktopHeight-300) $run = GUICtrlCreateButton ( "Run Bot", 10, 30) $stop = GUICtrlCreateButton ( "Stop Bot", 10, 70) $update = GUICtrlCreateButton ( "Update Prices", 10, 110) GUISetState () While 1 $guimsg = GUIGetMsg() Select Case $guimsg = $run RunBot() Case $guimsg = $stop StopBot() Case $guimsg = $update Update() Case $guimsg = -3 StopBot() ExitLoop EndSelect WEnd Func RunBot() While 1 ;Simple loop for example If $guimsg = $stop Then StopBot() Return EndIf Sleep(100) WEnd EndFuncAlso you may use GUIOnEvent mode
climberman Posted August 10, 2008 Author Posted August 10, 2008 (edited) Thanks for the help guys, so far no luck exactly but i figured i'd throw ina check for the esc key so at least when things go wrong i have that fail safe. Otherwise i get locked in a loop where the mouse is clicking on a certain point and have to shut down manually. I'm gonna give the onevent mode a try and see what happens......... Ok the oneventmode works great and is extremely fast compared to the other method. Thanks Edited August 10, 2008 by climberman
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