Jump to content

Button doesn't trigger.


Recommended Posts

So, another newbie question here.

#include <GUIConstants.au3>
#include <Misc.au3>
$dll = DllOpen("user32.dll")
$Form1 = GUICreate("Jumping Jacks", 401, 101, 193, 115)
$Progress1 = GUICtrlCreateProgress(8, 8, 385, 33)
; GUICtrlSetData(-1, 0)
$Button1 = GUICtrlCreateButton("+1", 16, 56, 97, 33)
$msg = "Done: " & GUICtrlRead($Progress1)
$Label1 = GUICtrlCreateLabel($msg, 120, 56, 269, 30)
GUICtrlSetFont(-1, 20, 400, 0, "Adobe Garamond Pro")
GUISetState(@SW_SHOW)

$progresscore = GUICtrlRead($Progress1)+1
$Msg = GUIGetMsg()

    
While 1

    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
    If $Msg = $Button1 Then ;_IsPressed(09, $dll) Then
GUICtrlSetData($Progress1, GUICtrlRead($Progress1)+1)
EndIf   
WEnd

I want to make it such that when the button is clicked, the progress bar's progress is increased by one, but that doesn't work. It seems the button just doesn't trigger.

Link to comment
Share on other sites

So, another newbie question here.

#include <GUIConstants.au3>
#include <Misc.au3>
$dll = DllOpen("user32.dll")
$Form1 = GUICreate("Jumping Jacks", 401, 101, 193, 115)
$Progress1 = GUICtrlCreateProgress(8, 8, 385, 33)
; GUICtrlSetData(-1, 0)
$Button1 = GUICtrlCreateButton("+1", 16, 56, 97, 33)
$msg = "Done: " & GUICtrlRead($Progress1)
$Label1 = GUICtrlCreateLabel($msg, 120, 56, 269, 30)
GUICtrlSetFont(-1, 20, 400, 0, "Adobe Garamond Pro")
GUISetState(@SW_SHOW)

$progresscore = GUICtrlRead($Progress1)+1
$Msg = GUIGetMsg()

    
While 1

    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
    If $Msg = $Button1 Then ;_IsPressed(09, $dll) Then
GUICtrlSetData($Progress1, GUICtrlRead($Progress1)+1)
EndIf   
WEnd

I want to make it such that when the button is clicked, the progress bar's progress is increased by one, but that doesn't work. It seems the button just doesn't trigger.

Hmm. You use $nMsg for the GUIGetMsg(), yet you use $Msg for the If statement... Oops?
Link to comment
Share on other sites

Thanks alot! I wonder how I missed that...

Just use it the switch case and you don't need to worry about that, for example:

#include <GUIConstants.au3>
#include <Misc.au3>
$dll = DllOpen("user32.dll")
$Form1 = GUICreate("Jumping Jacks", 401, 101, 193, 115)
$Progress1 = GUICtrlCreateProgress(8, 8, 385, 33)
; GUICtrlSetData(-1, 0)
$Button1 = GUICtrlCreateButton("+1", 16, 56, 97, 33)
$msg = "Done: " & GUICtrlRead($Progress1)
$Label1 = GUICtrlCreateLabel($msg, 120, 56, 269, 30)
GUICtrlSetFont(-1, 20, 400, 0, "Adobe Garamond Pro")
GUISetState(@SW_SHOW)

$progresscore = GUICtrlRead($Progress1)+1
$Msg = GUIGetMsg()

   
While 1

    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
            Case $Button1
                GUICtrlSetData($Progress1, GUICtrlRead($Progress1)+1)
    EndSwitch
WEnd

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

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