Jump to content
Yashied

HotKey UDF

Recommended Posts

kcvinu

@JohnOne, that problem vanished after a restart.


My Contributions

UDF Link Viewer   --- A tool to visit the links of some most important UDFs 

 Includer_2  ----- A tool to type the #include statement automatically 

 Digits To Date  ----- date from 3 integer values

PrintList ----- prints arrays into console for testing.

 Alert  ------ An alternative for MsgBox 

 MousePosition ------- A simple tooltip display of mouse position

GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function

Access_UDF  -------- An UDF for working with access database files. (.*accdb only)

 

Share this post


Link to post
Share on other sites
bitingsock

I am experiencing a very frustrating bug.

_HotKey_Assign(BitOR($CK_CONTROL, $VK_RETURN), 'popup')

When I try to activate the hotkey using the right control key, my keyboard continues to behave as if the control key has been left down. If I press the left control key and release it fixes it until I use the hotkey again. Pressing the right control key at that time does not fix the problem; only if I press the left control key.

If I activate the hotkey using the left control key the problem is not exhibited.

Edited by bitingsock

Share this post


Link to post
Share on other sites
Yashied

@bitingsock

I can't reproduce this "bug".

#Include <HotKey.au3>

Global Const $VK_RETURN = 0x0D

_HotKey_Assign(BitOR($CK_CONTROL, $VK_RETURN), 'Test')

While 1
    Sleep(10)
WEnd

Func Test()
    ConsoleWrite('OK' & @CRLF)
EndFunc   ;==>Test
Edited by Yashied

Share this post


Link to post
Share on other sites
bitingsock
#RequireAdmin
#include <HotKey_21b.au3>
#include <vkConstants.au3>
Opt("GuiOnEventMode", 1)
$Form1 = GUICreate("Ventrilo Dictator", 530, 60, -1, -1, -1)

GUICtrlCreateLabel("Set a comment", 3, 0, 530, 17)
GUICtrlCreateLabel("Ctrl+Enter for popup mode", 400, 0, 150, 20)
$Input1 = GUICtrlCreateInput("", 3, 20, 450, 21)
$Button1 = GUICtrlCreateButton("Set", 460, 20, 30, 21)
_HotKey_Assign(BitOR($CK_CONTROL, $VK_RETURN), 'popup')
$Button2 = GUICtrlCreateButton("clear", 490, 20, 30, 21)
GUISetState(@SW_SHOW, $Form1)
$tts = ""
$previouswindow = 0
ControlFocus("Ventrilo Dictator", "", $Input1)
While 1
    Sleep(30)
WEnd
Func popup()
    If WinGetHandle("[active]") = $Form1 Then
        If $previouswindow <> 0 Then WinActivate($previouswindow)
    Else
        $previouswindow = WinGetHandle("[active]")
        WinActivate("Ventrilo Dictator")
        WinSetOnTop($Form1, "", 1)
        ControlFocus("Ventrilo Dictator", "", $Input1)
        WinSetOnTop($Form1, "", 0)
    EndIf
EndFunc

Here is a slimmed down version of my project. I will note the problem is now cleared by pressing the right control key afterwards (sometimes, I think)

Try to type something into the gui this creates and you may notice the problem? I am on Win8.1 x64 btw

Edited by bitingsock

Share this post


Link to post
Share on other sites
bitingsock

I've discovered if I put a sleep(1000) in between

$previouswindow = WinGetHandle("[active]")

and

WinActivate("Ventrilo Dictator")

it prevents the problem so this may be a higher level bug and not directly something with the UDF.

EDIT:

ya it looks like it has something to do with having the key down when switching windows; I changed my popup() to

Func popup()
    If WinGetHandle("[active]") = $Form1 Then
        If $previouswindow <> 0 Then
        While _IsPressed("11") or _IsPressed("0D")
            Sleep(10)
        WEnd
        WinActivate($previouswindow)
        EndIf
    Else
        $previouswindow = WinGetHandle("[active]")
        While _IsPressed("11") or _IsPressed("0D")
            Sleep(10)
        WEnd
        WinActivate($Form1)
        WinSetOnTop($Form1, "", 1)
        ControlFocus($Form1, "", $Input1)
        WinSetOnTop($Form1, "", 0)
    EndIf
