Jump to content

GUI Event from function


Recommended Posts

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?

Link to comment
Share on other sites

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.
Link to comment
Share on other sites

climberman

Example:

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
EndFunc

Also you may use GUIOnEvent mode

Link to comment
Share on other sites

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 by climberman
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...