AutoHotKey refused to send Alt, which is supposed to display the menu with shortcuts

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
t_baker
Posts: 4
Joined: 12 Jan 2016, 19:37

AutoHotKey refused to send Alt, which is supposed to display the menu with shortcuts

12 Jan 2016, 20:18

Hi, first, thanks for your time on this post.

I'm using AutoHotKey v1.1.22.09 on Windows 10, in a computer-aided translation software Trados Studio 2014.

I want to perform a shortcut operation which includes the following two steps:

1) display the menu with quick access keys, which is similar to physically pressing the Alt key on the keyboard. The expected result of sending {Alt} is attached to the post.

2) after this menu is displayed, I can "Send H", "Send U", and then "Send A" to implemented the required function.

However, I was stuck in step 1): AutoHotKey refused to send {Alt}, or if it did send {Alt}, it must have done it in a different way, because no menu is displayed.

I tried the following in the hope of simulating the physically pressing the Alt key to display the menu:
^[::Send {Alt}
^[::Send !
^[::Send Alt

None of these provide the expected result. Did I do something wrong, as a new AutoHotKey user does, or is there any suggestion?

Thanks again.
Attachments
2016-1-13 9-04-47.png
Expected display after sending {Alt}
(5.21 KiB) Downloaded 82 times
User avatar
evilC
Posts: 4823
Joined: 27 Feb 2014, 12:30

Re: AutoHotKey refused to send Alt, which is supposed to display the menu with shortcuts

13 Jan 2016, 08:29

"Alt" does not actually exist as a key - "Left Alt(LAlt)" and "Right Alt(RAlt)" exist as keys.
Trying to send Alt without a left or right variant may not do what you want.

Furthermore, if you wish to send a combination of ALT and other keys, there is a better way to do that.

To send ALT+F, try: Send !f
To send ALT on it's own, try Send {LAlt}
You shouldn't need to send ALT on it's own though, if you wish to open the "File" menu, just Send !f should do it fine - you should not need to wait for the menu to appear.
t_baker
Posts: 4
Joined: 12 Jan 2016, 19:37

Re: AutoHotKey refused to send Alt, which is supposed to display the menu with shortcuts

13 Jan 2016, 12:29

Hi evilC, thanks a lot for your message.

Yes, I should directly Send !f (in my case, it's Send !h). Send !h worked in many software, including Total Commander, Chrome browser, and the like. This means that the keystroke is correct and should work properly.

However, unfortunately, I did not get the expected result in the specific software that I need - Trados Studio. Maybe it is not a problem of AutoHotKey, but one related to Trados Studio, or a problem of compatibility between the two. I guess I have to take it as it is. How I wish there will be a workaround for this, no matter though Trados Studio or through AutoHotkey.
t_baker
Posts: 4
Joined: 12 Jan 2016, 19:37

Re: AutoHotKey refused to send Alt, which is supposed to display the menu with shortcuts

13 Jan 2016, 20:39

Hi evilC, thanks for your reply.

Yes, Trados Studio recognizes other keys, including +{F10} to display the shortcut menu, MouseMove to move to a function icon, {Click}, {Enter}, and some others. These are the keys I use because {Alt} is unavailable to activate the shortcut menu. Currently, I only have the Alt problem on Trados Studio.

I tried SetKeyDelay and running as administrator, but {Alt} or !h still does not respond in Trados Studio. :(

But still thank your for your suggestions.
lexikos
Posts: 9583
Joined: 30 Sep 2013, 04:07
Contact:

Re: AutoHotKey refused to send Alt, which is supposed to display the menu with shortcuts

13 Jan 2016, 21:47

^[::Send {Alt} will not work in most applications because you are still holding the Ctrl key. Manually pressing Ctrl+Alt does not activate the menus either. Send automatically releases the hotkey's modifiers when you send a non-modifier key, but it does not do this for a modifier key on its own, such as {Alt} or {Alt down/up}.

It looks like Trados Studio uses the Ribbon Framework, similar to Word 2010 and WordPad (in Windows 7 at least). The following works on Word and WordPad, but it's possible that Trados Studio handles keyboard input differently, or that Word and WordPad don't use the same/public version of the Ribbon Framework.

Code: Select all

^[::
KeyWait Ctrl
Send {Alt}
return
^[::Send !f also works in Word and WordPad, but we know Send !h does not work in Trados Studio. Have you tested it with a different hotkey, or without a hotkey (e.g. after WinActivate)?
evilC wrote:"Alt" does not actually exist as a key - "Left Alt(LAlt)" and "Right Alt(RAlt)" exist as keys.
There are three virtual keys: VK_LMENU, VK_RMENU and VK_MENU. Alt and ! for a hotkey and Alt for KeyWait mean any of the three, but Send {Alt} is equivalent to Send {LAlt}.
t_baker
Posts: 4
Joined: 12 Jan 2016, 19:37

Re: AutoHotKey refused to send Alt, which is supposed to display the menu with shortcuts

14 Jan 2016, 04:17

Hi lexikos,

Thank you so much.

Code: Select all

^[::
KeyWait Ctrl
Send {Alt}
return
This script did the work. This activates the ribbon and shows the shortcut "H" that I'm eager to have.

With this working, I can customizing many shortcut functions in Trados Studio, which is a very popular computer-aided translation (CAT) application. I saw other people in some translation forums are puzzled by this problem. I believe they will be as happy as me if they find this post.
jck

Re: AutoHotKey refused to send Alt, which is supposed to display the menu with shortcuts

16 Aug 2018, 11:36

I know this thread is old, but I would like to complete the answer, because with some configurations it doesn't work as expected (in my case: when using Windows with a Steam Link).

First it's useful to make a function to be sure all keys are released (I use this one for all my hotkeys):

Code: Select all

waitRelease() {
	KeyWait Control
	KeyWait Shift
	KeyWait Alt
}
Then to use a ribbon shortcut, this should usually work:
(exemple for the ribbon shortcut in Word for creating a bullet list : alt l k right right enter)

Code: Select all

!^+b::
	waitRelease()
	Send {alt}lk{right}{right}{enter}
return
And as I said above, if this doesn't work for you, the trick I found is to replace {alt} by !{space}{alt}{alt}. This actually force the focus on the current window, like this:

Code: Select all

!^+b::
	waitRelease()
	Send !{space}{alt}{alt}lk{right}{right}{enter}
return
Hope this could help those who still need
lexikos
Posts: 9583
Joined: 30 Sep 2013, 04:07
Contact:

Re: AutoHotKey refused to send Alt, which is supposed to display the menu with shortcuts

16 Aug 2018, 23:56

I have corrected the code in the post above to remove the incorrect use of braces and terminate the hotkey subroutines with return.

This is a remapping, not a hotkey: !^+b::{

Braces should not be used with hotkeys or labelled subroutines, as they generally have no effect (other than to mislead the reader/author).

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Fredrik F, Joey5, maxkill and 400 guests