Jump to content

Recommended Posts

Posted (edited)

Greetings people of the AutoIt community!

I think I have discovered some possible wrong verbiage in the HelpFile.

I'm trying to make my software detect the _IsPressed("KEY") for the RIGHT MENU button on the keyboard. 

You all have a RIGHT MENU button on your keyboard (maybe you haven't noticed it), it's they key between the Right ALT key and the Right CTRL Key.

However!!!!!!! In the helpfile it says the RIGHT MENU key is "A5", that is not true for me. A5 is actually the Right ALT key.

So my question is, what is the _IsPressed HexKey for the RIGHT MENU button?

 

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

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

While 1
    If _IsPressed("A5", $hDLL) Then
       Sleep(100)
       msgbox(0,"Test", "Pressed!")
      Sleep(250)
      EndIf
WEnd

DllClose($hDLL)

 

If you try to run the above code, the msgbox will only appear if you press the Right ALT key, even though the helpfil says that A5 is the Right Menu Key hex.

 

Thank you,

Brian

Edited by BlazerV60
Inserted my code
Posted

According to Microsoft, the right menu key is 0xA5 or $VK_RMENU. No clue why your keyboard shows it as the ALT key. The virtual keycode for the ALT key is supposed to be 0x12 or $VK_MENU, according to Microsoft.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

  Reveal hidden contents

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Posted

Hi BrewMan,

For some reason this isn't the case for me.

If I try to run this simple script below, the msgbox will only appear if I press the RIGHT ALT key. It won't show if I pressed the RIGHT menu key.

 

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

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

While 1
    If _IsPressed("A5", $hDLL) Then
       Sleep(100)
       msgbox(0,"Test", "Pressed!")
      Sleep(250)
      EndIf
WEnd

DllClose($hDLL)

Let me know if the above code works fine for you.

 

Thanks!

Posted

@BrewManNH do you mean this MSDN article ?

https://msdn.microsoft.com/pl-pl/library/ms927178.aspx

VK_LMENU 0xA4 Left ALT
VK_RMENU 0xA5 Right ALT

If so then you have right about that this function works correctly.

 

But I think this user is looking for this key:
https://en.wikipedia.org/wiki/Menu_key

Am I right @BlazerV60 ?

 

If so then, I can agree with @BlazerV60 that HelpFile is using wrong wording as "Right ALT" <> "Right MENU key" and where you can find "Left MENU key"

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

according to:   https://en.wikipedia.org/wiki/Menu_key

  Quote

Programmers using the Windows API can intercept this key by looking for a WM_KEYDOWN message with wParam VK_APPS (defined as 0x5D in winuser.h). It has key code 93 (VK_APPS 0x5D.)

Expand  

 

and  https://msdn.microsoft.com/pl-pl/library/ms927178.aspx

VK_APPS 5D Applications key on a Microsoft Natural Keyboard


So this example should looks like this:

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

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

While 1
    If _IsPressed("5D", $hDLL) Then
       Sleep(100)
       msgbox(0,"Test", "Pressed!")
      Sleep(250)
      EndIf
WEnd

DllClose($hDLL)


 

btw.
HelpFile for _IsPressed()   should be extended, I mean this following information:

VK_APPS 5D Applications key on a Microsoft Natural Keyboard

should be added.

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

It depends on what the wording is for the key, in the MSDN site, the ALT key uses the VK_MENU key code, so I guess the RMENU key would equate to the right ALT key, if the ALT key is called the MENU key.

I did some digging, and the key you're looking for is the APPS key, which uses key code 0x5D or $VK_APPS.

BTW, the key code variables I mentioned are found in WinAPIvkeysConstants.au3

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

  Reveal hidden contents

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Posted

@mLipok

Yes, mLipok the wikipedia article that shows the image of the Menu key that you linked is EXACTLY the key I'm talking about.

And I also agree with you on the revision that should be made in the Help File.

The Help File should be updated to say:

A5 Right ALT key INSTEAD OF A5 Right MENU key 

Also, as you suggested, the helpfile should be extended to add this:

5D  Right MENU key

@BrewManNH

Maybe it can be called the APPS key too, but most people know it as the Menu key. The wikipedia link shown by mLipok shows that it's officially called the Menu key as well.

Thank you for directing me to the WINAPIvKeysConstants.au3, that should also have revisions to reflect this new update

I also did some digging, in the GERMAN autoit helpfile: https://autoit.de/onlinehilfe/libfunctions/_IsPressed.htm

It correctly lists A5 as the Right Alt Key, unlike in the English version. The link is an English/German side by side comparison.

 

Thank you everyone for helping me in this. 5D is the correct hex for the Menu button, and now I'm able to finish my program.

Posted (edited)
  On 1/24/2016 at 10:29 PM, BrewManNH said:

BTW, the key code variables I mentioned are found in WinAPIvkeysConstants.au3

Expand  

I see that.
I wonder how to use these variables with this function?

 

btw.

I just added this

  Quote

    5D PopUp Menu Key - Applications key on a Microsoft Natural Keyboard

Expand  

to HelpFile documentation for _IsPressed(). (edit: in SVN)

 

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

Unfortunately the _IsPressed function won't recognize the $VK_* key variables, I just remembered that the function adds the "0x" to the start of the string you send the function. So you have to send it the string of the key codes instead of the constants it should be using.

Although the whole function basically is a 3 line wrapper for the GetAsyncKeyState function, so the _isPressed function is kind of a dummy's guide to the _WinAPI_GetAsyncKeyState function in the WinAPI UDF.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

  Reveal hidden contents

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

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
×
×
  • Create New...