| View previous topic :: View next topic |
| Author |
Message |
schandl
Joined: 26 Apr 2005 Posts: 28 Location: Munich, Germany
|
Posted: Wed May 18, 2005 6:15 pm Post subject: Problem with pass-through/tilde and Send |
|
|
I posted the following problem in the support section and some possible solutions were found. But I still wonder if this is the intended behaviour. Here is some example code: | Code: | #y::
Send, #x
Return
~#x::
MsgBox, Win+x was used
Return |
Win+x shows a window, Win+y does nothing. If I leave out the tilde in front of #x, Win+y works as expected. I just do not understand why. Is this a bug or a feature? If it is a feature, how can I change the definition of Win+y to get it to work?
Bernd |
|
| Back to top |
|
 |
Laszlo
Joined: 14 Feb 2005 Posts: 4078 Location: Pittsburgh
|
Posted: Wed May 18, 2005 10:17 pm Post subject: |
|
|
| In my XP laptop Win-x is not defined by the OS, therefore it behaves as x alone. With your script, Win-y does not disable it, so I get an x, but no MsgBox. It looks strange, I agree. |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10480
|
Posted: Thu May 19, 2005 2:27 pm Post subject: |
|
|
The tilde prefix makes the hotkey use the keyboard hook. Since the hook is designed to ignore simulated keystrokes for the purposes of triggering hotkeys, the tilde prevents Send #x from triggering the Win+x hotkey.
The hook ignores simulated keystrokes to prevent infinite loops wherein a hotkey triggers itself endlessly. Although this behavior is by design, I'll try to clarify it in the help file, perhaps under ListHotkeys or #UseHook.
To work around this, you can simply Gosub a hotkey rather than triggering it with a keystroke:
#y::
Gosub ~#x
return |
|
| Back to top |
|
 |
schandl
Joined: 26 Apr 2005 Posts: 28 Location: Munich, Germany
|
Posted: Thu May 19, 2005 6:56 pm Post subject: |
|
|
Thanks for the explanation, Chris. Your solution works, but only if Win+x is defined as in the exmaple. It does not work if it was defined using the Hotkey command. Oh well, I think I have to look into a work-around for the script I am trying to extend.
Thanks anyway
Bernd |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10480
|
Posted: Fri May 20, 2005 12:51 pm Post subject: |
|
|
| When using the hotkey command to define #x, have the #y hotkey do a Gosub to the label you assigned to #x. |
|
| Back to top |
|
 |
toralf
Joined: 31 Jan 2005 Posts: 3841 Location: Bremen, Germany
|
Posted: Fri May 20, 2005 1:47 pm Post subject: |
|
|
Hi, Chris
I think the script schandl wants to extend uses the "A_Hotkey" variable. So he wants #x to be executed, so the rest of the script works without changes. Right?
But you could extend the routine. Set a status variable when #y is pressen, and in the routine that is called via #x you insert a if statement that tests that status variable and uses it to use someting else then "A_Hotkey". _________________ Ciao
toralf  |
|
| Back to top |
|
 |
schandl
Joined: 26 Apr 2005 Posts: 28 Location: Munich, Germany
|
Posted: Fri May 20, 2005 7:28 pm Post subject: |
|
|
Toralf, you are right. But by now I decided to adapt the whole script to my needs instead of trying to extend using some weird hack. This will also help to learn a little more about AutoHotkey.
Bernd |
|
| Back to top |
|
 |
|