Jump to content

Can HotKeySet() Capture the Keyboard's Power (/Sleep/StandBy) Key?


Recommended Posts

Hi all


I have just bought a new keyboard and mouse combo,
it's the Logitech MK295:

MK295.jpg

https://www.logitech.com/en-us/products/combos/mk295-keyboard-mouse-combo.920-009782.html

(really nice keyboard and mouse BTW.
I like how they look, and the keyboard's keys are really quiet. Definitely an improvement over my older keyboard)

 

On the top part of the keyboard, there are 8 additional keys:

Additional-Buttons.jpg

 

I created HotKeySet()s for each one of them, and this is how I managed to map them:

HotKeySet("{MEDIA_PLAY_PAUSE}"  ,"ApplicationLauncher")
HotKeySet("{VOLUME_MUTE}"       ,"ApplicationLauncher")
HotKeySet("{VOLUME_DOWN}"       ,"ApplicationLauncher")
HotKeySet("{VOLUME_UP}"         ,"ApplicationLauncher")

HotKeySet("{BROWSER_HOME}"      ,"ApplicationLauncher")
HotKeySet("{LAUNCH_MAIL}"       ,"ApplicationLauncher")
HotKeySet("{SLEEP}"             ,"ApplicationLauncher")     ;The only one that doesn't work
HotKeySet("{LAUNCH_APP2}"       ,"ApplicationLauncher")

 

So out of 8 keys, I successfully capture 7 of them,
and the only one I have a problem with, is the 7th one - the one with the Power icon and "PC" label.

"{SLEEP}" doesn't seem to capture it..

I wonder, is there another key name that I should try,
or does it happen because Windows so strongly hooks that key,that AutoIt cannot capture it?

 

BTW,
some additional info that might help:

When I go to Control Panel -> Power Options,
and switch to the "Advanced" tab,
then the setting that handles this key is this:

Power-Options-Advanced.jpg


Originally it was set to "Stand by",
and indeed whenpressing that 7th key, the computer would go to Sleep (not Hibernate).

After I changed it to "Do nothing", as can be seen in the screenshot,
then indeed that key does nothing.

In both situations, AutoIt did not capture it..


Hopefully there's another Key Name I should try other than "{Sleep}", which didn't work..


Or, I should give up that key, and not use it with AutoIt, if it's not possible to capture it.


Thank you

Edited by Zohar
Link to post
Share on other sites

Hello, Try a keyboard map tool and check if you get it mapped.

 

Saludos

 

 

Link to post
Share on other sites

You can simply open the _WinAPI_SetWindowsHookEx example.  Just add a line at the very beginning of the Func EvaluateKey($iKeycode):

ConsoleWrite ($iKeyCode & @CRLF)

If it shows a code, you know that KB is sending it to computer.  But if you read carefully HotKeySet, there are a number of keys that you cannot use...

Link to post
Share on other sites
  • Moderators

JockoDundee,

Have you never read this announcement? If not, then do so now and count yourself lucky I am in a generous mood.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to post
Share on other sites
9 hours ago, Melba23 said:

Have you never read this announcement?

Yes, I have.  And I see the violation, clearly, in retrospect.

9 hours ago, Melba23 said:

If not, then do so now and count yourself lucky I am in a generous mood.

I have reread it, and thank you.

<snip>

Thank you.

Full disclosure, I wrote this yesterday.

Edited by Melba23
Discussed removed point via PM

Code hard, but don’t hard code...

Link to post
Share on other sites
58 minutes ago, Melba23 said:

I am in a generous mood.

Aren't you always ?  I hardly remember you being in a very bad mood (well maybe one time) ;)

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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...