AHK Win8.1 View Key Info won't refresh

Report problems with documented functionality
User avatar
Posts: 2
Joined: 17 Jun 2017, 03:03

AHK Win8.1 View Key Info won't refresh

17 Jun 2017, 07:31

I've just installed AHK on a Windows 8.1 system. I wrote a tiny script so I could look at keyboard scancodes:

MsgBox, While blah blah
, and more blahs

The idea is that the message box (which in my real script has rather longer and more meaningful text than this example
does) holds the script up so I can use the systray icon to Open the main window. Then View -> Key History & Script Info
lets me see key information.

However... there's a problem with View. Although its display says "Press [F5] to refresh" that simply does nothing. I /can/
get the display refreshed, but only by clicking View -> Refresh.

I'm also puzzled by the text displayed by MsgBox: the comma at the start of the third line of the script is meant, I thought,
to indicate continuation from the previous line? The displayed text IS continued, but the comma is displayed as well. Is
that meant to happen?

I've also found that sometimes there's no systray icon, which makes the whole thing useless. I clicked the taskbar up-arrow
icon (to see if there was anything relevant in Control Panel - Notifications) and found that there were about a dozen separate
AHK icons listed there, all set as 'Only show notifications'. I altered ONE of them to 'Show icon and notifications' & the settings
of about eight of those listed all changed. I made the same alteration to ONE of the remaining entries and all the others all
changed. I had only so far tried two scripts, so this suggests that Windows is trying to track lots of per-script separate icons.
But, when I installed AHK, I explicitly chose NOT to have separate systray icons. I then tried starting my test script, and before
closing its Msgbox, starting it again. YES, TWO systray icons appeared. That's clearly not right.

Also, sometimes when I run my test script, even when its MsgBox has been closed, the systray AHK icon remains on the tray. I'd
expect it to vanish when the script's no longer active.

Lastly, when I first read the information in the help file about using the KeyHistory command, or View -> Key... I was perplexed
by the reference to the "main window". There's no indexed entry in the help file for "main window". It wasn't at all clear to me how
one would get a "main window" to display. I'm fairly sure that my first experiments didn't have a systray icon at all.

Re: AHK Win8.1 View Key Info won't refresh

17 Jun 2017, 12:45

If there is no tray icon it probably means you have https://autohotkey.com/docs/commands/_NoTrayIcon.htm in your script, so be sure to check that.

If you use https://autohotkey.com/docs/commands/_I ... bdHook.htm the script becomes persistent meaning it stays active and doesn't automatically exit, see the note at the end of the documentation and https://autohotkey.com/docs/commands/_Persistent.htm for reference as well.

Win8.1 64bit with v1.1.26.00 pressing F5 refreshes the window and I see the F5 (and other keys I pressed) appear as normal.
User avatar
Posts: 2
Joined: 17 Jun 2017, 03:03

Re: AHK Win8.1 View Key Info won't refresh

17 Jun 2017, 14:56

Thanks for your reply. I don't have #NoTrayIcon in the script; it's precisely and only the three lines I posted, though I've now added ExitApp to it.

Regarding View & F5, I did have one instances of F5 working for refresh of the initial View pane, and found that when I susbequently went to the View -> Key Info ... display then F5 did work, but if I started the script and went directly to View -> Key Info... F5 didn't work any of the ten or so times I tried this. I wasn't able to recreate the instance where it did work, either.

Re: AHK Win8.1 View Key Info won't refresh

17 Jun 2017, 15:09

Try with this script yes just one line, now your view keys and pressing F5 should work and there should be an icon in the tray. You can press the little arrow near the tray to "customize it" perhaps ahk is set to "always hide" or something like that.

MsgBox you have in your script probably locks the script/thread as it is modal (ahk can't do anything until you've pressed the button) so it waits until it is dismissed - in the meantime it won't register any key presses either so you won't see them.
Strange you still don't see an icon in the tray though.
User avatar
Posts: 1670
Joined: 19 Dec 2016, 01:58
Location: UK

Re: AHK Win8.1 View Key Info won't refresh

17 Jun 2017, 16:33

I believe the install option is about single/multiple *taskbar buttons* for scripts, rather than systray icons.

You can have the same script open more than once (and hence have multiple systray icons but for different instances of the script), see #SingleInstance.

As Guest said, some scripts are 'persistent', see #Persistent, and to close those you need to use ExitApp. Otherwise scripts tend to close when they reach 'return' or 'Exit' or the last line of a script.

Personally I add #NoTrayIcon to all my scripts except one or two, and use a 'master' script to interact with the hidden ones, which I may eventually release, although Lexikos has released something similar called 'AHKControl'.

Autohotkey-scripts-.ahk/AHKControl.ahk at master · Drugoy/Autohotkey-scripts-.ahk · GitHub

MsgBox parameters can be a bit fiddly, it has some 'smart' behaviour.

Re. 'main window', I found this in the documentation:

Variables and Expressions

[v1.1.01+] The unique ID (HWND/handle) of the script's hidden main window.

Or right-click an AHK systray icon, and click 'Open'.

I'm working on a beginner tutorial, I'll be sure to include a reference to 'main window'.

I created a small script, the key history did not update when F5 was pressed when the MsgBox was visible, but F5 did work during the Sleep periods, refresh did work at all times via 'View, Key history and script info':
So testing on Windows 7, latest AHK (v1.1.26.00), I had the same problem you did.
Last edited by jeeswg on 20 Jun 2017, 02:53, edited 1 time in total.
Posts: 5407
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: AHK Win8.1 View Key Info won't refresh

17 Jun 2017, 20:26

It is by design, and has been that way since the beginning.

Menu keyboard accelerators (keyboard shortcuts) are implemented by calling TranslateAccelerator from the program's message loop. Modal dialogs run their own message loop, which dispatches messages directly to the target window's procedure. TranslateAccelerator isn't designed to be called from the window procedure. The accelerator table isn't registered anywhere (and isn't designed to be), so there is no way for the dialog's message loop to know it exists, and therefore no reason for it to call TranslateAccelerator.

The current documentation has no section for general program operation (or operation of the tray icon, or a central place relating to both that and ListLines/ListVars/KeyHistory), so nowhere appropriate to document the limitation. It is already included in my work-in-progress documentation revision (which I wrote about here).
User avatar
Posts: 1670
Joined: 19 Dec 2016, 01:58
Location: UK

Re: AHK Win8.1 View Key Info won't refresh

23 Jun 2017, 07:30

If only there were some hotkey-based utility that could help us out in this situation.

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

Menu item ID (65410) retrieved via:
Get Info from Context Menu (x64/x32 compatible) - AutoHotkey Community

[EDIT:] I've added a script here, for using all of the main window hotkeys even when a MsgBox is showing:
list of AutoHotkey WM_COMMAND IDs (e.g. Reload/Edit/Suspend/ListVars on another script) - AutoHotkey Community

Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 3 guests