| View previous topic :: View next topic |
| Author |
Message |
Gosugenji
Joined: 07 May 2008 Posts: 35 Location: In your Internets
|
Posted: Wed May 28, 2008 5:20 pm Post subject: My mouse to arrow key translator breaks! |
|
|
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 |
|
 |
Gosugenji
Joined: 07 May 2008 Posts: 35 Location: In your Internets
|
Posted: Thu May 29, 2008 8:02 pm Post subject: |
|
|
| bump? |
|
| Back to top |
|
 |
Guest
|
Posted: Fri May 30, 2008 8:30 pm Post subject: |
|
|
>_<  |
|
| Back to top |
|
 |
[VxE]
Joined: 07 Oct 2006 Posts: 1125
|
Posted: Sat May 31, 2008 3:01 am Post subject: |
|
|
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 |
|
 |
Guest21 Guest
|
Posted: Mon Jun 02, 2008 11:35 pm Post subject: None |
|
|
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
|
Posted: Tue Jun 03, 2008 12:11 am Post subject: |
|
|
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 |
|
 |
Gosugenji
Joined: 07 May 2008 Posts: 35 Location: In your Internets
|
Posted: Thu Jun 12, 2008 7:43 pm Post subject: works like a charm! |
|
|
| Looks like the severely improved script works like magic! thanks for the great fix. |
|
| Back to top |
|
 |
|