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 

Send only works once

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Wade
Guest





PostPosted: Wed Jun 30, 2004 10:42 pm    Post subject: Send only works once Reply with quote

I'm trying to remap my right ALT key to send a Page Down, and the following code works, but it only works ONCE, and then it quits working!
Code:

#InstallKeybdHook
#UseHook
*RAlt::
Send, {PgDn Down}
Loop
{
   Sleep, 10
   GetKeyState, state, Ralt, P
   if state = U  ; The key has been released, so break out of the loop.
      break
}
Send, {PgDn Up}
return


I've tried with and without the keyboard hook, and still get the same results. If I use
Code:
RAlt::MsgBox, Test
, it works everytime. Anybody have any ideas????
Back to top
PenP



Joined: 15 May 2004
Posts: 10
Location: The Netherlands

PostPosted: Wed Jun 30, 2004 11:12 pm    Post subject: Reply with quote

I think this will work,

Code:
#InstallKeybdHook
#UseHook
*RAlt::
Send, {PgDn Down}
Loop
{
   Sleep, 10
   GetKeyState, state, Ralt, P
   if state = U  ; The key has been released, so break out of the loop.
      Send, {PgDn Up}
}
return


Grtz, PenP
Back to top
View user's profile Send private message
Guest






PostPosted: Thu Jul 01, 2004 12:52 am    Post subject: Reply with quote

Thanks, but that doesn't even work once..........

In my above example, it shows in the execution log that the key is being pressed, and that the keys are being sent, but nothing happens....
Back to top
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10467

PostPosted: Thu Jul 01, 2004 2:50 am    Post subject: Reply with quote

It appears that the OS (at least XP) has low-level handling for the Alt key. Therefore, even though your press of the ALT hotkey is suppressed (hidden from the system), the OS sees that it is down anyway and thus modifies the behavior of keys accordingly (which we don't want in this case).

As a workaround, this hotkey works on my system, even if you hold down the key to auto-repeat it:
*RAlt::Send {RAlt Up}{PgDn}

I think this fix can be safely built into the program for future versions, so thanks for reporting it.

Btw, you don't need to use the complex method of remapping (as in your example) unless the key needs to be kept held down for gaming purposes or some other atypical use.
Back to top
View user's profile Send private message Send e-mail
Wade
Guest





PostPosted: Thu Jul 01, 2004 3:42 am    Post subject: Reply with quote

Sweet!!! That works. Thanks for an awesome app!
Back to top
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help 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