Jump to content

Clicking on a gui?


Recommended Posts

Hi!

Another quick question. I want something that can detect if you click on the Gui and if you did it would change a label ($labelA)

I tried this

Guisetonevent($form1, "ChangeLabel")

Func ChangeLabel()

Guictrlsetdata($labelA,GUIctrlREAD($LabelA) - 1)

EndFunc

I also tried

If _ispressed (01) then

Guictrlsetdata($labelA,GUIctrlREAD($LabelA) - 1)

Endif

I knew the second one wouldnt work but did i do something wrong in the first one??

Please help me!

code
Link to comment
Share on other sites

Is this what you want to happen?

#include <GUIConstants.au3>

Opt("GuiOnEventMode",1)

$Form = GUICreate("Click to Update", 200, 200)
GUISetOnEvent($GUI_EVENT_CLOSE, "quit")
GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "UpdateInput")
$Input = GUICtrlCreateInput("1", 32, 32, 136, 21,BitOr( $ES_Number,$ES_Center,$ES_Readonly))
GUISetState(@SW_SHOW)

While 1
    Sleep(500)
WEnd

Func Quit()
    Exit
EndFunc

Func UpdateInput()
    GUICtrlSetData($Input, GuiCtrlRead($Input)+1)
EndFunc
Edited by Paulie
Link to comment
Share on other sites

Is this what you want to happen?

#include <GUIConstants.au3>

Opt("GuiOnEventMode",1)

$Form = GUICreate("Click to Update", 200, 200)
GUISetOnEvent($GUI_EVENT_CLOSE, "quit")
GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "UpdateInput")
$Input = GUICtrlCreateInput("1", 32, 32, 136, 21,BitOr( $ES_Number,$ES_Center))
GUISetState(@SW_SHOW)

While 1
    Sleep(500)
WEnd

Func Quit()
    Exit
EndFunc

Func UpdateInput()
    GUICtrlSetData($Input, GuiCtrlRead($Input)+1)
EndFunc

Yes, Thank you this is exactly what I needed! I thought you had to do this GUISetOnEvent($Form1, "UpdateInput") instead of this GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "UpdateInput"). Thank you

And i have one more question how can i make sure a sound ( Soundplay("sound.wav") ) is playing at all times??

Thank you for your help!

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