Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Hotkey Help - Display Active AHK Hotkeys and Hotstrings


  • Please log in to reply
77 replies to this topic
Fanatic Guru
  • Members
  • 254 posts
  • Last active: Nov 13 2015 10:07 PM
  • Joined: 08 Jul 2011
This script creates a Hotkey Help dialog that shows all the Hotkeys found in all of the AHK files currently running.

It finds the names of all the running AHK programs through looking at Hidden Windows. This is done by a function that others might find useful. I have commentted this function at the end.

It then scans those AHK files for hotkeys and hotstrings.

It also scans those files for #Include and then recursively scans those files also.

It can detect compiled AHK EXE files but it can not scan them for hotkeys and those EXE would not contain any help comments so instead it looks for an AHK file with the same name as the EXE in the same location, working directory, or script directory; and scans it if found.
 
In a similar fashion Help will also look for a text file with the same names as the AHK script and get hotkey information and comments from that file if it exist. 

You can change the settings within the running script and save your settings to an INI file.

There are various settings that can be adjusted and saved to the INI file.

You can also edit the script at the top to add specific files, hotkeys, and hotstrings to ignore.

The script shows what I consider to be some intermediate techniques that others might find useful for learning.

Like using an INI file.

Creating a scrolling Gui that autosizes a control to fit the Gui window when resized.

Creating a Gui checklist and getting the information into script variables.
 
Creating multiply Gui.

Getting information about Hidden Windows to detect things like running AHK scripts.

Anyways because I am only intermediately skilled I tend to code in a verbose style that is easier to follow and might help someone else to learn something.

UPDATED: Version 2.88

Script CODE:
Spoiler

Link to CODE:
Hotkey Help.ahk
 
SAMPLE DIALOG
============================= HOTKEY HELP ============================
Win+f1                <--- Show Hotkey Help
Win+Alt+f1            <--- Change Hotkey Help Settings
Win+Ctrl+f1           <--- Display Files, Hotkeys, and Hotstrings Excluded

============================ GOOGLE SEARCH ===========================
Win+g                 <-- Google Search Highlighted Selection
Win+Ctrl+Alt+Escape   

============================= DICTIONARY =============================
Win+Alt+d             <-- Open Dictionary Input Box
Win+Ctrl+d            <-- Dictionary Search Highlighted Selection
Win+Ctrl+Alt+Escape   

========================== HOTSTRING HELPER ==========================
Win+h                 <-- Create Hotstring for Selected Text
Win+Ctrl+Alt+Escape   
HotString: pfa        = please find attached

======================== STARTUP - AUTOHOTKEY ========================
Win+Ctrl+Alt+Escape   

============================= SECURE PDF =============================
Win+Ctrl+s            <-- Secure PDF
Win+Alt+s             <-- Unsecure PDF

======================== EMAIL ATTACHMENT LIST =======================
Win+a                 <-- Add email attachment list as single line
Win+Ctrl+a            <-- Add email attachment list table
Win+Alt+a             <-- Add email attachment list table with file numbers

++++++++++++++++++++++++++++ IMAGE CAPTURE +++++++++++++++++++++++++++
PrintScreen            capture drawn rectangle
ScrollLock             capture active window
Pause                  capture active monitor
Ctrl+Escape           

+?+?+?+?+?+?+?+?+?+?+?+?+?+?+? MTGO FREE +?+?+?+?+?+?+?+?+?+?+?+?+?+?+
+-+-+-+-+-+-+-+-+-+-+-+-+-+- CLICK - TRADER +-+-+-+-+-+-+-+-+-+-+-+-+-
------------------------------ TILLAGOTO -----------------------------
------------------------------- TOOLBAR ------------------------------
---------------------------- PLATFORMREAD ----------------------------
---------------------------- COMINTERFACE ----------------------------
---------------------------- SCITEDIRECTOR ---------------------------
----------------------------- SCITEMACROS ----------------------------
---------------------------- PROFILEUPDATE ---------------------------
To get a good looking dialog it is important to put a helpful comment after every hotkey in your scripts. Preferrable in a uniform format.

I do.

#a:: ; <--- This is a Sample Hotkey

The spacing between the :: and ; is not important as the script parses for the imformation and then spaces it uniformily.

Because it is using RegEx to attempt to identify Hotkeys it can probably be fooled. It attempts to weed out things that look like hotkeys but are not like text in comments or the use of :: in weird places. 
 
Through information about values stored in variables that running scripts can be forced to report the Help attempts to evaluate the key definitions of hotkeys created with keys defined by variables.  It is not always correct though because Help can only determine the current value of a variable which may not necessarily be the same as it was when a hotkey was created using that variable. 
 
