Sign in to follow this  
Followers 0
cornholio

catch a boutton click

6 posts in this topic

Hello, i'm new to this language. I've searched in the help chm for a way to change what happens when user clicks a button...i woould need some help plz..is it is possible

Share this post


Link to post
Share on other sites



In the help file there is a section under AutoIt called "GUI Reference"

There are 2 ways to detect when a button is pressed, one is OnEvent mode and the other is MessageLoop mode,

Look at them both and decide which one you want to use

Share this post


Link to post
Share on other sites

Thanks. I've read the examples from gui reference; good to know. What i want to do: being given a window not from a gui I made), I want to have my program in the background and, when a user click a specific button in that window, my program to show a message box(par example).

I don't know how to react to an event from an outside window. I can though get the position of the button i want to catch and use some mouse events when the user clicks in that area, but i didn't find the events on mouse click, just functions to perform clicks and other mouse operations.

Share this post


Link to post
Share on other sites

If you want to do OnEvent Mode (I prefer it)

At the begging of the script write a line of code: Opt("GUIOnEventMode",1) to set the mode to OnEvent

After creating the control have a line of code: GUIControlSetOnEvent($button,"Function") to set the Event to the control

Then define the function

Func Function()
     MsgBox(0,"Title","Text")
EndFunc

Share this post


Link to post
Share on other sites

WinExists() + WinActive() + ControlGetFocus() + _IsPressed()


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

If you want to do OnEvent Mode (I prefer it)

At the begging of the script write a line of code: Opt("GUIOnEventMode",1) to set the mode to OnEvent

After creating the control have a line of code: GUIControlSetOnEvent($button,"Function") to set the Event to the control

Then define the function

Func Function()
     MsgBox(0,"Title","Text")
EndFunc
I did not create the control, and $button shoul be the controlID as returned by the fucntion GUICtrlCreate(..)..

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