AHK tools, general useful items

I’ve been exploring AHK a bit further, specifically in the area of using GUI’s to use an interface to help access information and do things. After looking at a few tutorials on YT I think I’ll need to get my head around some functions. As you need to action some sort of action to a GUI item.

AHK GUI interface tools

There are some good video courses out there and a couple of tools for creating the actual GUI interface. The first is AutoGUI, but that would not run on my Surface Book as the resolution was too high and just shut down. Also you download it from Sourceforge and it’s a .7z zip file that I had to unzip online.

The other tool is SmartGui Creator. Another Drag/drop and size interface then you cut/paste the GUI code into your script and start linking to it with your code.

Another I found on pastebin AHK GUI Creator is also quite nice, very simple.

AHK Link creator

I saw someone in a video use a pop up box to create a link. There is this article on the topic, but I wanted a pop-up box so that I could add the URL in and then another box to put the text I wanted to be the link so created the Alt+1 code that adapted the code from the article above which is sort of Alt+2:

!1::  ;Alt+1
  Sleep, 100
  InputBox, UrlLink, "New Link", "Put a new URL in box ""
  InputBox, Texty, "New Text", "Put a Word/String for what you want to read"
  ;nTab:= ""target="_blank"""
  Sleep, 50
  clipurl := "<a href=""" UrlLink """ ><strong >" Texty "</strong></a>"
  SendInput {Raw}%clipurl%
; First copy URL, it goes to clipboard
; Next Select text you want to make the link to
!2:: ;Alt+2
  Sleep, 100
  clipurl := clipboard ; This takes URL from clipbd and assigns to var
  Send, ^c ; This copies the selected/highlighted text in the doc, again to clipboard (so overwrites the URL)
  Sleep, 50
  ;clipurla := "<a href=""" . clipurl . """>" . clipboard . "</a>"
  clipurla := "<a href=""" clipurl """><strong >" clipboard "</strong></a>"
  SendInput {Raw}%clipurla%
  clipboard := clipurl
  clipurl =;

It only works in my Emails when I’m in HTML tab. In Notepad, if I save as .html it will work there too. So, you have to be in programme where you want the text to be written, then hit Alt+1 (my Hotkey, popup box for link, then after OK another popup box for Title, then on Ok for that box it creates the string you can paste into HTML for it to work.

<a href="C:\Users\drake\Downloads\______Screenshots\2021-01-20 12_13_13-_New Text_.jpg" ><strong >The big wahoony</strong></a>

There is also a button in HTML to use instead, I’m thinking of trying this out with signature for emails, with buttons instead of links:

 <button onclick="document.location='https://www.w3schools.com/html/html_links.asp'">HTML Tutorial</button> 

An elaboration on this is to create a Button for people to click to go to:

!3:: ;Be in Text area Put a new URL in box (OK) Put a Word/String for what you want to read (OK)
  { Sleep, 100
    InputBox, UrlLink, "New Link", "Put a new URL in box ""
    InputBox, Texty, "New Text", "Put a Word/String for what you want to read"
    Sleep, 50
    clipurl := "<a href=""" UrlLink """ "
    Sleep, 50
    SendInput {Raw}%clipurl%
    sleep 100
    SendRaw, style="background-color:#5a19ae;color:#ffffff;display:inline-block;font-family:sans-serif;font-size:13px;font-weight:bold;line-height:20px;text-align:center;text-decoration:none;width:150px;-webkit-text-size-adjust:none;"  
    sleep 100
    SendRaw, > %Texty% </a> 

That took a while to sort out, raw coding in VS Code didn’t work when I transferred to Email, but I found this handy page to make Buttons. It works like a charm.

I also used the #include to link my URL script to my main key page. That’s handy as I can Comment it out and use it when I want.

I’ve now got it set up as a Full Signature in CopyTexy & also a HtoKey for pasting it into emails. The HotKey paste is quite slow, CopyPasty is a lot faster. You do have to remember to jump back out of HTML tab in Thunderbird before you can send, so I’m wondering if I can add that to the AHK script to make it more robust. This tripped me up when I was testing the email as I had the buttons adjacent to reach other, but on the mobile it looked really untidy, so I rearranged them down the LH side so they look great on a mobile, nice and simple. I put spaces between so easy to click on individual buttons.

Also have the phone number that you press button on mobile and it rings the number, cool

AHK AutoCorrect

AutoCorrect is a cool tool that I’m starting to play with. It corrects mis-spellings, so you select text and hit (currently Shift+1) and it shows you the mis-spelt word and then you can put in the record. Only thing is it doesn’t seem to automatically correct after doing it. So I need to delve into it a bit more. (It seems double tap on spacebar works, but that’s not logical)

Some useful Calls with “A_” variables

There was a YouTube Video that showed a cyclin f a proramme such as Explorer with a hotkey, so that

; This is a script that will always go to The last explorer window you had open.
; If explorer is already active, it will go to the NEXT last Explorer window you had open.
; CTRL Numpad2 is pressed with a single button stoke from my logitech G15 keyboard -- Macro key 17. 
; from vid https://www.youtube.com/watch?v=OqyQABySV8k
  IfWinNotExist, ahk_class CabinetWClass
    Run, explorer.exe
  GroupAdd, taranexplorers, ahk_class CabinetWClass
  if WinActive("ahk_exe explorer.exe")
    GroupActivate, taranexplorers, r
    WinActivate ahk_class CabinetWClass ;you have to use WinActivatebottom if you didn't create a window group.

based on this video:

Some more cool things I’ve been playing with is calling system variables such as Computer name & time, and structuring time/date to suit requirements. This is a good video:

Some code I’ve been playing with:

  ; a group of Built-in variables of AHK  https://www.autohotkey.com/docs/Variables.htm#Intro
  ; vid for good AHK  current time format  https://www.youtube.com/watch?v=l4wm4dObhF4
  SendInput, %A_UserName% `n ; username on pc
  ;SendInput, %A_IPAddress% `n
  SendInput, %A_IPAddress1% `n ; IP address 1
  SendInput, %A_IPAddress2% `n
  SendInput, %A_IPAddress3% `n
  SendInput, %A_IPAddress4% `n
  SendInput, %A_AppData% `n ; path to app data
  SendInput, %A_StartMenu% `n ; path to start menu folder
  sendraw, "Does user have Admin rights? 1 if admin rights else 0"`n
  SendInput, %A_IsAdmin% `n ; 1 if admin rigts else 0
  sendraw, "primary screen width"`n
  SendInput, %A_ScreenWidth% `n ; screen width
  sendraw, "primary screen height"`n
  SendInput, %A_ScreenHeight% `n ;screen ht
  SendInput, %A_ComputerName% `n`n ; comp name
  SendInput, %A_AhkPath% `n ; path to programme
  SendInput, %A_NowUTC% `n ; UTC Now
  SendInput, %A_Now% `n ; Now
  FormatTime, CurrentDateTime,,yyy-MM-dd 
  SendInput, %CurrentDateTime% `n ; current date formats yyy-mm-dd
  FormatTime, CurrentDateTime,,yyy-MM-dd hh:mm:ss
  SendInput, %CurrentDateTime% `n ; current date/time formats yyy-mm-dd & Time
  FormatTime, CurrentDateTime,,yyy-MM-dd h:mm tt
  SendInput, %CurrentDateTime% `n ; current date/time formats yyy-mm-dd & Time in AM/PM
  FormatTime, CurrentDateTime,,dddd,MMMM d, yyyy
  SendInput, %CurrentDateTime% `n `n ; current date/time formats long format
  sendraw, "caret x location"`n
  SendInput, %A_CaretX% `n ; ceret in text file - where x is 
  sendraw, "caret y location"`n
  SendInput, %A_CaretY% `n ; ceret in text file - where y is 
  FormatTime, CurrentDateTime,,dddd,MMMM d, yyyy
  SendInput, %CurrentDateTime% `n `n ; current date formats long format
  FormatTime, CurrentDateTime,,yyy-MM-dd h:mm tt
  SendInput, %CurrentDateTime% `n ; current date/time formats yyy-mm-dd & Time in AM/PM
  FormatTime, CurrentDateTime,,yyy-MM-dd 
  SendInput, %CurrentDateTime% `n ; current date formats yyy-mm-dd

Some useful stuff, not sure yet where I’d use some of them, but date is good for ReadMe files so you know when you’ve written a note. Also good for file named where I add Date to file name.

Organising AHK files

I though this gentleman’s video’s on organising AHK files is pretty good. I’m going to start structuring my files that way as it makes them far easier to scan and read.

Also another videos on Keyboard & mouse combo hotkeys:

Help files

I want to create a dedicated hotkey for a help file message box for each Script, just saying what keys are used and what they do. Something Like Ctrl + F1 say, so you can check what codes are running. Maybe conflict between running files so maybe ^F2,^F3 etc.

As I’m using #Include in my main AHK script I have added a help button at Ctrl+8 with reference to hotkeys in the main file and also to the linked file, so I can use them whilst only running this one. Handy when you can’t remember Hotkeys. Also just use Ctrl+7 to refresh the file, even if I’m only updating the linked file.

AHK Access, Pause, Suspend & refresh/Reload

Access. I have AHK pinned to my task bar, clicking on it opens browser to doc page, but right clicking on it allows me to pin some AHK scripts to the top, so they are easy to find to start if I’ve shut them down and want to restart them, I don’t have to go looking to the directory to double click on them.

Pause & Suspend Hotkeys. In the Taskbar Tray you can pause or suspend hotkeys of a particular script by right clicking on them and selecting choice and the Icon changes to denote its new status.

This is particularly handy if you have a buggy script and you’ve utilsed a key , say Shift +R so that Capital R does not work in a Text doc, you can suspend hotkeys in different scripts to identify where the bug is originating from.

Reload Script. This is something that I want on a HotKey so that I can refresh the script when it gets buggy. A handy way to reload without delving into the Taskbar Tray.

#Include, functions() & Excel

These are something I want to get used to using.

#include, for pulling in files to use them in other files

Functions() for bunching up processes into one item that can be called. You can send user variables to functions and get them to return manipulated data.

Excel. Just for linking data to an Excel file. Actually, I wonder if my 3DPDF CSV download could go into a AHK script to do the processing for the data instead of VBA.

End comment

There are some great tools out there to help you code some macro’s. Now I need some idea’s of things I want to create macro’s for.

The few simple ones I use all work, but I need to start developing some more tools to increase productivity, and also get familiar with the new ones I’ve found.

I think the structuring of the files so that they are more organized is a good start, a style & structure that is easy to read and access. It will definitely be good for cross-referencing different files, especially with HotKeys and Abbreviation keys

Thank you for your interest & attention.