A raw view of hotkey combinations being used by all running scripts can be seen also.  This information is retrieved from the running scripts directly so contains no comments but should pickup most all current hotkeys.
 
Also the main help dialog contains buttons for Stopping, Pausing, Suspending, Editing, Reloading and Opening scripts.

A text file can also be created with the same name as an AHK script that can contain help information without having to edit the actual AHK script. Txt is the default extension but custom extensions can be defined in the variable initialization of Hotkey Help. Sometimes when dealing with other peoples scripts it is easier to just put the help comments in a txt file especially if they update the script a lot causing it having to be re-commented each time it is updated.

These text help files need to contain a hotkey definition line with :: and ; similar to an actual hotkey definition line in a script. ie.
^#a:: ; <-- ~ Word ~ Save All Files
^#a:: ; <-- ~ Adobe ~ Authorization Stamp
^#b:: ; <-- Backup
Because of all the bugs I encounter posting on this forum I am much more active here:
Hotkey Help.
 
FG

Hotkey Help - Help Dialog for Currently Running AHK Scripts                         Function - Timer - Create and Manage Timers

 

AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon


DataLife
  • Members
  • 1022 posts
  • Last active: Nov 27 2015 01:09 AM
  • Joined: 27 Apr 2008

Really useful script. I can never remember which hotkeys are assigned to which scripts. Whether I wrote them or downloaded them from the Autohotkey forum.

 

Is there a way to get this script to list hotkeys created with the hotkey command?


Check out my scripts.  (MyIpChanger) (XPSnap) (SavePictureAs) All my scripts are tested on Windows 7, AutoHotkey 32 bit Ansi unless otherwise stated.

Fanatic Guru
  • Members
  • 254 posts
  • Last active: Nov 13 2015 10:07 PM
  • Joined: 08 Jul 2011
Yes, you should have that option in the settings. It defaults to no.

If you hit Win+Alt+f1 there should be a setting called Show Created with Hotkey Command.

The very first version I uploaded did not have that option as I do not use the Hotkey command but then I added it and re-posted about an hour later.

I guess I should add a version number as I just made another minor change where I added a Trim command in one line.

Hope you find it as useful as I do.

FG

Hotkey Help - Help Dialog for Currently Running AHK Scripts                         Function - Timer - Create and Manage Timers

 

AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon


DataLife
  • Members
  • 1022 posts
  • Last active: Nov 27 2015 01:09 AM
  • Joined: 27 Apr 2008

Here are the active hotkeys for tillagoto

 

Hotkey, IfWinActive   
Hotkey, %uSummonGUI%  
Hotkey, If            
Hotkey, %uSummonGUI%  
Hotkey, %uGotoDef%    
Hotkey, %uGoBack%     
Hotkey, %uGoForward%  
Hotkey, IfWinActive   Make sure it'll be a variant and not override a current shortcut
Hotkey, % s           Using SummonGUI only to test

 

Notice that it is only showing the variable and not the hotkey.


Check out my scripts.  (MyIpChanger) (XPSnap) (SavePictureAs) All my scripts are tested on Windows 7, AutoHotkey 32 bit Ansi unless otherwise stated.

Fanatic Guru
  • Members
  • 254 posts
  • Last active: Nov 13 2015 10:07 PM
  • Joined: 08 Jul 2011
The variable is the hotkey. It is using dynamic hotkeys that are determined and assigned while the script is running.

Since this script is only parse the files for hotkeys and not actually accessing any internal operating list of hotkeys there is no way for this script to know what the content of those variables were when the hotkey was dynamically created.

Even if it was accessing an internal operating list of hotkeys it would be difficult to match those hotkeys up with the hotkey command that created them to get the help information from the comments on those lines.

In some cases it may not even be a key combination but a condition that triggers the hotkey like IfWinActive.

I have yet to discover a way to access an internal operating list of hotkeys or variables for all AHK scripts running. I image it is possible with the right information but I have been unable to find any method for doing it on the forums.

This lack of ability to access a hotkey list directly is the reason for the script file parsing method.

In general the hotkey command is used to create dynamic hotkeys using variables. That is the reason I do not showing them by default.

FG

Hotkey Help - Help Dialog for Currently Running AHK Scripts                         Function - Timer - Create and Manage Timers

 

AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon


ozzii
  • Members
  • 167 posts
  • Last active: Oct 30 2015 04:54 PM
  • Joined: 23 Mar 2011

Hi,

When I disable the hotstring I still have some:

:?*:
:*?:
:c*?:

I think that the easiest way to not showing it, it's to not taking lines who begin with ":"

 

 

EDIT: another thing that I just saw

