Jump to content

HotKey UDF


Yashied
 Share

Recommended Posts

@JohnOne, that problem vanished after a restart.

Spoiler

My Contributions

Glance GUI Library - A gui library based on Windows api functions. Written in Nim programming language.

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)

 

Link to comment
Share on other sites

  • 2 months later...

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
Link to comment
Share on other sites

@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
Link to comment
Share on other sites

#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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

  • 11 months later...

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.

Link to comment
Share on other sites

  • 7 months later...

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.

Link to comment
Share on other sites

  • 1 month later...
  • Developers
Link to comment
Share on other sites

  • 10 months later...
  • 3 months later...

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

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • 4 months later...

Hey, I have a little question. I want to make a Hotkey, that calls function, that is checking with "_IsPressed" method, if the user is holding down the key.
With the normal HotKey UDF it worked. But with this, the key gets released when I press the Hotkey. When I use "$HK_FLAG_NOBLOCKHOTKEY" it works, but then my keys will also get written down. Someone has suggestions?

Code:

_HotKey_Assign($keyLeft, "left", $HK_FLAG_NOBLOCKHOTKEY + $HK_FLAG_NOOVERLAPCALL)

...

Func left()
        MouseDown("left")
        While (_IsPressed($keyLeft, $dll))
            Sleep(20)
        WEnd
        MouseUp("left")
EndFunc   ;==>left

So I want to click with a key on my keyboard, but I also want to drag with it, thats why I use "_IsPressed". The User can customize the keys and I save the keycode in an ini, thats why this UDF is pretty useful, but I can't detect whether the user is still holding down the key.

Edited by Maran23
Link to comment
Share on other sites

  • 2 months later...
  • 4 years later...

what about Opt('SendCapslockMode', 0) and Send() ?

without SendCapslockMode I have more problems (slow press Send command/Caps Lock blinking etc...) with SendCapslockMode not but this UDF not working as expected when I using Send() or when I wanna hotkey with SHIFT

#include 'WinAPIGdi.au3'
#Include '..\HotKeyUDF\HotKey_21b.au3'

Opt('SendCapslockMode', 0)

$_SHIFT = '0x0100'
$_CTRL  = '0x0200'
$_ALT   = '0x0400'
$_WIN   = '0x0800'

$E = '0x45'
$R = '0x52'

_HotKey_Assign($_ALT + $E, "E", 4)
_HotKey_Assign($_ALT + $R, "R", 4)

while True
   sleep(10)
wend

Func E()
   ConsoleWrite("E")
   Send("E")
   sleep(200)
EndFunc

Func R()
   ConsoleWrite("R")
   sleep(200)
EndFunc

when I hold down ALT+R then write R into console as expected but when I hold down ALT+E function run only one, I must release ALT when I wanna run ALT+E again... can anyone help?

Edited by ibecko
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...