Jump to content
Sign in to follow this  
sen21

Do something when button is clicked

Recommended Posts

sen21

Hey

I wanted my script to store the position of the mouse when the left mouse button is clicked. I know I am almost there but it's not running the function when the mouse gets pressed. Here's what I have:

GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "_getButtonPosition")

Func _getButtonPosition()
     $mouse_pos = MouseGetPos()
EndFunc

I put a msg box in the _getButtonPosition method to see if it was even entering it or not, and it's not. Am I approaching this the wrong way or am I just doing something stupid? =)

Thanks

Share this post


Link to post
Share on other sites
narayanjr

look up _IsPressed()

Share this post


Link to post
Share on other sites
qazwsx

i would recommend not using a do until loop they are slower than while loops. I think...

Share this post


Link to post
Share on other sites
Buey

Did you do:

Opt("GUIOnEventMode",1)

?

Share this post


Link to post
Share on other sites
sen21

Did you do:

Opt("GUIOnEventMode",1)

?

Yeah, I did at the beginnng under my #include <GUIConstants.au3>.

I guess I'll just use the do until loop.

Thanks

Share this post


Link to post
Share on other sites
therks

Are you actually using a GUI? Cus GUISetOnEvent() is only going to capture mouse clicks on the GUI itself, otherwise yes, you will have to use _IsPressed().

Share this post


Link to post
Share on other sites
sen21

Are you actually using a GUI? Cus GUISetOnEvent() is only going to capture mouse clicks on the GUI itself, otherwise yes, you will have to use _IsPressed().

ahhh that would make sense. ok thanks everyone.

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  

×