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 

losing shift key presses with suspend

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





PostPosted: Sat Jun 12, 2004 1:53 am    Post subject: losing shift key presses with suspend Reply with quote

;when suspend mode toggles (on or off doesn't matter) using either toggling method (foot pedal or alt key) and i hold the shift key down, it cancels the shift key press
;if i wait a second before i release shift after suspend toggles it will still perform it's function
;this gets pretty annoying
;is there a way to prevent it other than not touching the pedal while i tab to various fields?

SetTimer, WatchPedals, 25
alt_tally = 1


WatchPedals:
GetKeyState, joyy, 1JoyY
if joyy <= 3
{
suspend off
suspend_mode = off
}
else
{
suspend on
suspend_mode = on
}
return


alt::
suspend permit
if alt_tally > 0
{
SetTimer, WatchPedals, off
suspend off
suspend_mode = off
}
else
{
SetTimer, WatchPedals, on
suspend on
suspend_mode = on
}
alt_tally *= -1
return

shift::
suspend permit
send {tab}
return

;you can comment out either method and try one at a time if you don't have footpedals (or a joystick) and see for yourself
Back to top
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10463

PostPosted: Sat Jun 12, 2004 2:48 am    Post subject: Reply with quote

When Suspend mode is turned on or off, the program reinitializes all hook hotkeys. Since shift is such a key, it's down-state is lost when the initialization occurs, thus the hotkey does not fire on key-up.

This might be easily fixed by specifying the left or right shift key rather than the neutral key, which will cause that shift key to fire on key-down rather than key-up. This is because AHK assumes you would never want to lose the functionality of both your shift keys when you define "shift" as a hotkey. However, it does allow you to entirely "sacrifice" one or both of them if you explicitly define both. So try this:

; If you only need one shift key to be a hotkey, remove the other one:
LShift::
RShift::
suspend permit
send {tab}
return

If the above does not solve it -- perhaps because you don't want to sacrifice either shift key -- see if there's any way you can redesign the script so that it doesn't use the Suspend command.
Back to top
View user's profile Send private message Send e-mail
WhiteCloud
Guest





PostPosted: Sat Jun 12, 2004 3:16 am    Post subject: Reply with quote

your answers to questions are incredibly effective

yeah i know you wrote ahk but this is like 1st class consulting Smile

Thanks!!!!!!!!!
Back to top
WhiteCloud



Joined: 19 Jun 2004
Posts: 68

PostPosted: Sat Jul 31, 2004 12:44 am    Post subject: Reply with quote

I've changed the code so that it uses the Hotkey command multiple times instead of the Suspend command. But the problem still exists.

I still need my shift key to Send {TAB} only when the key is released. (I still use shift for it's regular purpose while typing) So I don't can't specify left or right shift to try to solve the problem. Is there another fix?
_________________
AHK = Hella fun
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10463

PostPosted: Sat Jul 31, 2004 12:55 am    Post subject: Reply with quote

Quote:
I still need my shift key to Send {TAB} only when the key is released.

Although there is not yet any built-in support for "key-up" hotkeys, you can do it using the following example:

; Use SHIFT as a prefix key with at least one other hotkey.
; The hotkey in this case does nothing.
shift & capslock::return

; Now use the shift key and it will be a "key up" hotkey:
Shift::
suspend permit
send {tab}
return
Back to top
View user's profile Send private message Send e-mail
WhiteCloud



Joined: 19 Jun 2004
Posts: 68

PostPosted: Sun Aug 01, 2004 4:51 pm    Post subject: Reply with quote

I mapped shift with Lshift and Rshift instead. And used the prefix key method described. It does work as a "key-up" hotkey, yet it is still losing tabs.

It happens specifically when I press shift down first, then wait any amount of time, and then use the ALT key or footpedal to reassign the other keys (using the Hotkey command). At that point in time, I can either release shift or release ALT (or the footpedal) first, it won't make a difference -- it'll still ignore my releasing of the shift key.

Is there any more info you need? The ALT key and footpedal simply run 10 to 20 lines of Hotkey commands and thats all.
_________________
AHK = Hella fun
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10463

PostPosted: Sun Aug 01, 2004 5:01 pm    Post subject: Reply with quote

If you use the Hotkey command in such a way that the keyboard hook will be added or removed (which is done automatically depending on the needs of your active hotkey set), the hook's key state will be reset. I suspect that's why the shift key event is lost. If so, you might be able to work around it by adding the line #InstallKeybdHook at the top of the script. This will tell it to keep the hook in place all the time.
Back to top
View user's profile Send private message Send e-mail
WhiteCloud



Joined: 19 Jun 2004
Posts: 68

PostPosted: Mon Aug 02, 2004 12:35 am    Post subject: Reply with quote

I put in #InstallKeybdHook but it still didn't have any effect.

Then I put in asterisks before the key names and it seems to be working now. Smile
I left in your other suggestions for now until i have more time to test it without those. I don't care if it's extra stuff, just as long as it works reliably and i don't have to keep looking at the screen to see if the computer received my tab press. I use this script at work where i type all day while not looking at the screen so this is making me quite happy thinking about it now that it is working reliably. Though I'm still not sure why it works now.

Code:
*lshift::
*rshift::
send {tab}
return

_________________
AHK = Hella fun
Back to top
View user's profile Send private message
WhiteCloud



Joined: 19 Jun 2004
Posts: 68

PostPosted: Mon Aug 02, 2004 12:36 am    Post subject: Reply with quote

btw without your replies i probably would have put this problem off for another couple months. Even though they didn't get the job done they still helped me stay active on it. Thanks Chris.
_________________
AHK = Hella fun
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10463

PostPosted: Mon Aug 02, 2004 6:14 pm    Post subject: Reply with quote

I think I spotted a problem that might be causing the above issue. It's hopefully fixed in the Installer, which has been updated at http://www.autohotkey.com/download/

Changes:
Fixed command Suspend, which sometimes permanently disabled all hotstrings. [thanks Loneaussie]

Fixed commands Suspend and Hotkey, which sometimes reset the state of the keys to "all up" even if the user was holding down a hotkey. [thanks WhiteCloud]
Back to top
View user's profile Send private message Send e-mail
WhiteCloud



Joined: 19 Jun 2004
Posts: 68

PostPosted: Mon Aug 02, 2004 11:06 pm    Post subject: Reply with quote

Cool!

Yeah I'll haveto test this out tonight cuz the asterisks might have helped, but didn't completely fix it.
_________________
AHK = Hella fun
Back to top
View user's profile Send private message
WhiteCloud



Joined: 19 Jun 2004
Posts: 68

PostPosted: Wed Aug 04, 2004 12:48 am    Post subject: Reply with quote

i tested the new version but it had no effect for my script
_________________
AHK = Hella fun
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10463

PostPosted: Wed Aug 04, 2004 3:11 am    Post subject: Reply with quote

If you can catch it misbehaving, you can send the contents of the main window's View > Key History to support@autohotkey.com and I'll try to analyze it.
Back to top
View user's profile Send private message Send e-mail
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10463

PostPosted: Sun Aug 15, 2004 12:46 pm    Post subject: Reply with quote

Quote:
It happens specifically when I press shift down first, then wait any amount of time, and then use the ALT key or footpedal to reassign the other keys (using the Hotkey command). At that point in time, I can either release shift or release ALT (or the footpedal) first, it won't make a difference -- it'll still ignore my releasing of the shift key.

I tried out the script and it doesn't seem to happen on my system when using the Joystick method. I hold down the shift key for a few seconds, move the y-axis to toggle the suspend mode, and then release the shift key. The tab still appears.

However, when instead I use the ALT hotkey (with a wildcard (*) prefix), the tab will not appear. I think this is because the shift key is considered to modify the alt-key as part of the wildcard (i.e. +Alt is one of the hotkeys included in the wildcard), thus when you press Shift+Alt, that's a hotkey, and when a prefix key is used in this way to modify and launch a hotkey action, by design it's key-up action (if it has one) will not fire.

If this is still an issue you want to work on, I'll continue to look for solutions with your help.
Back to top
View user's profile Send private message Send e-mail
WhiteCloud



Joined: 19 Jun 2004
Posts: 68

PostPosted: Mon Aug 16, 2004 3:22 am    Post subject: Reply with quote

I made several test scripts and they worked. It's got me confused as to whether this one is due to my bad coding or not. I made a work around so I'm not too pressured to get this one sorted out.

I'm going to need a few weeks to get passed this wave of work at work before I delve back into it and give you a decent piece of code to test.
_________________
AHK = Hella fun
Back to top
View user's profile Send private message
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