Jump to content

Button Command


houseonfire
 Share

Recommended Posts

$button_1 = guictrlcreatebutton("Go", left, top, width, height)

if you want that button to do something, then example:

While 1
$msg = GuiGetMsg()
if $msg = (button name) then
(do something here)
endif

[font=Microsoft Sans Serif]My Scripts: From Most recent to least.[/font]Countdown GUI | QLOCK TWO | FlipClock | Slot Machine My UDF:_GenerateRandomNoRepeat | _GuiSnap

Link to comment
Share on other sites

I was gonna try that.. but the $msg thing made me think its gonna pop up a message.

Thank you very much.

$Button1 = GUICtrlCreateButton("test", 32, 112, 89, 41, 0)
While 1
    $msg = GuiGetMsg()
    If $msg = $Button1 Then
        MSGBox (0, "test", "test")
    endif
WEnd

Doesn't seem to work :s

Edited by houseonfire
Link to comment
Share on other sites

I tried that code to give a button some commands and it works great, but, whenever I click any button, I cannot close the Form via the X on the window corner, its like frozen waiting for the "While" to end.

Is there a way to prevent this?

thanks in advance.

Link to comment
Share on other sites

I tried that code to give a button some commands and it works great, but, whenever I click any button, I cannot close the Form via the X on the window corner, its like frozen waiting for the "While" to end.

Is there a way to prevent this?

thanks in advance.

Try to add this in your While loop!

;Check if user clicked on the close button
If $msg = $GUI_EVENT_CLOSE
   ;Destroy the GUI including the controls
    GUIDelete()
   ;Exit the script
    Exit
EndIf
Link to comment
Share on other sites

You actually need to create a GUI for it:

CODE

#include <GUIConstants.au3>

$GUI1 = GUICreate("GUI!", 346, 179, 193, 115)

$Button1 = GUICtrlCreateButton("Press Me!!!", 8, 8, 331, 161, 0)

GUISetState(@SW_SHOW)

While 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case $GUI_EVENT_CLOSE

Exit

Case $Button1

msgbox(0, "Test", "Testing!!!")

EndSwitch

WEnd

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