Jump to content

HotKeySet("+M", "function") not working properly? Shift locks...


 Share

Recommended Posts

Ok, the title says it all. If I Shift+M, it acts as if I'm holding down the shift key and only after I press shift again that it shift-up.

So in my function where I have Send("{Tab}"), it acts as Send("{ShiftDown}{Tab}").

Any one have an idea why is this?

[font="Georgia"]Chances are, I'm wrong.[/font]HotKey trouble?Stringregexp GuideAutoIT Current Version

Link to comment
Share on other sites

HotKey is set to "+M" thus either Shift should work. But I mainly use the Right-ShiftKey. And I just find out, Left-Shift+M works right, but not Right-Shift+M.

Weird! :)

Here's the code.

; ManMan HotKeys
TrayTip("Status: Ready", "HotKeys Loaded", 3)
Sleep(2000)
TrayTip("Clear TrayTip","",0)

HotKeySet("+{ESC}", "_Terminate")

While 1
    If WinActive("SomeWindow") Then
        HotKeySet("+m", "_Func1")
        HotKeySet("+a", "_Func2")
        HotKeySet("{F4}", "_Login")
        HotKeySet("+o", "_Func3")
        HotKeySet("+r", "_Func4")
        HotKeySet("{NUMPADENTER}", "_Enter")
    Else
        HotKeySet("+m")
        HotKeySet("+a")
        HotKeySet("{F4}")
        HotKeySet("+o")
        HotKeySet("+r")
        HotKeySet("{NUMPADENTER}")
    EndIf
WEnd

Func _Terminate()
    TrayTip("Status: Unloading", "HotKeys Closing", 10)
    Sleep(2000)
    Exit
EndFunc

[font="Georgia"]Chances are, I'm wrong.[/font]HotKey trouble?Stringregexp GuideAutoIT Current Version

Link to comment
Share on other sites

Ok I'm pulling hairs now. :)

Is there anyway to re-bind RShiftKey to trigger the same event as LShiftKey? I Googled about this and the solutions I found doesn't even work.

Or better yet, can I disable RShiftKey Event?

And no, HotKeySet() can't do it. It has to be done by overriding Keyboard Events or something.

Anybody have an idea?

[font="Georgia"]Chances are, I'm wrong.[/font]HotKey trouble?Stringregexp GuideAutoIT Current Version

Link to comment
Share on other sites

try something like this, look in helpfile for the keys ;)

If _IsPressed("11") And _IsPressed("12") And _IsPressed("23") Then
    runfunction()
    Sleep(200)
EndIf
Thank you but _IsPressed() only work if the key is pressed, not held down. And even if I try to run a function, the RShiftKey is still pressed and will continue to messed up my macro. :)

[font="Georgia"]Chances are, I'm wrong.[/font]HotKey trouble?Stringregexp GuideAutoIT Current Version

Link to comment
Share on other sites

Hmm, IsPressed works for me like Hotkeyset, if i press this combination, the function will be executed. I use this in some of my scripts, because Hotkeyset can´t use all keys.

Try this example:

#Include <Misc.au3>
While 1
If _IsPressed("11") And _IsPressed("12") And _IsPressed("23") Then
    msg1()
    Sleep(200)
EndIf   

If _IsPressed("11") And _IsPressed("12") And _IsPressed("24") Then
    msg2()
    Sleep(200)
EndIf   
Sleep(50)
WEnd

Func msg1 ()
MsgBox(0, "Test", "ctrl+alt+end was pressed")
EndFunc

Func msg2 ()
MsgBox(0, "Test2", "ctrl+alt+home was pressed")
EndFunc
Edited by Matrix112
Link to comment
Share on other sites

Hmm, IsPressed works for me like Hotkeyset, if i press this combination, the function will be executed. I use this in some of my scripts, because Hotkeyset can´t use all keys.

Try this example:

#Include <Misc.au3>
While 1
If _IsPressed("11") And _IsPressed("12") And _IsPressed("23") Then
    msg1()
    Sleep(200)
EndIf   

If _IsPressed("11") And _IsPressed("12") And _IsPressed("24") Then
    msg2()
    Sleep(200)
EndIf   
Sleep(50)
WEnd

Func msg1 ()
MsgBox(0, "Test", "ctrl+alt+end was pressed")
EndFunc

Func msg2 ()
MsgBox(0, "Test2", "ctrl+alt+home was pressed")
EndFunc
Thank you for your reply, but as I explained above, _IsPressed triggers as it should, but there's more to RightShiftKey than simply pressing a key.

I found out over the weekend that it's one of Windows' stupid features that if you hold RightShiftKey for 8 seconds, it enables some Accessibility Options command that locks Shift as if you're holding it down.

