 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
deguix
Joined: 26 Aug 2004 Posts: 72 Location: Everett - MA, USA
|
Posted: Sun Oct 24, 2004 2:46 am Post subject: Using Keyboard Numpad as a Mouse |
|
|
This has 700+ lines of codes script which makes your numpad into a mouse. This is like the MouseKeys from Windows, however this has some advanced features like:
- Keys for mouse wheel and left, middle, right, X1 and X2 mouse buttons. (X1 and X2 only supportable on Win2000+.)
- Very smooth movements.
- Much faster speed and acceleration.
- Customizable normal, acceleration and maximum speeds for both mouse movements and wheel.
- Adjustable rotation. With this you can even make this mouse to be inversed like on some flight simulators.
- Uses ScrollLock for activation. This enables you to use the normal NumPad when you don't want the script activated.
- Button/wheel keys are usable even with mouse devices that don't have the wheel or middle, X1 or X2 buttons. (This depends if your mouse hardware support the wheel or those buttons.)
You can find this script on the AutoHotkey Script Showcase online.
Complaints, suggestions, questions... are all accepted. Of course, I don't accept to receive new mouse devices, because you know what this script is about...  _________________ Working now on:
NSIS Wiki (NSIS)
Last edited by deguix on Fri Nov 05, 2004 11:29 pm; edited 15 times in total |
|
| Back to top |
|
 |
Atomhrt
Joined: 02 Sep 2004 Posts: 128 Location: Sunnyvale
|
Posted: Sun Oct 24, 2004 3:18 am Post subject: |
|
|
Pretty cool! I have thrown my mouse into the trash, and I will use the numpad for now on!
I do like the wheel scroll keys *very much*.  _________________ I am he of whom he speaks! |
|
| Back to top |
|
 |
Gre
Joined: 12 Oct 2004 Posts: 77 Location: São Paulo ,Brazil
|
Posted: Sun Oct 24, 2004 6:41 am Post subject: |
|
|
| Quote: | | I do like the wheel scroll keys *very much*. |
Me too!
Hey,deguix.Are you the same person who posted this?
| Quote: | | How can I get a number that I want from a REG_SZ string and use it for math operations? I'm using this below: |
 |
|
| Back to top |
|
 |
dijiyd
Joined: 01 Apr 2004 Posts: 90 Location: Philippines
|
Posted: Sun Oct 24, 2004 8:30 am Post subject: |
|
|
That is one loooong script. But heckuvalot of help for a few graphics I'm doing. Very nice.
Um.. though, it doesn't seem to support ctrl clicks or alt clicks. Well, nothing a little tweaking can't fix. |
|
| Back to top |
|
 |
