Jump to content

Button won't fire


 Share

Recommended Posts

Why won't the button on my GUI call the function? Here's the relevant parts of the code:

$BtnAdd = GUICtrlCreateButton("Add", 305, 7, 50, 49)

$BtnStart = GUICtrlCreateButton("Start", 354, 7, 50, 49)

GUISetState()

While 1

$msg = GUIGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE

ExitLoop

Case $msg = $BtnAdd

Case $msg = $BtnStart

Call RunApps()

EndSelect

WEnd

Thanks!

Edited by DanielDaniel
Link to comment
Share on other sites

Thanks for the quick reply, but still no use. I have reduced the code to this:

While 1

$msg = GUIGetMsg()

If $msg <> 0 Then msgbox(0, "hj", $msg)

Select

Case $msg = $GUI_EVENT_CLOSE

ExitLoop

Case $msg = $BtnAdd

MsgBox(0, "hh", "hh")

EndSelect

WEnd

But the msgbox never fires as I suspect that $msg never has a value other than 0.

Link to comment
Share on other sites

I've added a gui to your script and a message to the RunApps() function, to test it. 

#include <GUIConstantsEx.au3>

GUICreate("GUI", 600, 400)

$BtnAdd = GUICtrlCreateButton("Add", 305, 7, 50, 49)
$BtnStart = GUICtrlCreateButton("Start", 354, 7, 50, 49)

GUISetState()

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $BtnAdd

        Case $msg = $BtnStart
            RunApps()
    EndSelect
WEnd

Func RunApps()
    MsgBox(0,"mnbvbv","mnbvmnbbv")
EndFunc

Maybe you have a problem with your other part of the script.

[edit] Please use "[autoit]" tags when you post your code. It's more "readable" because of the syntax highlighting.

Edited by taietel
Link to comment
Share on other sites

Just to close the loop, I solved this problem. I had put the below line in my code, meaning that the buttons were now event driven (I actually prefer this) rather than using the msg$ and Do/Until option.

Opt("GUIOnEventMode", 1)

Simply adding the event to the button with the below command solved the problem.

GUICtrlSetOnEvent($BtnStart, "RunApps")
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...