I'm trying to find a way to manipulate the keyboard request or atleast change interrupt the request so I change it as if the LeftShiftKey was pressed instead...and I found where can I do my manipulations to, but I'm not good at meddling with DLLs. ;)

I know what needs to be done, I don't know how to do it with AutoIt or can it even be done. :)

Right now I'm trying to find a way to just kill any RightShiftKey requests, and neither _IsPressed nor HotKey can do it.

Edited by aslani

[font="Georgia"]Chances are, I'm wrong.[/font]HotKey trouble?Stringregexp GuideAutoIT Current Version

Link to comment
Share on other sites

I found out over the weekend that it's one of Windows' stupid features that if you hold RightShiftKey for 8 seconds, it enables some Accessibility Options command that locks Shift as if you're holding it down.

The feature that is being turned on is called "Sticky keys" and is configurable under "Accessibility Options" in the contol panel.

It is also toggled by the registry key

[HKEY_CURRENT_USER\Control Panel\Accessibility\StickyKeys]
"Flags"="506"
The "506" value in "Flags" turns Sticky Keys off.

If you want to disable all Accessibility Options, see here

http://unattended.msfn.org/unattended.xp/v...ea107695888563/

Hope that helps...

Link to comment
Share on other sites

Ok, I have stickykeys turned off on my machine and this still happens all the time to me. Any script that I have used hotkeyset() will (inconsistently) lock one the 3 function keys (alt, ctrl or shift). The only way to release the stuck key is to press it again on my keyboard.

Is there a post that solves this problem or is it a known bug? Been digging a while on this...

keywords: alt ctrl shift hotkey stuck sticking bug

“Efficiency is doing things right; effectiveness is doing the right things.”-Peter F. Drucker

Link to comment
Share on other sites

I've done some more testing and what appears to be happening is this:

If I'm VERY quick about just tapping the hotkey combo, I don't usually have any problems. However, if the assigned function starts sending commands that include keystrokes to the system while I still have the hotkey held down, those keys that are pressed usually get stuck (almost always the CTRL key, for some reason).

So, knowing that, is there a parameter or option I can set to limit this behavior or at least a check I can run to verify that the key has been released before executing the function?

“Efficiency is doing things right; effectiveness is doing the right things.”-Peter F. Drucker

Link to comment
Share on other sites

Have the last line in the function return a {SHIFT UP} or whatever, or set a flag and then run a function based on that flag that sends a {SHIFT UP}

Edited by Blue_Drache

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Link to comment
Share on other sites

So, knowing that, is there a parameter or option I can set to limit this behavior or at least a check I can run to verify that the key has been released before executing the function?

I figured out a workaround to this issue that seems to work. It's a bit clunky but I thought I'd post to see what people think.

#include <Misc.au3>
sleep(3000); press CTRL/ALT/SHIFT or any combination - allows 3 seconds
_waitRelease(); wait for user to release ALL of these keys
msgbox(1, "success", "all function keys released")


Func _waitRelease()
$dll = DllOpen("user32.dll")
While 1
    Sleep (100)
    If _IsPressed("10", $dll) OR _IsPressed("11", $dll) OR _IsPressed("12", $dll) Then
    ; assume a function key is still pressed and loop again
        Else
            ExitLoop
    EndIf
WEnd
DllClose($dll)
EndFunc

I'm going to implement and give it a try. Much better than hoping my crazy "{ShiftUP}" commands work!

“Efficiency is doing things right; effectiveness is doing the right things.”-Peter F. Drucker

Link to comment
Share on other sites

The problem key for me aren't any of those, it's the "A1" - Specifically the RightShiftKey.

The problem is;

If _IsPressed("A1", $dll) Then
 ; do something miraculous that kills this stupid keys for all eternity
EndIf

:)

So, did the above code replacement fix your issue?

“Efficiency is doing things right; effectiveness is doing the right things.”-Peter F. Drucker

Link to comment
Share on other sites

Nope. _IsPressed() is being override, thus the function will execute as if the ShiftKey is held down.

I wonder if AutoIt can sniff the DLL that if 0xA1 is called, AutoIt kills it on site.

This is what I meant by replacing the string. See if this function works in your script:

#include <Misc.au3>
sleep(3000) ; press Right Shift - allows 3 seconds for you to start holding it down
_waitRelease() ; wait for user to release right shift key
msgbox(1, "success", "Right Shift key keys released - now safe to send tab")
send({TAB}) ; continue on with your all important Send({TAB})


Func _waitRelease()
$dll = DllOpen("user32.dll")
While 1
    Sleep (100)
    If _IsPressed("A1", $dll) Then
        ; assume a function key is still pressed and loop again
        Else
            ExitLoop
    EndIf
WEnd
DllClose($dll)
EndFunc

“Efficiency is doing things right; effectiveness is doing the right things.”-Peter F. Drucker

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...