Jump to content

On Button1_Click..? Help with if user clicks button 1


Recommended Posts

Hey guys! Im New to AutoIT but have been using Visual Studio 2008 So I do have some scripting knowledge... So As of now this is my first AutoIT project, And ive made my GUI and all But In my Script...For some reason I cant find the code for when the User click on Button1

Example: If user clicks Button1(ON) the mouse moving and clicking/keystroke script starts and if user clicks button2 (OFF) the script stops... I know in VB.net this would be If Button1_Click then Sorta deal , But I know that autoit is somewhat different, So please a little help? Thanks alot!

Link to comment
Share on other sites

Hey guys! Im New to AutoIT but have been using Visual Studio 2008 So I do have some scripting knowledge... So As of now this is my first AutoIT project, And ive made my GUI and all But In my Script...For some reason I cant find the code for when the User click on Button1

Example: If user clicks Button1(ON) the mouse moving and clicking/keystroke script starts and if user clicks button2 (OFF) the script stops... I know in VB.net this would be If Button1_Click then Sorta deal , But I know that autoit is somewhat different, So please a little help? Thanks alot!

Hi,

Opt("GuiOnEventMode",1);Switch on OnEventMode for GuiCtrls
 
 GuiCreate("",250,35)
 GuiCtrlCreateButton("Press me !",5,5,240,25)
 GuiCtrlSetOnEvent(-1,"_MyFunc");Set on event Button for "_MyFunc" function
 GuiSetState()

 Func _MyFunc()
 Msgbox(64,"","You pressed me !")
 EndFunc

While 1;Start loop for script (window will stay visible)
Sleep(250)
WEnd
Edited by FireFox
Link to comment
Share on other sites

like disss....

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Opt("GuiOnEventMode", 1);Switch on OnEventMode for GuiCtrls

GUICreate("", 250, 35)
GUISetOnEvent($GUI_EVENT_CLOSE, "_MyExit")
GUICtrlCreateButton("Press me !", 5, 5, 240, 25)
GUICtrlSetOnEvent(-1, "_MyFunc");Set on event Button for "_MyFunc" function
GUISetState()


While 1;Start loop for script (window will stay visible)
    Sleep(250)
WEnd

; -----------  Functions ------------------

Func _MyFunc()
    MsgBox(64, "", "You pressed me !")
EndFunc   ;==>_MyFunc

Func _MyExit()
    MsgBox(64, "", "You pressed Exit !")
    Exit
EndFunc   ;==>_MyExit

8)

Edited by Valuater

NEWHeader1.png

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