AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

My mouse to arrow key translator breaks!

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Gosugenji



Joined: 07 May 2008
Posts: 35
Location: In your Internets

PostPosted: Wed May 28, 2008 5:20 pm    Post subject: My mouse to arrow key translator breaks! Reply with quote

Im using an invisible box to control the keyboard once the user presses the hotkey. Go outside the box, the cursor is reset and the respective arrow is hit. certain points the loop breaks when it isnt supposed to?

Code:

+MButton::
MouseGetPos, xpos, ypos
xright:=xpos+2
xleft:=xpos-2
yup:=ypos-2
ydown:=ypos+2
loop=1
Loop
{
    MouseGetPos, xchg, ychg
    if not GetKeyState("shift","P")
        {
        loop=0
        return
        }
    if not loop = 0
    {
       if (xchg > xright)
       {
            sendinput {Right} 
       MouseMove, xpos, ypos

       }
       if (xchg < xleft)
       {
            sendinput {Left}
            MouseMove, xpos, ypos
   }
       if (ychg < yup)
       {
            sendinput {up} 
       MouseMove, xpos, ypos

       }
       if (ychg > ydown)
       {
            sendinput {down}
            MouseMove, xpos, ypos
   }
   }

}
Back to top
View user's profile Send private message
Gosugenji



Joined: 07 May 2008
Posts: 35
Location: In your Internets

PostPosted: Thu May 29, 2008 8:02 pm    Post subject: Reply with quote

bump?
Back to top
View user's profile Send private message
Guest






PostPosted: Fri May 30, 2008 8:30 pm    Post subject: Reply with quote

>_< Sad
Back to top
[VxE]



Joined: 07 Oct 2006
Posts: 1125

PostPosted: Sat May 31, 2008 3:01 am    Post subject: Reply with quote

maybe add #UseHook to the top?

edit: this will probably work OK:
Code:
$~*LShift Up::SetTimer, WatchTheMouse, off
$<+MButton::
MouseGetPos, ox, oy
SetTimer, WatchTheMouse, 5
WatchTheMouse:
MouseGetPos, nx, ny
If ( (dx := nx-ox)**2 > 8 )
   Send % (dx>0) ? "{Right}" : "{left}"
If ( (dy := ny-oy)**2 > 8 )
   Send % (dy>0 ? "{Down}" : "{up}")
If (dx**2 + dy**2 > 8)
   Click, %ox% %oy% Left 0
return

_________________
My Home Thread
More Common Answers: 1. It's in the FAQ 2. Ternary ( ? : ) guide 3. Post code with [code][/code] tags
Back to top
View user's profile Send private message
Guest21
Guest





PostPosted: Mon Jun 02, 2008 11:35 pm    Post subject: None Reply with quote

Cannot seem to get this working. Help?

I pasted it into notepad loaded it and cannot figure out how to initiate it.

Basically I'm trying to control a game with my mouse.
Back to top
engunneer



Joined: 30 Aug 2005
Posts: 6772
Location: Pacific Northwest, US

PostPosted: Tue Jun 03, 2008 12:11 am    Post subject: Reply with quote

do you have autohotkey installed? I think you should go through the new script tutorial.
_________________
Unless otherwise noted, all code is untested.
Common Answers: 1.(Loops, Viruses, etc.) 2. Search 3.RTFM
Back to top
View user's profile Send private message Visit poster's website
Gosugenji



Joined: 07 May 2008
Posts: 35
Location: In your Internets

PostPosted: Thu Jun 12, 2008 7:43 pm    Post subject: works like a charm! Reply with quote

Looks like the severely improved script works like magic! thanks for the great fix.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group