zone97

HoyKey UDF (Glicth Fix?)

6 posts in this topic

I am using the hotkey_21b.au3 UDF.. And as others have pointed out there is a glitch where the keys get stuck.. Here is an example script where I tried to make a work around. Anyone know how I might fix this? Short of not using the UDF...  The test, I opened notepad put in some text, hit the hot key and it selected all and cleared. But often the CTRL or ALT key gets hung? I have even had it trigger CTRL-ALT-DEL .. Ideally Id like to find the glitch in the UDF and fix it.

 

#include ".\Includes\HotKey_21b.au3"

; - 1620 = CTRL-ALT-T

 _HotKey_Assign('1620', 'test', $HK_FLAG_DEFAULT)

 While 1
 Sleep(100)
 WEnd

Func Test()
    ReleaseModifiers()
    Send("^a")
    Send("{DEL}")
    MsgBox(0, "test", "I sent a CTRL-A followed by DELETE")
    Exit
EndFunc

Func ReleaseModifiers()
    Send("{SHIFTUP}")
    Send("{CTRLUP}")
    Send("{ALTUP}")
    Sleep(100)
EndFunc   ;==>ReleaseModifiers

 

HotKey_21b.au3


 

Spoiler

WinSizer 2.1 (01/04/2017) - Download - [ Windows Layout Manager ]
Folder+Program (12/23/2016) - Download - [ USB Shortcut Creator ]

 

Share this post


Link to post
Share on other sites



After trying several fixes. This one seems to be the most reliable. I replaced the built in Send() function with SendEx()

Func SendEx($ss, $warn = "")
    Local $iT = TimerInit()
    ; - Check for stuck modifiers ALT, SHIFT, CTRL, LWIN, RWIN
    While _IsPressed("10") Or _IsPressed("11") Or _IsPressed("12") Or _IsPressed("5B") Or _IsPressed("5C")
        If $warn <> "" And TimerDiff($iT) > 1000 Then
            SplashTextOn("", "Working!", 130, 43, -1, -1, 1)
            Sleep(500)
            SplashOff()
        EndIf
        Sleep(50)
    WEnd
    Send($ss)
EndFunc   ;==>SendEx

 


 

Spoiler

WinSizer 2.1 (01/04/2017) - Download - [ Windows Layout Manager ]
Folder+Program (12/23/2016) - Download - [ USB Shortcut Creator ]

 

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

I can't remember what it was exactly but you could send the key up, after using any ctrl or alt or shift.

Edited by careca

Spoiler

Paster - Main function is to paste text, but has more functions.

OpenW - Open With... alternative, Open any file with any application, set it's icon, set application as default.

Renamer - Rename files and folders, remove portions of text from the filename etc.

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Firefox Profile Backup - Backup/restore previously saved profile.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

 

Share this post


Link to post
Share on other sites

I had tried the {CTRLUP} option, didn't work. Here is my text example with applied fixes. Not 100% but closest I could get.

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Run_Tidy=y
#Tidy_Parameters=/tc 4 /reel
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

#include ".\Includes\HotKey_21b.au3"
; - Functional UDFs
#include <Timers.au3>
#include <Misc.au3>

; - 1621 = CTRL-ALT-U

; - Keyboard cleanup handler
Global $dll = DllOpen(@WindowsDir & "\System32\user32.dll")
Global Const $vKeys[8] = [0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0x5B, 0x5C]

_HotKey_Assign('1621', 'test', $HK_FLAG_DEFAULT)

While 1
    Sleep(100)
WEnd

Func Test()
    ReleaseModifiers()
    SendEx("^a")
    SendEx("{DEL}")
    MsgBox(0, "test", "I sent a CTRL-A followed by DELETE")
    Quit()
EndFunc   ;==>Test

Func SendEx($ss, $warn = "")
    Local $iT = TimerInit()
    ; - Check for stuck modifiers ALT, SHIFT, CTRL, LWIN, RWIN
    While _IsPressed("10") Or _IsPressed("11") Or _IsPressed("12") Or _IsPressed("5B") Or _IsPressed("5C")
        If $warn <> "" And TimerDiff($iT) > 1000 Then
            SplashTextOn("", "Working!", 100, 43, -1, -1, 1)
            Sleep(500)
            SplashOff()
        EndIf
        Sleep(50)
    WEnd
    Send($ss)
EndFunc   ;==>SendEx

Func ReleaseModifiers()
    For $vKvalue In $vKeys
        DllCall($dll, "int", "keybd_event", "int", $vKvalue, "int", 0, "long", 2, "long", 0) ; Release each key
        Sleep(10)
    Next
    Sleep(100)
EndFunc   ;==>ReleaseModifiers

Func Quit()
    DllClose($dll)
    ReleaseModifiers()
    Exit
EndFunc   ;==>Quit

 


 

Spoiler

WinSizer 2.1 (01/04/2017) - Download - [ Windows Layout Manager ]
Folder+Program (12/23/2016) - Download - [ USB Shortcut Creator ]

 

Share this post


Link to post
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