timjohnson Posted December 7, 2005 Share Posted December 7, 2005 Hi all, How can I test if the user click a certain button. Say if the user click the "cancel" button during the print diaglog box, I want to do action X. So, how can I test if the perdorm a certain muose click on that "cancel" button? Many thanks. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted December 7, 2005 Moderators Share Posted December 7, 2005 If this is a GUI you've made: While 1 $Msg = GUIGetMsg() If $Msg = $GUI_EVENT_CLOSE Then ; Do something EndIf Wend If your not using those, then maybe take a look at WinGetState(), Maybe MouseGetPos() and a mixture of _IsPressed(). Maybe there is some other means that I'm just a bit brain dead to think of at the moment. GL! 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. Link to comment Share on other sites More sharing options...
timjohnson Posted December 7, 2005 Author Share Posted December 7, 2005 Cheers, exactly what I need. Many many thanks. If this is a GUI you've made: While 1 $Msg = GUIGetMsg() If $Msg = $GUI_EVENT_CLOSE Then ; Do something EndIf Wend If your not using those, then maybe take a look at WinGetState(), Maybe MouseGetPos() and a mixture of _IsPressed(). Maybe there is some other means that I'm just a bit brain dead to think of at the moment. GL! Link to comment Share on other sites More sharing options...
seandisanti Posted December 7, 2005 Share Posted December 7, 2005 (edited) Hi all, How can I test if the user click a certain button. Say if the user click the "cancel" button during the print diaglog box, I want to do action X. So, how can I test if the perdorm a certain muose click on that "cancel" button? Many thanks.it kind of depends on where the button is... if it's a response to a msgbox, you check that by assigning the result to a variable: $LikeThis = msgbox(3,"Wasn't This Easy?","Don't you love the helpfile?") select case $LikeThis = 6 msgbox(0,"Good.","Me too.") case $LikeThis = 7 msgbox(0,"Oh yeah?!","You should read it before you answer") case $LikeThis = 2 msgbox(0,"Hmmm.","Well i guess cancel is better than no...") EndSelect if you're trying to get a response from a button in a gui you've made, then it depends on how your gui is running, either as a message loop, or eventmode. either way you should assign the button to a variable so that the return value can be evaluated. ;either way you run gui, next line should be the same. it assigns the button a name, so messages can be received from the button via the variable $ThisButton = GUICtrlCreateButton("Click me. I dare you.",0,0) ;for message loop (default) gui: ;... other code here $msg = GUIGetMsg() Select Case $msg = $ThisButton MsgBox(0,"Uh-oh","You've done it now...") EndSelect ;... other code ;for OnEventMode (my fav) GUICtrlSetOnEvent($ThisButton,"BTN") Func BTN() MsgBox(0,"Uh-oh","You've done it now...") EndFunc if you're talking about other buttons, like buttons in gui's you didn't make, or buttons to close the window, let me know and i'll provide more examples.... ***edit*** too slow i guess.... Edited December 7, 2005 by cameronsdad Link to comment Share on other sites More sharing options...
timjohnson Posted December 8, 2005 Author Share Posted December 8, 2005 if you're talking about other buttons, like buttons in gui's you didn't make, or buttons to close the window, let me know and i'll provide more examples....***edit*** too slow i guess....Hi cameronsdad,Thanks for your help. I have tried WinGetState(). I thought I make it works, but in fact it didn't.For the buttons, it is in fact buttons didn't make by me. It is just the Print" and "Cancel" buttons in the standard print diaglogue boxWhat I try to do is if the user click "Print"... of course it print stuff,else if user click "cancel", I will do a bunch of other action.Thanks. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now