Jump to content

Recommended Posts

Posted (edited)

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
Posted

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.

Posted

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
Posted

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

Posted

Thank you!

That worked great for me.

Still need to understand in detail all the code, because I just did a copy paste. Never worked with GUI before in autoit.

Thanks again.

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...