Sign in to follow this  
Followers 0
Batch

Ok Here's A Challenge

8 posts in this topic

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" )

Share this post


Link to post
Share on other sites



#2 ·  Posted (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 :whistle:B)

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 by JdeB

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#3 ·  Posted (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. :whistle: but i love the way ya did it.

Edited by beerman

 

Spoiler

shoot_zpsfd329d66.png
dontbelieveeverythingyouthink_zps0e1e900

Madness is the first step to understanding...

Share this post


Link to post
Share on other sites

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. :whistle:  but i love the way ya did it.

Yeap.. the version i posted works on WinXP....

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

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. :whistle:


 

Spoiler

shoot_zpsfd329d66.png
dontbelieveeverythingyouthink_zps0e1e900

Madness is the first step to understanding...

Share this post


Link to post
Share on other sites

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.


 

Spoiler

shoot_zpsfd329d66.png
dontbelieveeverythingyouthink_zps0e1e900

Madness is the first step to understanding...

Share this post


Link to post
Share on other sites

was jsut goofing around with your idea larry. you bad. i also threw in moving the combobox, buttons and static controls to move... :whistle: kaos


 

Spoiler

shoot_zpsfd329d66.png
dontbelieveeverythingyouthink_zps0e1e900

Madness is the first step to understanding...

Share this post


Link to post
Share on other sites

Wow, that works, and I'm impressed, I just can't understand it B):whistle: If I read the help file again and pondered on this for some time I believe I would. Dang you guys are smart!

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