I have this for a starting script:

#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%
#NoTrayIcon
#SingleInstance force

Run, AutoCorrect.ahk
;Run, Hotkey Help.ahk

#Include <Hotkey Help>
#Include <tf>

The result is

-------------------------------- START -------------------------------
---------------------------- <HOTKEY HELP> ---------------------------
-------------------------------- <TF> --------------------------------

But when I disable the include and enable the Run, I can saw the hotstrings of hotkey helper.



DataLife
  • Members
  • 1022 posts
  • Last active: Nov 27 2015 01:09 AM
  • Joined: 27 Apr 2008

The variable is the hotkey. It is using dynamic hotkeys that are determined and assigned while the script is running.

Since this script is only parse the files for hotkeys and not actually accessing any internal operating list of hotkeys there is no way for this script to know what the content of those variables were when the hotkey was dynamically created.

Even if it was accessing an internal operating list of hotkeys it would be difficult to match those hotkeys up with the hotkey command that created them to get the help information from the comments on those lines.

In some cases it may not even be a key combination but a condition that triggers the hotkey like IfWinActive.

I have yet to discover a way to access an internal operating list of hotkeys or variables for all AHK scripts running. I image it is possible with the right information but I have been unable to find any method for doing it on the forums.

This lack of ability to access a hotkey list directly is the reason for the script file parsing method.

In general the hotkey command is used to create dynamic hotkeys using variables. That is the reason I do not showing them by default.

FG

I write my dynamic hotkeys to an ini file.

 

I could possibly do this....

 

Add code to the beginning your script to read my ini file and then use fileappend to create a temporary ahk script and run it, then your script will automatically read my hotkeys. I then would kill the temporary script after your script is finished.


Check out my scripts.  (MyIpChanger) (XPSnap) (SavePictureAs) All my scripts are tested on Windows 7, AutoHotkey 32 bit Ansi unless otherwise stated.

Fanatic Guru
  • Members
  • 254 posts
  • Last active: Nov 13 2015 10:07 PM
  • Joined: 08 Jul 2011

Hi,
When I disable the hotstring I still have some:

:?*:
:*?:
:c*?:
I think that the easiest way to not showing it, it's to not taking lines who begin with ":"
 
 
EDIT: another thing that I just saw
I have this for a starting script:
#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%
#NoTrayIcon
#SingleInstance force

Run, AutoCorrect.ahk
;Run, Hotkey Help.ahk

#Include <Hotkey Help>
#Include <tf>
The result is
-------------------------------- START -------------------------------
---------------------------- <HOTKEY HELP> ---------------------------
-------------------------------- <TF> --------------------------------
But when I disable the include and enable the Run, I can saw the hotstrings of hotkey helper.


I did not consider wildcards in the hotstrings. I can fix that.

You can not #include Hotkey Help because it has a Top of the Script section called the Auto-Execute Section. This Auto-Execute Section basically extends from the top of the script to the first Hotkey.

#include just interjects another scripts code exactly where the #include command is located.

If you do:

#include ThisScript.ahk
#include ThatScript.ahk

You end up with something like:

; ThisScript
[Auto-Execute Section]
[Hotkeys]
; ThatScript
[Auto-Execute Section]
[Hotkeys]

The [Auto-Execute Section] of ThatScript will never get executed.

Basically scripts with [Auto-Execute Section] need to be executed with Run. Run is generally used for independent scripts. Include is generally used for functions or scripts that need to share information and are designed to work together in some way.

Many scripts will not work correctly with #include.

FG

Hotkey Help - Help Dialog for Currently Running AHK Scripts                         Function - Timer - Create and Manage Timers

 

AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon


Fanatic Guru
  • Members
  • 254 posts
  • Last active: Nov 13 2015 10:07 PM
  • Joined: 08 Jul 2011

DataLife, on 29 May 2013 - 09:50 AM, said:
I write my dynamic hotkeys to an ini file.

I could possibly do this....

Add code to the beginning your script to read my ini file and then use fileappend to create a temporary ahk script and run it, then your script will automatically read my hotkeys. I then would kill the temporary script after your script is finished.

You would not need to actually run your "dummy" ahk script. You could create a ahk script file that contains hotkeys and help information. It does not have to be in a format that would even be executable.

Something like:

a:: ; Help Information for Hotkey A
b:: ; Help Information for Hotkey B
c:: ; Help Information for Hotkey C
d:: ; Help Information for Hotkey D

Then right after the line:

Scripts_List := AHK_Paths("Scripts") ; Get Path of all AHK Scripts

Add:

Scripts.Insert("Dummy Hotkey Help.ahk")

Basically your dummy ahk file gets added to the list of running ahk files to scan even though it is not running.

