Jump to content

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


 Share

Recommended Posts

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
Thank you though. It still doesn't work. The reason why is that, even if you release the RightShiftKey, it still act as if you are holding the Shift key down even if you're not.

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

Link to comment
Share on other sites

Can you post a sample of your code that recreates this problem? If possible, just the relevant portions without any dependencies (such as 3rd party applications).

I've completely solved my stuck function keys with this little function...

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

Link to comment
Share on other sites

Can you post a sample of your code that recreates this problem? If possible, just the relevant portions without any dependencies (such as 3rd party applications).

I've completely solved my stuck function keys with this little function...

Post #3

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

Link to comment
Share on other sites

#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")


; 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 _Func1()
_waitRelease()
; some script you want to run
EndFunc


Func _Func2()
_waitRelease()
; some script you want to run
EndFunc

Func _Func3()
_waitRelease()
; some script you want to run
EndFunc

Func _Func4()
_waitRelease()
; some script you want to run
EndFunc


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




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

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

Link to comment
Share on other sites

I was placing that function into wrong places...no wonder it's not working.

The real credit here should go to the people who wrote the lovely help system for this program. I just had to reverse the logic behind the sample they threw into that and viola, it worked. Of course, we both lucky the function is called *is*Pressed and not *was*Pressed. That would be much less useful.

I'd say chalk a win up to AutoIT on this one and I'll be using this little baby in all my hotkey activated functions going forward.

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