deguix
Joined: 26 Aug 2004 Posts: 72 Location: Everett - MA, USA
|
Posted: Sun Oct 24, 2004 1:28 pm Post subject: |
|
|
| Quote: | | Hey,deguix.Are you the same person who posted this? | I just failed on that... but I got over it afterwards and ended this script which I developed in one week. And I'm still a n00b .
| Quote: | | Um.. though, it doesn't seem to support ctrl clicks or alt clicks. Well, nothing a little tweaking can't fix. | What keys do you suggest instead? _________________ Working now on:
NSIS Wiki (NSIS) |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10467
|
Posted: Sun Oct 24, 2004 2:23 pm Post subject: |
|
|
Great script! And the nice compact help section at the top is a great aid.
| Quote: | And I'm still a n00b . | Not anymore. This script shows you learned the intricacies very well, such as GetKeyState, dynamic hotkeys, and SetTimer to create an maintain multiple threads.
| Quote: | | Quote: | | Um.. though, it doesn't seem to support ctrl clicks or alt clicks. Well, nothing a little tweaking can't fix. | What keys do you suggest instead? | I've spotted some things such as the above that might make this amazing script even better. Here are the details (of course these are only suggestions):
As a first step to supporting ctrl-click and shift-click, insert asterisks (wildcards) in front of the following: | Code: | Hotkey, *NumPad0, ButtonLeftClick
Hotkey, *NumPad5, ButtonMiddleClick
Hotkey, *NumPadDot, ButtonRightClick
Hotkey, *NumPadDiv, ButtonX1Click
Hotkey, *NumPadMult, ButtonX2Click
Hotkey, *NumpadSub, ButtonWheelUp
Hotkey, *NumpadAdd, ButtonWheelDown |
This next section can be changed to use the above asterisks, as follows: | Code: | KeysActivation:
GetKeyState, NumLockState, NumLock, T
If NumLockState = D
{
Hotkey, *NumpadSub, on
Hotkey, *NumpadAdd, on
Hotkey, *NumpadDiv, on
Hotkey, *NumpadMult, on
}
else
{
Hotkey, *NumpadSub, off
Hotkey, *NumpadAdd, off
Hotkey, *NumpadDiv, off
Hotkey, *NumpadMult, off
}
return |
Also, replace in two places:
Button = %A_ThisHotkey%
with
StringReplace, Button, A_ThisHotkey, *
Finally, to support the above, all GetKeyStates that don't use T (toggle) would have to use P (physical), otherwise if any of them are ever hook hotkeys (such as the wildcard hotkeys), GetKeyState won't report that they're down even though the user is physically holding them down.
To support the ability to shift-left-click, it is necessary to handle the built-in quirks of Numpad, namely that when the user is holding down the shift key, Numlock is effectively off (even though the light is on): | Code: | Hotkey, NumpadIns, ButtonShiftLeftClick ; This must be done to support shift-left-click.
...
ButtonShiftLeftClick:
Button2 = NumPadIns
ButtonClick = Left
Goto ButtonClickStart
...
ButtonClickStart:
If Button2 = NumPadIns
Send, {shift down}
...
SetTimer, ButtonClickEnd, off
MouseClick, %ButtonClick%,,, 1, 0, U
If Button2 = NumPadIns
Send, {shift up}
return |
To better support control-clicking, it might be worth giving up the following hotkeys in favor of allowing the mouse to move while the user is holding down the control key: | Code: | Hotkey, ^Numpad8, ButtonSpeedUp
Hotkey, ^Numpad2, ButtonSpeedDown
Hotkey, ^Numpad7, ButtonAccelerationSpeedUp
Hotkey, ^Numpad1, ButtonAccelerationSpeedDown
Hotkey, ^Numpad9, ButtonMaxSpeedUp
Hotkey, ^Numpad3, ButtonMaxSpeedDown |
To better support shift-clicking, consider making NumpadUp/Down/Home/etc. into movement hotkeys. This would allow the user to move the mouse while holding down the shift key. The reason for this is that shift disables Numlock (even though the light may be on).
I noticed you were setting a variable equal to zero. On the off chance that you didn't know, you can make a variable empty this way:
var =
... and check if it's empty this way:
if var =
Also, I think the following line can be removed in two places if you change the "90" that follows it to "90.0":
MouseCurrentSpeedToSide += 0.0
Anyway, I think it's wonderful. I will e-mail you the changed version in case you want it.
With your permission, I would like to post this in the script showcase. |
|
| Back to top |
|
 |
Atomhrt
Joined: 02 Sep 2004 Posts: 128 Location: Sunnyvale
|
Posted: Sun Oct 24, 2004 3:04 pm Post subject: |
|
|
| Chris wrote: |
Anyway, I think it's wonderful. I will e-mail you the changed version in case you want it.
|
I'd like a copy. Could you email it to me too? _________________ I am he of whom he speaks! |
|
| Back to top |
|
 |
deguix
Joined: 26 Aug 2004 Posts: 72 Location: Everett - MA, USA
|
Posted: Sun Oct 24, 2004 5:50 pm Post subject: |
|
|
| Quote: | | With your permission, I would like to post this in the script showcase. |
OK, you can use your revised version. But is not better to keep the mouse speed adjustment keys rather than the wheel's? Or maybe give them other hotkeys rather than using Ctrl or Alt? The only key not used on the NumPad is the Enter key, so maybe we could be creative and give it an action...
Updated script code on the first post with Chris revised version. _________________ Working now on:
NSIS Wiki (NSIS) |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10467
|
Posted: Sun Oct 24, 2004 7:20 pm Post subject: |
|
|
I'm not sure what's best; I didn't put enough time into it, nor did I test the revised version very well (I was more thinking out loud than trying to force changes to it ). What might be nice is have the NumpadEnter key popup a menu of choices, or perhaps have it be a prefix key (i.e. hold it down and another key to make an adjustment).
Maybe others who use it will suggest what they think is the best default hotkey configuration. |
|
| Back to top |
|
 |
deguix
Joined: 26 Aug 2004 Posts: 72 Location: Everett - MA, USA
|
Posted: Sun Oct 24, 2004 9:17 pm Post subject: |
|
|
Two bugs I found here:
- When holding NumPad5, NumPadDiv or NumPadMult, it clicks several times instead of holding the click. (a problem with MouseClick?)
- Hold a moviment key from NumPad, hold NumLock key, release the movement key and release NumLock. You'll see that that movement continues even when not holding that movement key. This is the same for Shift. _________________ Working now on:
NSIS Wiki (NSIS) |
|
| Back to top |
|
 |
