 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
adamisageek
Joined: 05 Mar 2007 Posts: 20 Location: Erie, PA
|
Posted: Thu Mar 27, 2008 5:39 pm Post subject: quick and dirty way to control mouse with Numpad (10 lines) |
|
|
I just wanted the ability to move the mouse without using the mouse itself sometimes, so I didn't need a full blown mouse alternative script. I don't even have this script running on its own, this code is inside my main running script for work.
The Numpad will only control the mouse when Numlock is off.
Here's my super simple numpad mousemovent script.
this is the entire code:
| Code: | NumpadEnd::MouseMove, -10, 10, 0, R
NumpadDown::MouseMove, 0, 10, 0, R
NumpadPgDn::MouseMove, 10, 10, 0, R
NumpadLeft::MouseMove, -10, 0, 0, R
NumpadRight::MouseMove, 10, 0, 0, R
NumpadHome::MouseMove, -10, -10, 0, R
NumpadUp::MouseMove, 0, -10, 0, R
NumpadPgUp::MouseMove, 10, -10, 0, R
NumpadClear::MouseClick
NumpadIns::MouseClick, Right |
There's no need for enabling/disabling hotkeys for this to work, because all the hotkeys merely reference the Numpad's editing keys, not the number keys, so they're only activated when Numlock is off. So if I need to use the mouse via the Numpad, I turn NumLock off and use the number keys to move the mouse and the [5] and [0] keys to left and right click. When I'm done, I turn NumLock back on and the Numpad works fine.
Note that I use the NumpadClear (Numpad [5] key) to left click, and NumpadIns (Numpad [0] key) to right click. You may want to switch this depending on whatever's more comfortable to you.
Also, you may want to change the movement speed; do so by changing all the "10" values in the script to whatever you'd like. Obviously the less the value is, the slower the mouse will move and vice versa the higher the value.
Edit however you like and redistribute, enjoy.  _________________ My AutoHotKey.com username has changed to GeekyAdam |
|
| Back to top |
|
 |
imapow
Joined: 13 Mar 2008 Posts: 162 Location: Trøndelag, Norway
|
Posted: Thu Mar 27, 2008 6:59 pm Post subject: |
|
|
to easy... _________________ -._.-¨¯¨-._.-IM@PΩW-._.-¨¯¨-._.- |
|
| Back to top |
|
 |
adamisageek
Joined: 05 Mar 2007 Posts: 20 Location: Erie, PA
|
Posted: Thu Mar 27, 2008 7:01 pm Post subject: |
|
|
haha, sorry  _________________ My AutoHotKey.com username has changed to GeekyAdam |
|
| Back to top |
|
 |
adam_ Guest
|
Posted: Thu Mar 27, 2008 7:17 pm Post subject: |
|
|
thanks for posting anyway. we've got different levels of users here. one man's trash is another's treasure.
don't let comments such as those keep you from posting scripts.  |
|
| Back to top |
|
 |
adamisageek
Joined: 05 Mar 2007 Posts: 20 Location: Erie, PA
|
Posted: Thu Mar 27, 2008 7:22 pm Post subject: |
|
|
oh i won't, i thought he was being funny.
and if he was trying to insult my small amount of code, that's even funnier!  _________________ My AutoHotKey.com username has changed to GeekyAdam |
|
| Back to top |
|
 |
imapow
Joined: 13 Mar 2008 Posts: 162 Location: Trøndelag, Norway
|
Posted: Thu Mar 27, 2008 7:34 pm Post subject: |
|
|
| adamisageek wrote: |
haha, sorry  |
not ment as an insolt.
good comprimation.
if i had wrote this script it had been tre times as big
| Code: |
numpadend::
mousemove, -10, 10, 0, R
return
|
_________________ -._.-¨¯¨-._.-IM@PΩW-._.-¨¯¨-._.- |
|
| Back to top |
|
 |
adamisageek
Joined: 05 Mar 2007 Posts: 20 Location: Erie, PA
|
Posted: Thu Mar 27, 2008 9:35 pm Post subject: |
|
|
| imapow wrote: | | not ment as an insolt. |
its cool i didnt think so
| imapow wrote: | if i had wrote this script it had been tre times as big
| Code: |
numpadend::
mousemove, -10, 10, 0, R
return
|
|
yeah i actually had it a lot longer for awhile:
| Code: |
numpadend::
{
if ((GetKeyState, state, NumLock, T) == U)
Mousemove -10, 10, 0, R
return
}
|
until I realized that the NumpadEnd key wasn't even accessible unless the NumLock was off. then i just put each mousmove or mouseclick event inline with the hotkey.  _________________ My AutoHotKey.com username has changed to GeekyAdam |
|
| Back to top |
|
 |
NLI-Conquer Guest
|
Posted: Thu Mar 27, 2008 9:39 pm Post subject: |
|
|
| Nice and simple, thanks for sharing. |
|
| Back to top |
|
 |
