Batch Posted February 5, 2004 Share Posted February 5, 2004 I want to keep a user from being able to press a button. I realize this is not foolproof, but for the example pull up the runbox, run the script, OK the msgbox, and move your mouse x position to 174 and it moves your mouse away from the button. I'm guess you would need an IF statement where the coordinates were an array of the x and y coordinates that the button fills. How can I script it so that if you get your mouse close to the button it gets moved away? AutoItSetOption( "MouseCoordMode", 0 ) dim $pos $pos = ControlGetPos("Run", "", "Button3") msgbox( 1, "Run box", $pos[0] &", " &$pos[1] &", " &$pos[2] &", " &$pos[3]) While 1 Sleep( "1" ) $mousepos = MouseGetPos() SplashTextOn( "Da Mouse is", "Here da mouse X=" & $mousepos[0] & " Y=" & $mousepos[1] ) If $mousepos[0] = 174 Then MouseMove( 500, 500 ) Endif Wend WinWaitClose( "Run" ) Link to comment Share on other sites More sharing options...
Developers Jos Posted February 5, 2004 Developers Share Posted February 5, 2004 (edited) Do you mean move the button??? Heres a variation of Larry's fun.au3 script.. It starts Run and then just try to click any of the 3 buttons Maybe that helps you ? Send("#r") If Not WinWait("Run","",10) Then Exit $bp2=ControlGetPos( "Run","","Button2" ) $bp3=ControlGetPos( "Run","","Button3" ) $bp4=ControlGetPos( "Run","","Button4" ) AutoItSetOption ( "MouseCoordMode", 0 ) While WinExists("Run") $mp = MouseGetPos() $mp[1] = $mp[1] - 30; correction for the window border select case $mp[0] > $bp2[0] and $mp[0] < $bp2[0]+$bp2[2] and $mp[1] > $bp2[1] and $mp[1] < $bp2[1]+$bp2[3] ControlMove ( "Run","","Button2",$bp2[0]-$bp2[2]-5,$bp2[1]) ControlMove ( "Run","","Button3",$bp3[0],$bp3[1]) ControlMove ( "Run","","Button4",$bp4[0],$bp4[1]) case $mp[0] > $bp3[0] and $mp[0] < $bp3[0]+$bp3[2] and $mp[1] > $bp3[1] and $mp[1] < $bp3[1]+$bp3[3] ControlMove ( "Run","","Button2",$bp2[0]-$bp2[2]-5,$bp2[1]) ControlMove ( "Run","","Button4",$bp4[0],$bp4[1]) ControlMove ( "Run","","Button3",$bp3[0]-$bp3[2]-5,$bp3[1]) Case $mp[0] > $bp4[0] and $mp[0] < $bp4[0]+$bp4[2] and $mp[1] > $bp4[1] and $mp[1] < $bp4[1]+$bp4[3] ControlMove ( "Run","","Button2",$bp2[0]-$bp2[2]-5,$bp2[1]) ControlMove ( "Run","","Button3",$bp3[0]-$bp3[2]-5,$bp3[1]) ControlMove ( "Run","","Button4",$bp4[0]-$bp4[2]-5,$bp4[1]) Case Else ControlMove ( "Run","","Button4",$bp4[0],$bp4[1]) ControlMove ( "Run","","Button3",$bp3[0],$bp3[1]) ControlMove ( "Run","","Button2",$bp2[0],$bp2[1]) EndSelect Sleep(50) Wend Edited February 5, 2004 by JdeB SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Somerset Posted February 5, 2004 Share Posted February 5, 2004 (edited) Send("#r") If Not WinWait("Run","",10) Then Exit $bp2=ControlGetPos( "Run","","Button1" ) $bp3=ControlGetPos( "Run","","Button2" ) $bp4=ControlGetPos( "Run","","Button3" ) AutoItSetOption ( "MouseCoordMode", 0 ) While WinExists("Run") $mp = MouseGetPos() $mp[1] = $mp[1] - 30; correction for the window border select case $mp[0] > $bp2[0] and $mp[0] < $bp2[0]+$bp2[2] and $mp[1] > $bp2[1] and $mp[1] < $bp2[1]+$bp2[3] ControlMove ( "Run","","Button1",$bp2[0]-$bp2[2]-5,$bp2[1]) ControlMove ( "Run","","Button2",$bp3[0],$bp3[1]) ControlMove ( "Run","","Button3",$bp4[0],$bp4[1]) case $mp[0] > $bp3[0] and $mp[0] < $bp3[0]+$bp3[2] and $mp[1] > $bp3[1] and $mp[1] < $bp3[1]+$bp3[3] ControlMove ( "Run","","Button1",$bp2[0]-$bp2[2]-5,$bp2[1]) ControlMove ( "Run","","Button3",$bp4[0],$bp4[1]) ControlMove ( "Run","","Button2",$bp3[0]-$bp3[2]-5,$bp3[1]) Case $mp[0] > $bp4[0] and $mp[0] < $bp4[0]+$bp4[2] and $mp[1] > $bp4[1] and $mp[1] < $bp4[1]+$bp4[3] ControlMove ( "Run","","Button1",$bp2[0]-$bp2[2]-5,$bp2[1]) ControlMove ( "Run","","Button2",$bp3[0]-$bp3[2]-5,$bp3[1]) ControlMove ( "Run","","Button3",$bp4[0]-$bp4[2]-5,$bp4[1]) Case Else ControlMove ( "Run","","Button3",$bp4[0],$bp4[1]) ControlMove ( "Run","","Button2",$bp3[0],$bp3[1]) ControlMove ( "Run","","Button1",$bp2[0],$bp2[1]) EndSelect Sleep(50) Wend JdeB i just corrected the code you posted. you had the buttons wrong. should be 1, 2,3 well i had to change it for windows 98se may work they way you had it in another windows i dunno. but i love the way ya did it. Edited February 5, 2004 by beerman Link to comment Share on other sites More sharing options...
Developers Jos Posted February 5, 2004 Developers Share Posted February 5, 2004 JdeB i just corrected the code you posted. you had the buttons wrong. should be 1, 2,3 well i had to change it for windows 98se may work they way you had it in another windows i dunno. but i love the way ya did it.Yeap.. the version i posted works on WinXP.... SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Somerset Posted February 5, 2004 Share Posted February 5, 2004 hey why don't you add this to it JdeB, add a hotkey take over of the tab that says nope no tab keys allowed, and also resize the buttons really tiny so nobody can see them. Link to comment Share on other sites More sharing options...
Somerset Posted February 5, 2004 Share Posted February 5, 2004 JdeB and Larry, this is quite funny, but if you execute both of your scrips one right after another. JdeB trys to move the cancel button left and right and Larry moves it every which direction. if you go after the cancel button from either underneathe it or above it the cancel button wiggs out, had a really bad case of nerves. lol try and see what i mean. Link to comment Share on other sites More sharing options...
Somerset Posted February 5, 2004 Share Posted February 5, 2004 was jsut goofing around with your idea larry. you bad. i also threw in moving the combobox, buttons and static controls to move... kaos Link to comment Share on other sites More sharing options...
Batch Posted February 6, 2004 Author Share Posted February 6, 2004 Wow, that works, and I'm impressed, I just can't understand it If I read the help file again and pondered on this for some time I believe I would. Dang you guys are smart! 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