I think I will add something like this. The ability to designate files even just a text file to scan and include in the help dialog even if they are not running.

This will provide a way to include things in the help dialog that might want to be added by the user.

I may just have it look for a text file with the same name as each AHK running and include the txt file in the scan if it exist. Then if necessary the user could create a custom text file with help. This would be good for scripts they did not write and do not want to alter by adding comments to all the hotkey assignments within the actual script. They could just do all the help information in a separate and simple text file.

I am going to play around with some stuff and see what I can come up with.

FG

Hotkey Help - Help Dialog for Currently Running AHK Scripts                         Function - Timer - Create and Manage Timers

 

AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon


DataLife
  • Members
  • 1022 posts
  • Last active: Nov 27 2015 01:09 AM
  • Joined: 27 Apr 2008

I may just have it look for a text file with the same name as each AHK running and include the txt file in the scan if it exist. Then if necessary the user could create a custom text file with help. This would be good for scripts they did not write and do not want to alter by adding comments to all the hotkey assignments within the actual script. They could just do all the help information in a separate and simple text file.

I am going to play around with some stuff and see what I can come up with.

FG

that is a great idea.


Check out my scripts.  (MyIpChanger) (XPSnap) (SavePictureAs) All my scripts are tested on Windows 7, AutoHotkey 32 bit Ansi unless otherwise stated.

ozzii
  • Members
  • 167 posts
  • Last active: Oct 30 2015 04:54 PM
  • Joined: 23 Mar 2011
I did not consider wildcards in the hotstrings. I can fix that.

Thanks in advance.

 

 

Basically scripts with [Auto-Execute Section] need to be executed with Run. Run is generally used for independent scripts. Include is generally used for functions or scripts that need to share information and are designed to work together in some way.

Thanks for the explanation.



Fanatic Guru
  • Members
  • 254 posts
  • Last active: Nov 13 2015 10:07 PM
  • Joined: 08 Jul 2011
I Updated the code in the first post to Version 2.0.

Changes Log (Version 2.0):
Information Stored in Array
Fixed Problem with detecting hotstrings with options
Fixed a Trim that was leaving spaces where not wanted
Added option to scan a text file with the same name as running script for help information
Added option to edit excluded scripts and hotkeys in a Gui and save that information to the Ini


The result does not look much different but I changed the code a lot.

The original script created the dialog string that it was going to display as the script files were being scanned. This became unwieldy as more options were added and was problematic for deleting duplicates.

The script now gets all the information and stores it in one array then after it has all the information creates the dialog string to display. It is much cleaner to handle what to display depending on options at that point.

Also the ability to have a text file with the same name as the script is useful for situations where you want to add help information for each hotkey but do not want to mess with the actual scripts. Maybe because it is an EXE or someone elses script that would lose commenting if you redownload or update.

The information just has to be in the standard format of a hotkey but does not actually have to be executable.

#h:: ;<<-- Text Help for Win+H
Win+d:: ;<<-- Text Help for Win+D
You can use a slightly different help format like <<-- as opposed to <-- if you want to be able to tell if the help is coming from within the script or from a text help file.

FG

Hotkey Help - Help Dialog for Currently Running AHK Scripts                         Function - Timer - Create and Manage Timers

 

AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon


ozzii
  • Members
  • 167 posts
  • Last active: Oct 30 2015 04:54 PM
  • Joined: 23 Mar 2011

Thanks for the update.

 

A little thing:

In my script I have an input and a gui with "::" inside.

These lines are showed in the list...



Fanatic Guru
  • Members
  • 254 posts
  • Last active: Nov 13 2015 10:07 PM
  • Joined: 08 Jul 2011
You could possible include what ever "hotkey" is being created by mistake in the Exclude list to keep them from showing.

Also if you can post the lines from the script that are fooling the RegEx I can probably modify the RegEx to be smarter.

FG

Hotkey Help - Help Dialog for Currently Running AHK Scripts                         Function - Timer - Create and Manage Timers

 

AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon


ozzii
  • Members
  • 167 posts
  • Last active: Oct 30 2015 04:54 PM
  • Joined: 23 Mar 2011
Here is the line:
 
Gui,Add,Button,xs+160 gGui10BTOK, ..:: Close ::..
 
other example:
InputBox, Hotstring, Nouveau mot, MOT ENTIER`t`t::tset::test!^a`nN'IMPORTE OÙ`t`t:*?:aten::atten!^a`nATTENTION À LA CASE`t:C*?:!ae::æ!^a`n`t`t`t:C:serbian::Serbian!^a,,,,,,,, ::%Hotstring%::%Hotstring%!^a