| View previous topic :: View next topic |
| Author |
Message |
jigawot
Joined: 01 Dec 2007 Posts: 7
|
Posted: Mon Dec 03, 2007 8:49 pm Post subject: Windows Key Remapping Bug? |
|
|
Consider the following:
| Code: | #v::
MsgBox Hello world
return
^d::
MsgBox Hello
return
#d::
MsgBox Hello there
return
|
As expected, LWin-v, LCtrl-d, and LWin-d all pop up message boxes with various greetings. However, when I add the following remappings...
| Code: | LCtrl::LWin
LWin::LAlt
LAlt::LCtrl |
...things break. The remapping appears to work just fine. I can press LCtrl and the Start menu pops open. However, when I try and use it for hotkeys, things don't work properly.
Pressing LCtrl-v displays the message box with "Hello world" in it, like expected. Pressing LAlt-d displays "Hello" as expected. So far, the remapping is working just fine. However, when I press LCtrl-d it does not show a message box with "Hello there", but instead it does a 'show desktop' command just like I had pressed LWin-d before doing the remap. Strangely, after showing my desktop, the control key is still down and I have to press LCtrl again to clear it.
Have I stumbled upon a bug or am I doing something wrong? |
|
| Back to top |
|
 |
engunneer
Joined: 30 Aug 2005 Posts: 6309 Location: Pacific Northwest, US
|
Posted: Mon Dec 03, 2007 10:18 pm Post subject: |
|
|
it did show the dialog when I hit LCtrl and d. It also popped up the start menu. _________________
Unless otherwise noted, all code is untested.
Common Answers: 1.(Loops, Viruses, etc.) 2. Search 3.RTFM |
|
| Back to top |
|
 |
jigawot
Joined: 01 Dec 2007 Posts: 7
|
Posted: Mon Dec 03, 2007 10:40 pm Post subject: |
|
|
My mistake. I forgot to include this bit:
If this is added at the beginning, it breaks. This code is inserted by the autohotkey template in the "New..." context menu.
Should SendMode change the behavior in this way? |
|
| Back to top |
|
 |
engunneer
Joined: 30 Aug 2005 Posts: 6309 Location: Pacific Northwest, US
|
Posted: Mon Dec 03, 2007 11:19 pm Post subject: |
|
|
same result as last time
| Code: |
SendMode Input
#v::
MsgBox Hello world
return
^d::
MsgBox Hello
return
#d::
MsgBox Hello there
return
LCtrl::LWin
LWin::LAlt
LAlt::LCtrl
|
_________________
Unless otherwise noted, all code is untested.
Common Answers: 1.(Loops, Viruses, etc.) 2. Search 3.RTFM |
|
| Back to top |
|
 |
jigawot
Joined: 01 Dec 2007 Posts: 7
|
Posted: Mon Dec 03, 2007 11:41 pm Post subject: |
|
|
| That is really weird. I tried this on two different XP boxes and had the same problem. Are you running Vista? Do you have any other autohotkey scripts running? I noticed it seemed to work if I had a particular script running at the same time. |
|
| Back to top |
|
 |
jmb275
Joined: 04 Dec 2007 Posts: 1
|
Posted: Tue Dec 04, 2007 12:13 am Post subject: |
|
|
I have tried this script as well and I have the same problem as jigawot.
In other words, without the remapping of keys everything works as expected. All three hotkeys map to little message boxes popping up. However, as soon as I include the key remapping LCtrl d no longer brings up a message box but rather executes a "show desktop".
Additionally, if I remove the line SendMode input LCtrl d does show the expected message box, but also brings up the start menu. This seems like an additional, but possibly related, bug.
Is engunneer running Vista, or could it be a specific keyboard. I have tried it with and without the specified drivers for my keyboard with the same results. |
|
| Back to top |
|
 |
engunneer
Joined: 30 Aug 2005 Posts: 6309 Location: Pacific Northwest, US
|
Posted: Tue Dec 04, 2007 1:21 am Post subject: |
|
|
I have XP_SP2 _________________
Unless otherwise noted, all code is untested.
Common Answers: 1.(Loops, Viruses, etc.) 2. Search 3.RTFM |
|
| Back to top |
|
 |
jigawot
Joined: 01 Dec 2007 Posts: 7
|
Posted: Tue Dec 04, 2007 1:28 am Post subject: |
|
|
| Popping up the start menu is an undesired behavior for a hotkey. Before the remap, the start menu does not open when you press Win-d. Any thoughts on this issue? |
|
| Back to top |
|
 |
engunneer
Joined: 30 Aug 2005 Posts: 6309 Location: Pacific Northwest, US
|
|
| Back to top |
|
 |
jigawot
Joined: 01 Dec 2007 Posts: 7
|
Posted: Tue Dec 04, 2007 3:09 am Post subject: |
|
|
Alright, how about this:
| Code: | SendMode Input
#d::
msgbox Hello there
return
LCtrl::LWin
|
I ran it and one would expect that pressing Ctrl-d or Win-d should do the exact same thing. However, when I look at the key history, I get:
| Code: | 5B 15B d 1.14 Left Windows
44 020 h d 0.19 D
44 020 s u 0.14 D test.ahk
5B 15B u 0.02 Left Windows |
for when I press Win-d (works fine). and...
| Code: | A2 01D h d 1.94 Ctrl C:\Documents and Settings\...
5B 15B i d 0.00 Left Windows
44 020 d 0.19 D
44 020 u 0.08 D
A2 01D h u 0.06 Ctrl
5B 15B i u 0.00 Left Windows |
when I press Ctrl-d. Here in the second example, the D is not suppressed, causing the 'Show Desktop' keyboard shortcut to activate and mess up my hotkey. Two very different behaviors for what should be the same hotkey.
If I remove the 'SendMode Input' part, it looks like this:
| Code: | A2 01D h d 1.30 Ctrl C:\Documents and Settings\...
5B 15B i d 0.00 Left Windows
44 020 h d 0.20 D
44 020 s u 0.09 D test.ahk
A2 01D h u 0.03 Ctrl
5B 15B i u 0.00 Left Windows |
And the D is now suppressed. The behavior here is close to what I want, but the start menu pops open.
I read a good portion of the other post, but I got a little lost in the nitty gritty parts. |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10464
|
Posted: Thu Feb 28, 2008 5:36 pm Post subject: |
|
|
Sorry for the late reply.
This undesirable behavior is probably caused in part by the fact that each remapping actually becomes a pair of hotkeys. So something like LCtrl::LWin actually defines LCtrl and LCtrl up as hook-hotkeys. Another factor is that it's the OS itself that handles your #d hotkey in this case (since by default, the keyboard hook is only used when a hotkey can't be implemented via the OS). Normally the OS will prevent the start menu from appearing when you press an OS-implemented hotkey. But AutoHotkey's low-level handling of the LCtrl key (due to your remapping) probably interferes with this.
This is a tricky area and I'm not sure what can or should be done about it. You've probably aware that there are workarounds, such as using registry remapping instead of the remapping LCtrl::LWin, or blocking the start menu explicitly in your script such as via Send {LCtrl}. |
|
| Back to top |
|
 |
jigawot
Joined: 01 Dec 2007 Posts: 7
|
Posted: Thu Feb 28, 2008 6:21 pm Post subject: |
|
|
Thank you for your post. I did some experimenting with the registry remapping and I think that is the route I will probably take. Originally, I wanted to be able to toggle these remappings with autohotkey, but with the strangeness this introduces, I think the registry hack is the way to go.
I didn't ever try using Send {LCtrl} to block the start menu, so I'll give that a try.
Thanks again. |
|
| Back to top |
|
 |
|