[VxE]
Joined: 07 Oct 2006 Posts: 1125
|
Posted: Thu Mar 27, 2008 10:29 pm Post subject: |
|
|
| Code: | Loop 8
Hotkey, % ("*NumPad" . A_Index + (A_Index > 4)), HandleNPtM, on
HandleNPtM:
Click % (19*(Mod(SubStr(A_ThisHotkey, 0, 1)-1, 3)-1) " " 19*(1-(SubStr(A_ThisHotkey, 0, 1)-1)//3) " Left 0 Relative")
*Numpad0::RButton
*Numpad5::LButton |
sry, couldn't resist... 6 lines (though it needs numlock ON)
(not my preferred way to move the mouse with keys, mind) _________________ 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 |
|
 |
adamisageek
Joined: 05 Mar 2007 Posts: 20 Location: Erie, PA
|
Posted: Thu Mar 27, 2008 10:36 pm Post subject: |
|
|
nice!
too bad you can't use the Numpad without moving the mouse, but its still a nice feat!
Grats  _________________ My AutoHotKey.com username has changed to GeekyAdam |
|
| Back to top |
|
 |
imapow
Joined: 13 Mar 2008 Posts: 162 Location: Trøndelag, Norway
|
Posted: Thu Mar 27, 2008 10:59 pm Post subject: |
|
|
adding speed ajustments (two lines)
ajustments to orginal script:
| Code: |
NumpadEnd::MouseMove, -%speed%, %speed%, 0, R
NumpadDown::MouseMove, 0, %speed%, 0, R
NumpadPgDn::MouseMove, %speed%, %speed%, 0, R
NumpadLeft::MouseMove, -%speed%, 0, 0, R
NumpadRight::MouseMove, %speed%, 0, 0, R
NumpadHome::MouseMove, -%speed%, -%speed%, 0, R
NumpadUp::MouseMove, 0, -%speed%, 0, R
NumpadPgUp::MouseMove, %speed%, -%speed%, 0, R
NumpadClear::MouseClick
NumpadIns::MouseClick, Right
|
add this two hotkeys to script:
| Code: |
numpadadd::speed+=1
numpadsub::speed-=1
|
_________________ -._.-¨¯¨-._.-IM@PΩW-._.-¨¯¨-._.- |
|
| Back to top |
|
 |
adamisageek
Joined: 05 Mar 2007 Posts: 20 Location: Erie, PA
|
Posted: Fri Mar 28, 2008 12:31 am Post subject: |
|
|
| imapow wrote: | add this two hotkeys to script:
| Code: | numpadadd::speed+=1
numpadsub::speed-=1 |
|
that works, but they'll also be triggered even if NumLock is on.
this might work:
| Code: | NumpadSub::speed-=!(GetKeyState("Numlock", "T"))
NumpadAdd::speed+=!(GetKeyState("Numlock", "T")) |
but you'd lose the normal ability of the NumpadAdd and NumpadSub keys (outputting "+" and "-"), so you could do it like this:
| Code: | ~NumpadSub::speed-=!(GetKeyState("Numlock", "T"))
~NumpadAdd::speed+=!(GetKeyState("Numlock", "T")) |
but then the normal NumpadAdd and NumpadSub keys would trigger every time you adjusted the Numpad mouse speed.
I think the best solution to implement mouse speed would be to add just a little more:
| Code: | numpadmousespeed := 10
NumpadEnd::MouseMove, -%numpadmousespeed%, %numpadmousespeed%, 0, R
NumpadDown::MouseMove, 0, %numpadmousespeed%, 0, R
NumpadPgDn::MouseMove, %numpadmousespeed%, %numpadmousespeed%, 0, R
NumpadLeft::MouseMove, -%numpadmousespeed%, 0, 0, R
NumpadRight::MouseMove, %numpadmousespeed%, 0, 0, R
NumpadHome::MouseMove, -%numpadmousespeed%, -%numpadmousespeed%, 0, R
NumpadUp::MouseMove, 0, -%numpadmousespeed%, 0, R
NumpadPgUp::MouseMove, %numpadmousespeed%, -%numpadmousespeed%, 0, R
NumpadClear::MouseClick
NumpadIns::MouseClick, Right
NumpadDel & NumpadSub::numpadmousespeed -= ((numpadmousespeed>5)*5*(!GetKeyState("Numlock", "T")))
NumpadDel & NumpadAdd::numpadmousespeed += ((numpadmousespeed<100)*5*(!GetKeyState("Numlock", "T"))) |
This method requires you to hold the NumpadDel key (Numpad Period, next to Numpad0) while you press NumpadAdd or NumpadSub to adjust mouse speed. this way, you can still use NumpadAdd and NumpadSub normally with the Numlock on or off. Also you'll notice I'm using increments of 5 for the mouse speed, just so it can be adjusted faster. Also I added min and max speeds of 5 and 100.
Looks like I only have one more line than you do; the declaration of the default value in the numpadmousespeed variable; something that is required but you seem to have left out. so I really didn't have any more lines than yours. :p
so i guess for the simplest way to control the mouse via the Numpad, you need only 6 lines of code (props to [VxE]), for an easier to read/manipulate way, you need only 10 lines, and for a simple way that allows mouse speed adjustment, you need 13.
what do you guys think? _________________ My AutoHotKey.com username has changed to GeekyAdam |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|