dijiyd
Joined: 01 Apr 2004 Posts: 90 Location: Philippines
|
Posted: Sun Oct 24, 2004 11:24 pm Post subject: |
|
|
| Well, I have a suggestion, why not put the hotkey to enable the mouse_numpad to scroll lock, (not much use for that eh?) then, if numlock is on, you can change the mouse speeds (or vice versa)? |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10467
|
Posted: Mon Oct 25, 2004 1:21 am Post subject: |
|
|
| deguix wrote: | Two bugs I found here:
- When holding NumPad5, NumPadDiv or NumPadMult, it clicks several times instead of holding the click. (a problem with MouseClick?) | This also happens with left-click and right-click. It is caused by the key-repeat feature. One way to fix it (there may be better ways) is this revised section: | Code: | ButtonShiftLeftClick:
GetKeyState, already_down_state, LButton
If already_down_state = D
return
Button2 = NumPadIns
ButtonClick = Left
Goto ButtonClickStart
ButtonLeftClick:
GetKeyState, already_down_state, LButton
If already_down_state = D
return
Button2 = NumPad0
ButtonClick = Left
Goto ButtonClickStart
ButtonMiddleClick:
GetKeyState, already_down_state, MButton
If already_down_state = D
return
Button2 = NumPad5
ButtonClick = Middle
Goto ButtonClickStart
ButtonRightClick:
GetKeyState, already_down_state, RButton
If already_down_state = D
return
Button2 = NumPadDot
ButtonClick = Right
Goto ButtonClickStart
ButtonX1Click:
GetKeyState, already_down_state, XButton1
If already_down_state = D
return
Button2 = NumPadDiv
ButtonClick = X1
Goto ButtonClickStart
ButtonX2Click:
GetKeyState, already_down_state, XButton2
If already_down_state = D
return
Button2 = NumPadMult
ButtonClick = X2
Goto ButtonClickStart
ButtonClickStart:
If Button2 = NumPadIns
Send, {shift down}
MouseClick, %ButtonClick%,,, 1, 0, D
SetTimer, ButtonClickEnd, 10
return |
| Quote: | | Hold a moviment key from NumPad, hold NumLock key, release the movement key and release NumLock. You'll see that that movement continues even when not holding that movement key. This is the same for Shift. | I suspect that is "normal" due to the fact that the order in which you press and release the keys can cause a single keystroke's key-down to have a different virtual key code than it's key-up event. AutoHotkey is not designed to deal with keys that change their nature halfway through the keystroke, so the results in a key-state script such as this one may be unpredictable. I'll try to improve this for a future version.
| dijiyd wrote: | | Well, I have a suggestion, why not put the hotkey to enable the mouse_numpad to scroll lock, (not much use for that eh?) then, if numlock is on, you can change the mouse speeds (or vice versa)? | Sounds like a good possibility. |
|
| Back to top |
|
 |
deguix
Joined: 26 Aug 2004 Posts: 72 Location: Everett - MA, USA
|
Posted: Sat Oct 30, 2004 12:30 am Post subject: |
|
|
| Quote: | | Well, I have a suggestion, why not put the hotkey to enable the mouse_numpad to scroll lock, (not much use for that eh?) then, if numlock is on, you can change the mouse speeds (or vice versa)? | Ok, at least won't make me hold a key that affects the normal mouse to change to speed adjustments...
Updated code on the first post with Chris' code, and the implementation of the suggestion above. _________________ Working now on:
NSIS Wiki (NSIS) |
|
| Back to top |
|
 |
dijiyd
Joined: 01 Apr 2004 Posts: 90 Location: Philippines
|
Posted: Sat Oct 30, 2004 11:21 am Post subject: |
|
|
Hmm.. I tried it, and it looks like there are a few bugs. I'll be tweaking this myself for the bugs, maybe I'll post it later.. (it looks like I'm the only one who needs those modifier clicks ) But here are the things I found:
1. Single clicks left click. This looks like it comes from "ButtonClickStart"
2. Mouse Wheel functions when numlock is on and does not when it is off.
3. Shift clicks don't work because apparently, shift+insert is some kind of universal shortcut for paste. (I dunno. Try it.)
Read ya later.. |
|
| Back to top |
|
 |
deguix
Joined: 26 Aug 2004 Posts: 72 Location: Everett - MA, USA
|
Posted: Sat Oct 30, 2004 5:33 pm Post subject: |
|
|
I fixed them all. Thanks for that! Updated code on the first post. Now, it has 700+ lines of code.  _________________ Working now on:
NSIS Wiki (NSIS) |
|
| 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
|