AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Problem with pass-through/tilde and Send

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Bug Reports
View previous topic :: View next topic  
Author Message
schandl



Joined: 26 Apr 2005
Posts: 28
Location: Munich, Germany

PostPosted: Wed May 18, 2005 6:15 pm    Post subject: Problem with pass-through/tilde and Send Reply with quote

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
View user's profile Send private message
Laszlo



Joined: 14 Feb 2005
Posts: 4078
Location: Pittsburgh

PostPosted: Wed May 18, 2005 10:17 pm    Post subject: Reply with quote

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
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10480

PostPosted: Thu May 19, 2005 2:27 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
schandl



Joined: 26 Apr 2005
Posts: 28
Location: Munich, Germany

PostPosted: Thu May 19, 2005 6:56 pm    Post subject: Reply with quote

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
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10480

PostPosted: Fri May 20, 2005 12:51 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
toralf



Joined: 31 Jan 2005
Posts: 3841
Location: Bremen, Germany

PostPosted: Fri May 20, 2005 1:47 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
schandl



Joined: 26 Apr 2005
Posts: 28
Location: Munich, Germany

PostPosted: Fri May 20, 2005 7:28 pm    Post subject: Reply with quote

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. Razz

Bernd
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Bug Reports All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group