EndFunc

seems to fix my problem

Edited by bitingsock

Share this post


Link to post
Share on other sites
RedwookHighway

I'm trying to run a simple test for this but I'm not getting anything. The script I came up with should make a beep sound play when ctrl v is pressed. Can anyone see any glaring issues with my code? It should also not interfere with the proper function for the past command.

 

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.8.1
 Author:         myName
 Script Function:
    Template AutoIt script.

#ce ----------------------------------------------------------------------------


#include<HotKey_21b.au3>
#include<vKConstants.au3>

_HotKey_Assign(BitOr($VK_CONTROL, $VK_V), "HotTest", $HK_FLAG_NOBLOCKHOTKEY, 0)

Func HotTest()

    Beep(1000, 500)

    EndFunc

While 1
    sleep(200)

WEnd

I am running this on a Windows 8.1 box.

Share this post


Link to post
Share on other sites
RedwookHighway

Interesting thing when running my test script the w key now makes the beep sound. There must be something going on with the Virtual-Key Codes. I looked them up but they seem correct.

Share this post


Link to post
Share on other sites
therks

So I see that @Yashied hasn't been active in a while, so I'm hoping someone else paying attention to this thread can help.

I seem to be having a similar issue as @bitingsock above. If another window is granted focus immediately, then the script will not recognize that the key has been released and will block all other keys from being typed. See repro script here:

;~ #include <HotKey.au3>
#include <HotKey_21b.au3>
#include <vkConstants.au3>

$hWnd = GUICreate('Issue Test', 400, 300)
GUICtrlCreateInput('', 0, 0, 400, 20)
GUICtrlCreateLabel('First, press the hotkey (Win+Space). Now, without pressing space or any control keys (Alt, Win, etc) try to type anything in the input field. ' & _
    'You should notice that nothing seems to happen, and in fact all normal keys are unresponsive across windows, UNLESS you hit space or another control key.', 0, 30, 400, 100)

_HotKey_Assign(BitOR($CK_WIN, $VK_SPACE), '_Test')

GUISetState()
Do
Until GUIGetMsg() = -3

Func _Test()
;~  __HK_KeyUp($VK_SPACE) ; Uncomment to fix
    WinActivate($hWnd)
EndFunc

This seems to be because __HK_KeyUp() is not being called properly. I assume because it should be called on the WM_KEYUP or WM_SYSKEYUP message, and the monitoring window is not receiving that message because a different window is active when the key is released. I tried looking through the code to figure out where I could maybe force a check but I'm very lost. At best I could put it in the HK_WM_HOTKEY() function but I'm not sure how to get the right VK code to that function without hard coding it.

  • Like 1

Share this post


Link to post
Share on other sites
Zoldex

I'm experiencing the very same problem: CTRL key keeps "hooked" and I need to press it alone to let it unlock.

Anyways I'm having the problem also with original HotKeySet function...

Hope someone can help...

Share this post


Link to post
Share on other sites
Jos
  • Like 3

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Mbee

Never mind (I deleted my question)

Edited by Mbee
Wrong question

Share this post


Link to post
Share on other sites
x_bennY

Hey, i'm having a big problem here... when i press a lot of keys in the same time the keys stops working! i can't type anything into my application.

_HotKey_Assign(BitOR($CK_ALT, $VK_F11), "HotKeyPressed_Raw", BitOR($HK_FLAG_DEFAULT, $HK_FLAG_EXTENDEDCALL, $HK_FLAG_NOBLOCKHOTKEY))
_HotKey_Assign($VK_RETURN, "HotKeyPressed_Raw", BitOR($HK_FLAG_DEFAULT, $HK_FLAG_EXTENDEDCALL, $HK_FLAG_NOBLOCKHOTKEY))

 

Share this post


Link to post
Share on other sites
Deye

x_bennY,
Maybe you want to "_HotKey_Disable \ Enable" at the calling function's enter \ exit times

I never used this UDF before.. ,  Please note that your reproducer doesn't tell us much as to how .. Or why this happening there, it isn't a complete reproducer ..

  • Like 1

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

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.