Sign in to follow this  
Followers 0
Krypton88

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

6 posts in this topic

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!

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

Hey thanks for that man, how do I make the "X" (exit button) on top right work? Didnt know i need a code for that. Guess im used to VB doing that part for me lol

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

Welcome!!

8)


NEWHeader1.png

Share this post


Link to post
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
Sign in to follow this  
Followers 0