maniootek

HotKeySet with CTRL and ALT keys together

4 posts in this topic

#1 ·  Posted (edited)

;^ = ctrl, ! = alt
HotKeySet("^!p", "Test")

Func Test()
   MsgBox(0,0, "test!")
EndFunc

while 1
   Sleep(100)
WEnd

This code run func "Test()" when I hit RALT + P (no need to hold ctrl), why?

Added: Is it possible to declare hotkey with RIGHT CTRL?

Edited by maniootek

Share this post


Link to post
Share on other sites



maniootek,

A quick Google shows that on many keyboards (such as mine), the right Alt key is marked as "Alt Gr" so you can access special characters on some keys. it also appears that if your keyboard does NOT have this key, you can simulate it by pressing "Alt-Ctrl" - which implies that the "Alt Gr" key produces that same combination and so satisfies the HotKey request.

This warning sums it up nicely:

Therefore, it is recommended that this combination not be used as a modifier in Windows keyboard shortcuts as, depending on the keyboard layout and configuration, someone trying to type a special character with it may accidentally trigger the shortcut, or the keypresses for the shortcut may be inadvertently interpreted as the user trying to input a special character.

If you want to limit the hotkey to just the {RCTRL) key then you will have to check _IsPressed inside the HotKey function.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Thank you. I didn't know about "Alt Gr"

Where can I find HotKeySet() function code?

Share this post


Link to post
Share on other sites

maniootek,

I meant inside the function code that you call when the HotKey is pressed - here is a simple example for which checks which SHIFT key was pressed:

#include <MsgBoxConstants.au3>
#include <Misc.au3>

Local $hDLL = DllOpen("user32.dll")

HotKeySet("{ESC}", "_Exit")

HotKeySet("+p", "Test") ; Shift-P

While 1
    Sleep(10)
WEnd



Func Test()
    If _IsPressed("A0", $hDLL) Then ; Left SHIFT key
        MsgBox($MB_SYSTEMMODAL, "Pressed", "LEFT Shift Key")
    Else ; Must be Right SHIFT key
        MsgBox($MB_SYSTEMMODAL, "Pressed", "RIGHT Shift Key")
    EndIf

EndFunc   ;==>Test

Func _Exit()
    DllClose($hDLL)
    Exit
EndFunc   ;==>_Exit

Clearer now?

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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