r/AutoHotkey • • Dec 05 '21

Well guys, I did it. I think I just automated 3 hours per day of my work from home job.

259 Upvotes

Got a 14 month project that involves pulling equipment fleet information from two different sources into a spreadsheet, and then fixing the entries in source B to match source A in the database program. Started with a couple simple shortcuts that clicked and copy/pasted, linked them together with if WinActive and WinWaitActive statements... and added actions to move on to the next line if problems occur. There's still a lot to do manually and some thinking that goes into tricky ones.... but all of the tedious grind is gone! I can spend hours a day learning new scripting languages/skills, housework, and even just napping/video games if I'm feeling like it!

Thank you to this community for all the help you've offered over the past 2 years, AHK is amazing and I'm so glad I found it!

To those headed down my path: not to get all r/antiwork, but whatever you do, don't tell your coworkers or boss. They won't appreciate it and DEFINITELY won't reward you financially. I tried that last time and it got me jack shit. Better to take the extra time and use it to pay yourself in either work/life balance or new skill acquisition.


r/AutoHotkey • • Apr 17 '16

Read This Before Posting!

216 Upvotes

Welcome to the AutoHotkey Subreddit!

Hopefully, you're here with questions on how to learn this fantastic scripting language. There are plenty of knowledgeable folks here that can help you out.

Update 2016-10-01 I took an opportunity to do a bunch of updating. I've expanded the text editor section to include multiple options, as well as another GUI creator and multiple other addons/plugins. I also pre-packed Notepad++ and Sublime to be compatible with AHK.
I've also added a section about formatting code when submitting to Reddit. A lot of people skip the instructions right before submission so hopefully they'll see it here instead.

 

  ------------------------------------------------
  | Make sure that you read through all of this. |
  ------------------------------------------------

Thanking People [Serious]:

(I actually felt this needed to be moved to the top as it's constantly ignored)

People, please be respectful of each other and thankful for help received.

This is a community based on free help that is paid for with sacrificed free time.
If someone takes the time to help you out with your problem, take 5 seconds to acknowledge it. Typing thank you and clicking an up vote costs you a few insignificant seconds and it means a lot to someone who spent their free time coming up with a solution to your problem. Respect

In the event that you want to thank someone past that (maybe they went above and beyond in helping you, or got you out of a pinch, or helped you look good in front of your boss, etc.), you can always gift them some Reddit gold.


HELP with a Script vs MAKE Me a Script:

If you're here to learn and you're providing your own attempt at the code, the people here will be much more inclined to help.

Alternately, if you come here with absolutely no intent of learning how to write scripts and you make posts begging for others to write the code for you, don't be surprised when people aren't as accommodating.

Remember, you're asking people to sacrifice their free time to make a script for you.

"Give a man a fish and he eats for a day.
Teach a man to fish and he eats for life."

The majority of people that help out on this subreddit are here to teach people how to fish, not to fish for them.

If you do want to request someone make a script for you, keep in mind that the simpler the script, the more likely someone will do it.


How to ask a question:

Be clear about your request. The more detail, the better.

  • What key(s) do you want to use?

  • What EXACTLY do you want this script to do? From start to finish.

  • Are there any timing issues to take into account?

  • Is there something specific that you don't want to have happen?

  • Do you only want it to happen in a specific program?

It's easier for us to help you if we fully understand what you're talking about.

Here is a good example and a bad example of how to describe something:

Bad Example:
"I'm trying to make a script where I press a button, it sends a code to my game, and then a short while later it sends another thing".

No idea what you want. Vagueness is a horrible thing.

Good Example:
"I'm trying to make a script for a game called Street Fighter.
I want to press the A button on my keyboard and have it send Down, Down+Right, Right, And Numpad4. This activates a special move in the game. There needs to be about 50 milliseconds between each key press.
Then after it sends that I want it to press and hold down Numpad9 until I let go of 'a'."


Formatting code when submitting:

When submitting code, you need to format it so it displays correctly.
Formatting makes your text display in monospace font and treats all text as text only. Special characters and special formatting get disabled.

To format a block of code, make sure you have an empty line, paste your code, and put 4 spaces (or a tab) at the beginning of each line.

    Code with 4 spaces before it

Code with 4 spaces before it

Faster ways of doing many lines:

  • Most text editors will let you highlight your text and press tab. This will put a tab indent in front of everything.

  • If you have Reddit Enhancement Suite, highlight your code and press the <> code button.

  • If you're using New Reddit (not my thing but no judgments) there's a similar code button that looks like a box with a T. If you don't see it, check under the ... option.

To do inline code formatting (small, single line snippets of code), especially inside text, put the code between grave accents `.
This: One `two` three
Becomes: One two three

Do not try to do multiple lines of code with grave accents. Do not use single quotes '. Neither work.


Useful Editors, GUI Creators, Plugins, etc...

What's the best editor to write AHK in?

There is no correct answer to this. Many people who try SciTE4AutoHotkey think it's one of the best AHK editors out there. Others try it and dislike it. I've updated this list to have a robust selection of editors that will work with AHK.


SciTE4AutoHotkey [Download]

Preview

Features:

  • Syntax highlighting

  • Code folding

  • Calltips (also known as IntelliSense)

  • AutoComplete

  • AutoIndent

  • AutoHotkey help integration

  • Abbreviations

  • Debugging support

  • Tools for AutoHotkey scripting

  • A toolbar that enables easy access to the tools

  • Includes a GUI Creator and Message Box Creator

This is the editor I use for all my AHK coding.

SciTE4AutoHotkey Main Page
SciTE4AutoHotkey GitHub Repository
SciTE4AutoHotkey Mirror - v3.0.06.01 - Use this if Chrome is giving you problems getting to the Main Page.

Bonus:

Link to my personal "Style Settings"
Preview
It's a dark theme with colorful syntax. Predominantly green and white on a black background.
It's based on the "HatOfGod" theme created by budRich.
Included is a syntax preview file so you can see how the coloring looks (same one in the preview above).

It should be noted I've also commented out a lot of the style settings so you can go in and modify it to your own likings.


AHK Studio (Suggested by gymcap) [Download]

Preview

Features

  • Run scripts from the File/Run or File/Run x64 (for those who use the 32 bit install).

  • Easy customization of themes Edit/Theme with a few that have been created by users. I will gladly add any themes that are submitted to me.

  • Automatic help text for most commands (eg MsgBox, Control, SplashText...etc).

  • Code Vault for adding code snippets to the program.

  • Version Tracker with Github upload.

  • Gist post your scripts.

  • Split up projects into Segments to keep things neat under File/New Segment. (makes an include file)

  • Special functions (Move Selected Lines Down, Create Comment Block, Character Count...etc)

  • Msgbox Creator for easily creating more complex msgboxs.

  • Personal Variable List: You can add anything to this list and it will come up with the list of other commands as you type them.

  • Custom Highlight List: You can add anything to this list as well and it will change the color that it appears in the program.

  • Customize every action with a hotkey, many of them are already assigned but they can be changed under Edit/Settings.

  • FTP integration.

  • Auto Close: by default when typing, it will add the closing symbol to the following: < ' [ { ( making them into <> ' ' [] {} ()

GitHub Link

AHK Forum Post

Bonus: GUI Creator

I'm a huge fan of SciTE4AutoHotkey and SmartGUI (the GUI creator that comes with it), but after using this for a bit, I have to say this creator is on par with, if not superior, to SmartGUI.

If you're doing anything with GUI creation, I STRONGLY urge you to try both GUI building tools and find out which one you like more. Hopefully, Maestrith (the awesome creator of this) will merge some of SmartGUI's very useful features into his program, making an inarguable "best AHK GUI creator".


Notepad++ [Download]

Preview with AHK Syntax Highlighting

Features:

  • Syntax Highlighting and Syntax Folding

  • User Defined Syntax Highlighting and Folding: screenshot 1, screenshot 2, screenshot 3 and screenshot 4

  • PCRE (Perl Compatible Regular Expression) Search/Replace

  • GUI entirely customizable: minimalist, tab with close button, multi-line tab, vertical tab and vertical document list

  • Document Map

  • Auto-completion: Word completion, Function completion and Function parameters hint

  • Multi-Document (Tab interface)

  • Multi-View

  • WYSIWYG (Printing)

  • Zoom in and zoom out

  • Multi-Language environment supported

  • Bookmark

  • Macro recording and playback

  • Launch with different arguments

How to customize Notepad++

I took the liberty of getting the portable version of Notepad++ (v7), and then added AHK syntax highlighting, auto-completion, and many of the other addons mentioned in the "How to customize Notepad++" link above.

I've combined it all into:
Notepad++ v7 32bit with AHK Support.zip
Download, unzip, and run Notepad++. Enjoy.


Sublime Text [Download]

Preview with AHK Support

Sublime text is an incredibly powerful text editor. I mean VERY powerful. The only drawback (for myself) is that it doesn't natively support AHK and I haven't found user made support for it that makes me want it more than SciTE. That aside, it IS fantastic and should be on your list of text editors to try (even if it's not for AHK).

Features:
I'm not trying to be lazy, but I'd STRONGLY recommend opening this page and reading the features posted there as well as watching the multiple gifs they have at the top of the page. They're pretty impressive.

If you're not a power user or you're really new to scripting, you may get the full benefit of this editor.

https://github.com/ahkscript/SublimeAutoHotkey

Again, I've gotten the portable version (v3 build 3126), installed AHK syntax highlighting/autocomplete/etc from the GitHub repository above, and packaged it into an "Unzip and run" file.

Sublime Text 3 with AHK support


Atom [Download]

Preview (Cescue's AHK Plug-In)

Atom is a free and open-source test/source code editor for Windows (as well as Mac and Linux).

Features:

  • Cross-platform: Works on OS X, Windows, and Linux.

  • Package manager (Atom Packages): Thousands of plugins that can be searched and installed from inside the program.

  • Autocompletion: An extensive autocomplete system for (almost) every language out there.

  • File system browser: The filetree and fuzzy finder make opening projects and files easy.

  • Multiple panes: Split your workspace into multiple panes to compare and edit code across files.

Normally, I'd pre-package this with the AutoHotkey packages.
However, Atom has a built-in search and install function that makes doing this easy. Its shown on the welcome screen, or you can do it manually by clicking Settings (Ctrl+Comma) > Install. From there you can search/install the AutoHotkey packages.

Note: At the time of me posting this, there were 2 different AHK packages available.
When trying to install the first one (written by nshakin), it errored out.
The second one (written by cescue) installed without any issue.


EditPad Pro [Download]

This and Sublime are my personal favorite text editors of all time and this is a shameless plug.

That being said, when it comes to writing .AHK files, this is probably the weakest choice of all the options provided.

Just because it's not strong in AHK doesn't mean it's not strong for other things, especially its search and replace function. Get it and use it for other languages/basic text manipulation, or use it for doing fantastic search and replaces.

While custom AHK syntax highlighting has been made for EditPad, it hasn't been maintained or updated in over 4 years.

 


New Script Template

This is a copy of the template I use to make almost all of my scripts.
It includes a lot of the same commands you'll see yourself typing into most scripts. Just a time saver.
Also, it includes auto-script reloading when saving using Ctrl+S and a quick suspend/quick kill hotkey combo (Ctrl+Esc).

Template


Connecting to IRC

If you have no IRC client installed and don't want to install one, there's Kiwi IRC.
Just fill in a nickname and hit Start.

Connection details:

Server:		chat.freenode.net
Port:		6667 (6697 for SSL)
Channel: 	#ahkscript

Check out the official forum thread for more information about IRC clients and discussions.


Common problems/requests:

This is a list of very common requests we see.
Please make sure you read through here before posting.

If the solution to your question is on this page, your post will be removed.

Contents:

    1) Creating a Toggle
    2) Holding Down a Key / Autofire
    3) One Key Activates Two Others
    4) Saving Data
        -To Text File
        -To .ini File
        -To .ini Section Inside a Script
    5) Starting/Stopping Things (Loops vs SetTimers)
    6) Finding Out What Button You're Pressing (JoyPad, Random Keyboard Keys, Surface Pro Stylus, etc...)
        -Keyboard Hook Method
        -Script for Detecting Scan Codes
        -Joypad Button and Axis Detection Script

    7) Making Certain Things Only Work in Specified Programs (WindowSpy!)
    8) Sending a Keystroke or Mouse Event to an Inactive Window

 


1) Creating a Toggle

If you're looking for a way to toggle things on and off, here's how you make a toggle using a variable.

; While you don't have to declare the toggle, by doing so you know what the initial start value is
toggle	:= 0

return

F1::
	; This is where the toggling occurs. You're setting the toggle to the opposite of itself.
	; 1 becomes 0. True becomes False. You can use either.
	toggle	:= !toggle

	if (toggle = 0){
		; If the toggle is off (0 or false), do the stuff in here
		MsgBox, The toggle is turned off.
	}
	else{
		; If the toggle is on (1 or true), do the stuff in here
		MsgBox, The toggle is turned on.
	}

return

Variables
If (expression)
Boolean
Operators


2) Holding Down a Key / Autofire

How to make a key "autofire" when a key is held down.

Edit: Don't use loops/while-loops for auto-fire. The original method posted here was how I first learned. While it does work, I later learned it can cause problems in a script. Especially when 2 loops try to run at the same time.
The more appropriate way of doing this is to use SetTimer.

This example shows how to make the 'a' key fire the 'b' key repeatedly.

; The hook $ hotkey modifier prevents a hotkey from firing itself.
; If 'a' is the hotkey, and it sends 'a', it would keep looping
$a::
	; Run the label AutoFireA
	GoSub, AutoFireA
return

; Label auto firing
AutoFireA:
	; Send a key. We're using 'b'
	Send, b
	; Check to see if 'a' is still being held down
	if GetKeyState("a", "P")
		; If yes, set a timer to run this label again. Time is in ms
		; Using a negative number fires the timer once instead of repeatedly.
		SetTimer, AutoFireA, -100
return

Hotkey Symbols
Gosub
Label
SetTimer
GetKeyState
Send


3) One Key Activates Two Others

If you want to send multiple keystrokes from 1 key, this is how you do it:
Please make sure you read example #2 (above) for explanations of when to use ~ and $ at the beginning of a hotkey.

; When you press "a", the keys "b" and "c" are pushed
a::
	Send, bc
return

Hotkey
Send


4) Saving Data

Option 1 - To a Text File:

; Numpad+ to add 1 to the counter
NumpadAdd::
	counter++
	; There's no delete line for file append so you have to delete the whole file
	; Then re-create it again to update the counter.
	; %A_Temp% is a built in variable that points to your profile's temp folder
	FileDelete, %A_Temp%\counter.txt
	FileAppend, %counter%, %A_Temp%\counter.txt
return

; Numpad- to subtract 1 from the counter
NumpadSub::
	counter--
	FileDelete, %A_Temp%\counter.txt
	FileAppend, %counter%, %A_Temp%\counter.txt
return

FileDelete
FileAppend
Built-In Variables


Option 2 - To a .ini File:

; Numpad+ adds 1 to the counter stored in the .ini file.
NumpadAdd::
	counter++
	; There's no delete line for file append so you have to delete the whole file
	; Then recrecreate it again to update the counter.
	IniWrite, %counter%, %A_Temp%\counter.ini, Counter Section, Counter
return

; Numpad- to subtract 1 from the counter stored in the ini file.
NumpadSub::
	counter--
	IniWrite, %counter%, %A_Temp%\counter.ini, Counter Section, Counter
return

IniRead
IniWrite
IniDelete
Built-In Variables


Option 3 - To a .ini section inside the script:

Note: This will not work for scripts compiled into executables.

;============================== Start Auto-Execution Section ==============================
; When the script starts, it reads the counter key of the SavedVariables section
; stored in this script. This helps "remember" the value of counter.
IniRead, counter, %A_ScriptFullPath%, SavedVariables, counter

return

;============================== Main Script ==============================
; Numpad+ adds 1 to the counter stored in the ini section at the end of this script.
NumpadAdd::
	counter++
	; This will write the current counter to the counter key in the SavedVariables section
	; of this script.
	IniWrite, %counter%, %A_ScriptFullPath%, SavedVariables, counter
return

; You can put your ini section inside of a multi-line comment.
; Start with a /* and end with a */

/*
This is an ini saved variable section.
You can write whatever you want here because AHK sees it as a comment.
Anything [insideBrackets] starts a new section. This is what the script looks for when dealing with ini files.
[SavedVariables]
counter=0
*/
;============================== End Script ==============================

IniRead
IniWrite
IniDelete
Built-In Variables


5) Starting/Stopping Things (Loops vs SetTimers)

Loops are great when you know you want something to run infinitely or want it to run a set number of times. But for starting and stopping a script, SetTimer is a much better choice over Loops with breaks.

With SetTimer, you can make very easy On/Off hotkeys, and you have control over how often the loop happens.

This script makes a message box that says "Hello!" pop up every 20 seconds.
F1 starts it. F2 stops it.

; Start timer. It'll run the helloPopUp label every 20 seconds.
F1::
	SetTimer, helloPopUp, 20000
return

; Stop the popup timer.
F2::
	SetTimer, helloPopUp, Off
return

helloPopUp:
	MsgBox Hello!
return

SetTimer
Label

Here's an example of the same script using a loop with an if-break statement. It works the same, but it's bulky and sometimes the breaks don't quite work like you want them to. That's why I advise people to use SetTimers unless the loop needs to run forever or run a certain amount of times.

F1::
	breaker := false
	Loop
	{
		if (breaker = true){
			break
		}
		Sleep, 20000
		MsgBox Hello!
	}
return

F2::
	breaker	:= true
return

Loop
Break


6) Finding Out What Button You're Pressing (JoyPad, Random Keyboard Keys, Surface Pro Stylus, etc...)

A lot of times, people need to find out how to use a specific button. It might be on a controller, or it might be some extra mouse button or an extra key on your keyboard. We also see a lot of Surface Pro Stylus questions. So here a couple ways to help you identify what button you're pressing.
It should be noted that NOT ALL BUTTONS/KEYS CAN BE DETECTED!!! Remember that.

Option 1 - Keyboard Hook Method

Make this into a script:

#Persistent
#InstallKeybdHook
#InstallMouseHook

Now double-click on the script icon in your system tray (Or right-click then click "Open").

Click "View" then "Key History and Script Info".

You can now press whatever buttons you're trying to identify. Press them a few times, then press F5 to refresh the Key History.
I chose to click my left mouse button and then type "autohotkey"

You should see something like this:

Window: D:\Scripts\AHK\Del.ahk - AutoHotkey v1.1.23.01
Keybd hook: yes
Mouse hook: yes
Enabled Timers: 0 of 0 ()
Interrupted threads: 0
Paused threads: 0 of 0 (0 layers)
Modifiers (GetKeyState() now) = 
Modifiers (Hook's Logical) = 
Modifiers (Hook's Physical) = 
Prefix key is down: no

NOTE: To disable the key history shown below, add the line "#KeyHistory 0" anywhere in the script. 
The same method can be used to change the size of the history buffer. 
For example: #KeyHistory 100  (Default is 40, Max is 500)

The oldest are listed first.  VK=Virtual Key, SC=Scan Code, Elapsed=Seconds since the previous event. 
Types: h=Hook Hotkey, s=Suppressed (blocked), i=Ignored because it was generated by an AHK script,
a=Artificial, #=Disabled via #IfWinActive/Exist, U=Unicode character (SendInput).

VK  SC	Type	Up/Dn	Elapsed	Key		Window
-------------------------------------------------------------------------------------------------------------
01  000	 	d	1.19	LButton        	
01  000	 	u	0.05	LButton        	
41  01E	 	d	1.50	a              	
41  01E	 	u	0.11	a              	
55  016	 	d	0.16	u              	
55  016	 	u	0.08	u              	
54  014	 	d	0.11	t              	
54  014	 	u	0.13	t              	
4F  018	 	d	0.05	o              	
4F  018	 	u	0.11	o              	
48  023	 	d	0.14	h              	
48  023	 	u	0.08	h              	
4F  018	 	d	0.09	o              	
4F  018	 	u	0.11	o              	
54  014	 	d	0.03	t              	
54  014	 	u	0.09	t              	
4B  025	 	d	0.05	k              	
4B  025	 	u	0.08	k              	
45  012	 	d	0.06	e              	
45  012	 	u	0.02	e              	
59  015	 	d	0.09	y              	
59  015	 	u	0.09	y              	
74  03F	 	d	6.22	F5   

You can use those VKs (virtual keys) and SCs (scan codes) in a script now. If I wanted my "a" key to make a message box pop up, I can do it with the VK or the SC like this:

vk41::
	MsgBox VK Hello!
return

 

sc01E::
	MsgBox SC Hello!
return

#InstallKeybdHook
#InstallMouseHook
#Persistent


Option 2 - Script for Detecting Scan Codes

Run this script and a box will pop up on your screen.
Press a button and a scan code should show up.

This script was written by SKAN from the AutoHotkey Forums. Thanks SKAN!

#Persistent
gosub GetScanCode
return

GetScanCode:
	SetFormat, Integer, Hex
	Gui +ToolWindow -SysMenu +AlwaysOnTop
	Gui, Font, s14 Bold, Arial
	Gui, Add, Text, w100 h33 vSC 0x201 +Border, {SC000}
	Gui, Show,, % "// ScanCode //////////"
	Loop 9
		OnMessage( 255+A_Index, "ScanCode" ) ; 0x100 to 0x108
		Return

	ScanCode( wParam, lParam ){
		Clipboard := "SC" SubStr((((lParam>>16) & 0xFF)+0xF000),-2) 
		GuiControl,, SC, %Clipboard%
	}
return

Option 3 - Joypad Button and Axis Detection Script

; July 6, 2005: Added auto-detection of joystick number.
; May 8, 2005 : Fixed: JoyAxes is no longer queried as a means of
; detecting whether the joystick is connected.  Some joysticks are
; gamepads and don't have even a single axis.

; If you want to unconditionally use a specific joystick number, change
; the following value from 0 to the number of the joystick (1-16).
; A value of 0 causes the joystick number to be auto-detected:
JoystickNumber = 0

; END OF CONFIG SECTION. Do not make changes below this point unless
; you wish to alter the basic functionality of the script.

#SingleInstance, Force

; Auto-detect the joystick number if called for:
if JoystickNumber <= 0
{
	Loop 16  ; Query each joystick number to find out which ones exist.
	{
		GetKeyState, JoyName, %A_Index%JoyName
		if JoyName <>
		{
			JoystickNumber = %A_Index%
			break
		}
	}
	if JoystickNumber <= 0
	{
		MsgBox The system does not appear to have any joysticks.
		ExitApp
	}
}

#SingleInstance
SetFormat, float, 03  ; Omit decimal point from axis position percentages.
GetKeyState, joy_buttons, %JoystickNumber%JoyButtons
GetKeyState, joy_name, %JoystickNumber%JoyName
GetKeyState, joy_info, %JoystickNumber%JoyInfo
Loop
{
	buttons_down =
	Loop, %joy_buttons%
	{
		GetKeyState, joy%a_index%, %JoystickNumber%joy%a_index%
		if joy%a_index% = D
			buttons_down = %buttons_down%%a_space%%a_index%
	}
	GetKeyState, joyx, %JoystickNumber%JoyX
	axis_info = X%joyx%
	GetKeyState, joyy, %JoystickNumber%JoyY
	axis_info = %axis_info%%a_space%%a_space%Y%joyy%
	IfInString, joy_info, Z
	{
		GetKeyState, joyz, %JoystickNumber%JoyZ
		axis_info = %axis_info%%a_space%%a_space%Z%joyz%
	}
	IfInString, joy_info, R
	{
		GetKeyState, joyr, %JoystickNumber%JoyR
		axis_info = %axis_info%%a_space%%a_space%R%joyr%
	}
	IfInString, joy_info, U
	{
		GetKeyState, joyu, %JoystickNumber%JoyU
		axis_info = %axis_info%%a_space%%a_space%U%joyu%
	}
	IfInString, joy_info, V
	{
		GetKeyState, joyv, %JoystickNumber%JoyV
		axis_info = %axis_info%%a_space%%a_space%V%joyv%
	}
	IfInString, joy_info, P
	{
		GetKeyState, joyp, %JoystickNumber%JoyPOV
		axis_info = %axis_info%%a_space%%a_space%POV%joyp%
	}
	ToolTip, %joy_name% (#%JoystickNumber%):`n%axis_info%`nButtons Down: %buttons_down%`n`n(right-click the tray icon`n or press Escape to exit)
	Sleep, 100
}
return

Escape::ExitApp

7) Making Certain Things Only Work in Specified Programs (WindowSpy!)

If you want your hotkeys/hotstrings/any other part to only work in a specific program, you'll need the #IfWinActive command.

To make a hotkey that only works in Chrome, we can use the following:

; Everything following #IfWinActive will only work for the program specified.
#IfWinActive, ahk_exe chrome.exe

; Opens a new tab and searches for "autohotkey tutorial"
F1::
	Send, ^t
	Sleep, 100
	Send, autohotkey tutorial{enter}
return

; The second #IfWinActive is to indicate anything past this
; point will work in any program.
#IfWinActive

If you're confused about the ahk_exe part, don't be. It's just one of many ways to identify a window.

You can use the title, but this can cause problems as titles can change. If you feel you NEED to use the title of the program, you can set HOW it searches for titles by using SetTitleMatchMode.

Most of the time you should use either the ahk_exe or the ahk_class.

To find a program's class or exe, you can use a powerful tool called "WindowSpy" that was installed along with AutoHotkey. To open window spy, run a script, right-click on the script icon in your system tray and click "Window Spy".

There's also a button for it in SciTE4AutoHotkey. Look on the bottom toolbar, right side.

SetTitleMatchMode
#IfWinActive
WinTitle (Covers ahk_exe, ahk_class, ahk_id , ahk_pid, ahk_exe, ahk_group)


8) Sending a Keystroke or Mouse Event to an Inactive Window

Sometimes you need to send a keystroke or mouse click to a program that's not active. Like playing/pausing your music player when you're in the middle of a game. Or maybe you need to pause the movie that's playing on your second monitor.
To do that, you'll need to use ControlSend or ControlClick.

Here's my own personal script I use to control WinAmp (a music player) regardless of what program is active.

;============================== Winamp ==============================

#IfWinExist, ahk_exe winamp.exe

; Previous Song
#z::
	ControlSend, ahk_parent, z, ahk_class Winamp v1.x
return

; Play
#x::
	ControlSend, ahk_parent, x, ahk_class Winamp v1.x
return

; Pause
#v::
	ControlSend, ahk_parent, c, ahk_class Winamp v1.x
return

; Next Song
#b::
	ControlSend, ahk_parent, b, ahk_class Winamp v1.x
return

#IfWinExist

It should be noted that the ahk_parent part (called the control parameter) is not usually needed. Winamp is one of the rare cases where it's required. Normally you'll leave it blank like this:

	ControlSend, , a, ahk_exe notepad.exe

ControlSend
ControlClick


This post is a constant work in progress. More will be added as needed.

If you feel a topic should be added, please leave a message.

If you have any questions about how a script works, please don't hesitate to ask.


r/AutoHotkey • • Feb 02 '20

Looking for practice? Want to expand your AHK knowledge? I got you covered.

178 Upvotes

I made a reply a while ago to /u/Swaggurttt (could you give us an update of how things have been going?)

He wanted to learn more about AHK. So I provided him a list of new things to learn past just "press button > send keys".

Hopefully, some people reading will take this opportunity to branch out and learn some new things that AHK is capable of.
From stepping into the aesthetically pleasing world of GUIs to using RegEx to become a string manipulating master.
From braving the cryptic DllCall() command that lets you embrace code from other files thus making your scripts much more robust and useful, to having a whole slew of problems and puzzles that will test your ability to utilize AHK's capabilities.

Practice, Problems, and Challenges - It's like fun homework

Let's start with 4 websites that will give you tons of practice.
From easy to insanely difficult.
Between these 4 sites, you should have more things to do than you could ever finish.

Code Abbey

The site I've spent the most time on.
From the easiest "add two variables" all the way to "write an AI".
It's a good place to learn core programming skills and develop logic.
Parsing through data, calculating variables, using arrays, etc...

Funny thing is this website is the reason I'm making this post.
It has been a while since I used this site and I couldn't remember the address. So I looked up this post and...here we are!

Rosetta Code

Another good site, though I like Code Abbey's layout, sorting, and input/output method more. Rosetta has its own pros, like showing you solutions in TONS of different languages.
Very helpful if you're familiar with other programming languages.

Code Chef

This was suggested to me a while ago and I've only done a couple of problems. Not because it's a bad site, but because I just haven't had the time to try and nuke the list. I figured it was worth including.

Those 3 should keep you busy for quite some time. Plus...

The AHK Subreddit

This subreddit is a treasure trove of problems!
I used to spend a ton of time just trying other people's problems, coming up with my own solutions, and comparing what I come up with to others. You can learn a TON doing it this way. And comparing answers afterward only teaches you newer and better ways of doing things.
Consider the unbelievable amount of backlogged posts you can go through. Years and years worth.

How about some suggestions for parts of AHK to learn?

RegEx (Regular Expressions) - Master of Strings

This is a mini-language for manipulating strings. Learn it!
If there's a discernible pattern to what you're looking for, you definitely can write a RegEx to find it.
See: RegExMatch and RegExReplace.
Bonus: It should be noted that RegEx is its own little mini-language with its own rules and syntax. BUT, once you learn it, you now know it for almost every other programming language (minus some discrepancies between flavors).

RegEx Resources:
  • Regular-Expressions.info is pretty much the authority on all things RegEx related.

  • RegExOne is another great resource that gives interactive examples as you learn the language.

  • Ultrapico.com is a user's site with their own 30 min tutorial and some other neat resources.

  • This RegEx Cheat Sheet is handy to have around, especially if you're newer and haven't memorized the metacharacters.

  • RegEx Buddy (Best RegEx Program Ever!) I encourage everyone to look into this program and consider buying a copy.
    For those who legitimately can't afford it, some careful Googling will land you a copy for $free.99. But, please consider supporting the developers of it.

  • RegExr is like RegExBuddy except it's free and online. Unfortunately, it isn't quite as robust as RegExBuddy. It'll help you learn, gives your place to build expressions, and a spot to test them.
    My biggest complaint is the site layout seems crowded. But, considering the price, availability, and what it does, it definitely deserves some respect (and to be bookmarked).

  • AHK's RegEx page
    AHK's own RegEx page with info to AutoHotkey, its flavor, options, etc...

COMs - Letting you interface with other shit one command at a time!

COMs are pretty amazing. They let you interact with lots of different things on windows.
Microsoft lets you access things like Internet Explorer, Excel, Word, Access, (literally the entire office suite), shell, WIN HTTP, VBScript, etc... It lets you use those programs directly from AHK. This increases reliability near infinitesimally compared to blind clicking and typing.
You can web scrape like a boss using the IE COM.
You can manipulate Excel spreadsheets, get data from them, update them, and whatever else you want.
COMs are handy.

Resources:

There are also quite a few videos on YouTube that you can also check out.

GUIs - I feel pretty. Oh so pretty....

Learn to make and manipulate Graphical User Interfaces or GUIs.
When you want user-friendly interaction with the users of your code, GUIs can be the perfect answer.
A non-programmer isn't going to want to run scripts with switches or open up .ahk file or edit code to change settings.
Enter the GUI!

The "Read This Before Posting!" stickied tutorial post has some good WYSIWYG suggestions. And it stands for What You See Is What You Get...that's really what they're called.
Personally, I'm a fan of GUI Creator by Maestrith.

You'll spend a LOT of time trying to learn all the different things GUIs can do.

The AHK docs are the go-to for this stuff.
Here are the pages you'll be visiting quite often:

I'd like to add a neat method I've started doing for tracking elements because it used to be a struggle for me.
When I create a GUI, I like to keep everything inside of functions and I really don't want to create global variables for everything.
I find myself making a single global Object in the AES.
Then, whenever I create a GUI element, I always add the hwnd option to it and then immediately save that HWND to the array. Plus, you can logically name it so it's much easier to recall.

Example:

Global guiHwnd := {}
NewGUI()
MsgBox, % "Cancel Btn: " guiHwnd.CancelBtn "`nOK Btn: " guiHwnd.OKBtn
ExitApp

NewGUI(){
	Gui, New
	Gui, Add, Button, hwndBtn gOKBtn, OK
		guiHwnd.okBtn := btn
	Gui, Add, Button, hwndBtn gCancelBtn, Cancel
		guiHwnd.cancelBtn := btn
	Gui, Show
	Return
}

GUIs are an excellent segue into DllCalls. Why? Because DllCall can let you fine-tune a GUI.

DllCall - Rule #1 of coding: Don't reinvent the wheel!

One thing we learn real quick in programming is you don't rewrite code that's already been created and thoroughly tested. It's a waste of time!
That's why people will bundle up their code into these neat packages called DLLs (Dynamic Link Libraries) and then publish them for others to use. These let you call commands and functions outside of the native AHK language. Meaning you can interact with Window's internal functions directly from your script!
This opens up a TON of possibilities for any script and unlocks some of the restrictions that come with AHK. Like changing things about GUIs that AHK doesn't have an option for. Or getting info directly from the operating system because we don't have an AHK command or function created to do so.

It's not just limited to Windows functions. It can access any DLL. As long as you know how to interface with it.

This MSDN link has a top-level link to all of the core things you need to learn about DLLCalling to windows.

  • Window Constants - These things are used all over in the MSDN documents. They're just built-in variables that contain info, usually a hex number.
    Thanks to /u/g33kdude getting me a very handy file, I've hosted a list of (~53,000?) Window's constants on my GitHub for anyone to use. Ctrl+F is your friend.

  • Window Functions - These are the actual things you make a call to. There are tons of them and you'll find them as needed. There's a function for damn near anything you can imagine inside of Windows.

  • Window Macros - These are a handful of useful macros for manipulating windows function data. Like get hi and lo word. I just make my own and call them from inside the script...

  • Window Messages - These are the messages windows shoots back and forth after almost every event. These are how you make event handlers.
    See: PostMessage/SendMessage, OnMessage(), and AHK Window Message List (WM_*)

  • Window Notifications - All of these are window messages.

  • Window Structures - To put it easy, a structure is a variable that stores data in bit form instead of the form you're more familiar with in AHK. Each structure has its own "layout/map" of what each set of bits/bytes means. This way, you can send a lot of information without making big sets of data. Kind of like a compact way for functions to communicate. If you don't know binary, this will suck. Make sure you learn binary. (If one explanation doesn't click, find another. To get the lightbulb to click, some people have to have it explained the right way.)
    Use VarSetCapacity() to set the size of a variable, and then use NumPut/NumGet to set/get bits.
    These can be tricky until you get used to them. Don't get discouraged.

GDI+ - Giving you the ability to create and manipulate graphics on the Windows level

GDI is Window's Graphics Device Interface.
A user named Tic (Tariq Porter) wrote GDI+ for AHK. It handles ALL the DllCalls you need to make to the GDI to manipulate graphics, draw shapes and objects, import pictures, etc.
You know all the stuff you can do in Paint? You can do ALL that anywhere at any time on the screen using AHK & GDIP. Without having to ever load Paint.
Please note the GDI+ repo also includes tutorials on how to use the library. It doesn't cover everything quite as in-depth as I'd like it to, but the examples will give you plenty to go off of.


Why are you still reading this? You should have gotten distracted way up top and started trying stuff on Code Abbey!

OK, one challenge I always like to give people.

Recreate the Window's calculator. And make it work exactly the same.
Initially, it sounds easy!
But, duplicating the functionality AND the aesthetics can be pretty tricky.
This is actually a tough challenge with lots of parts.
You'll have to make a GUI that looks as close as possible to calc.exe. Make the display function the same, make every button work correctly, calculations should work, memory buttons should function, etc.
Don't forget to make an icon for it and also to disable the AHK system tray icon, just like the real thing.
Oh! And recreate the menu, too.
This will give you practice on TONS of different aspects. It's complex enough to be challenging but not so complex no one would ever want to do it.

If you can get this done and want to extend things further, try making the scientific version of the calculator!!
There's a real challenge. The extra advanced math buttons each have to work correctly.

Go, try, learn.
If you get stuck, come back to the sub and ask for help.
Or hit up the Discord crew.
While you're waiting for an answer, you can always go through some of the current questions on the sub.

I hope you guys enjoy this post.


r/AutoHotkey • • Nov 25 '24

Meta / Discussion How I turned AHK into my job for 3-5 years.

172 Upvotes

I figure this community will get a kick out of this story so here it is. 7 years ago I was working in a global security dispatch center (~150 employee department) as an operator for a major company. the core of my job was to see alarms on my screen (Lenel) and dispatch them via phone/radio/email to the appropriate security team. Our department received 1-2 million alarms a year (not an estimate, I did the alarm metrics gathering for our department). For every alarm we had to enter clearance notes and a bunch of other stuff which took a lot of time.

One day, I was sitting at my desk with 30 alarms in front of me and thought "there has to be a better way to do this". Being the semi tech savvy person I am, I started googling how to make macros to automate alarm clearance notes and found AHK. I don't have any coding background but after reading some of the documentation it seemed really simple so I downloaded it and gave it a try.

I quickly built clearance notes for every alarm type. It felt great being able to do my job significantly faster so I started wondering what else this cool little script thing could do and this is the point where my job unofficially became AHK. Half of my time was spent managing alarms and the other half was spent developing my script which I had named Alarm Acknowledger (AA). I added a custom GUI, go it to look up phone numbers and place calls for me (we were using ROIP for calls), I even got it to upload all clearance notes for all my co-workers into a central Excel file on a shared drive (this was hell because if two people try to update a file at the same time it fails so I had to do some trickery with local .txt files that occasionally updated to the master file when it wasn't occupied).

After unofficially working on AA for about 2 years my management said I could just do this full time so I moved over to our security-tech team where I continued to update it for ~3 years along with other ad-hoc project work.

The whole time I was doing this I never used anything besides notepad to build it and all of my version control was done manually in a folder on a external hard drive. When I left the company my script was ~3800 lines of code and had more features than I can even remember. Looking back I have no idea how I never moved to something like vscode / GitHub.

I'm posting this because I am feeling nostalgic and wanted to share the story of how I got to this point in my life. It's been about 2 years since I last worked on AA and I start a full stack boot camp next week so I can HOPEFULLY develop as a job again. AHK is what got me into developing so it will always have a special place in my heart. If you made it this far into my story, let me know what got you into using AHK. I'd love to hear your stories.


r/AutoHotkey • • Mar 02 '21

Meta / Discussion Share your most useful AHK scripts! [My huge script+and then some more+request]

145 Upvotes

I've just had an idea. I'm going to share my ahk script filled with useful shortcuts, and then in the replies, you share some of your scripts! I'm in dire need of repurposing some of my function keys

;Search selection, Ctrl+Shift+g

^+g::
{
clipboard=
Send, ^c
Sleep 0025
Run, http://www.google.com/search?q=%clipboard%
Return
}



;----------------------------------------------------------------------------
;Always on top, Alt+t

!t::WinSet, AlwaysOnTop, Toggle, A
return



;----------------------------------------------------------------------------
;AutoCorrect 

::}ahk::autohotkey



;----------------------------------------------------------------------------
;Transparency toggle, Scroll Lock
sc046::
toggle:=!toggle
if toggle=1
 {
 WinSet, Transparent, 150, A
 }
else
 {
 WinSet, Transparent, OFF, A
 }
return



;----------------------------------------------------------------------------
;NumPad Shortcuts, Ctrl+NumPad

^NumPad1::
Run,https://www.youtube.com
return

^NumPad2::
Run,https://www.netflix.com/browse
return

^NumPad9::
run, "Notepad.exe"
return

;I have other ones, but you get the idea, just simply running apps or websites



;----------------------------------------------------------------------------
;Chrome Incognito, Pause/Break

Pause::
run, "chrome.exe" -incognito 
return

;Pause/Break key to close the active window
;Pause::WinClose, A

;YouTube Incognito
Pause & Home::
Run "chrome.exe" -incognito "https://www.youtube.com"
return



;----------------------------------------------------------------------------
;Volume control, Alt+Scroll wheel (and Mbutton)

Alt & WheelUp::Volume_Up
Alt & WheelDown::Volume_Down
Alt & MButton::Volume_Mute



;----------------------------------------------------------------------------
;Suspend hotkeys
!s::
suspend, toggle
return



;----------------------------------------------------------------------------
;Fixing/repurposing Fn+function keys

;My keyboard is the Red Dragon Mitra K551

;Fn+F1 sends you to Spotify instead of windows media player
Launch_Media::
Run,Spotify.exe
return

;Fn+F9 sends you to Gmail instead of Outlook
Launch_Mail::
Run, "https://mail.google.com"
return

;Fn+F10 basically does the same thing it did before, mine stopped working, I think
;something to do with the accounts
Browser_Home::
Run, "chrome.exe"
return 

;Fn+F12 sends you to google drive instead of searching (Ctrl+f or even F3 are more
;reliable for searching, at leat on chrome)
Browser_Search::
run, https://drive.google.com/drive
return



;----------------------------------------------------------------------------
;Other random ideas not on my main script
;----------------------------------------------------------------------------

;Emptying recycle bin with a shortcut

^f1::FileRecycleEmpty
return



;----------------------------------------------------------------------------
;Quicker Alt tab, Caps Lock (I mainly used it for quickly switching between half 
;life and a half life guide)

CapsLock::
send {Alt Down}
sleep 0030
send {Tab}
sleep 0010
Send {Alt Up}
return 



;----------------------------------------------------------------------------
;Function keys to maximize and minimize the active window

f7::WinMinimize, A
return

f8::WinMaximize, A
return



;----------------------------------------------------------------------------
;Auto greater and lesser than for html, and since this one sends both, you 
;could make a script that instead of sending greater than, shift+< would send </>,
;as a closing tag

$<::
send, <
sleep 0010
send, >
sleep 0010
send, {Left}
return



;----------------------------------------------------------------------------
;Volume mixer, f7 opens it, if it's not active it recalls it, if its active, 
;it closes it

#MaxThreadsPerHotkey 2
SetTitleMatchMode, 2

F7::
Run, "SndVol.exe" 
return

#IfWinActive Mezclador
	F7::WinClose, A
	return

That´s about it. Like I said before, it'd be cool of you leave in the comments your favorite/most useful scripts, maybe something to repurpose the function keys, Pause/Break, and Scroll Lock. Thanks Again!


r/AutoHotkey • • Jan 18 '22

Resource 10+ AHK scripts I use on a daily basis

133 Upvotes

I wrote an article explaining each script and how to use them: https://gourav.io/blog/autohotkey-scripts-windows#useful-scripts

Repo containing all scripts: https://github.com/GorvGoyl/Autohotkey-Scripts-Window

Few of my fav scripts:

  • Look up selected text

  • Use Win key as mouse left-click

  • Show notification on low battery or when fully charged

  • Show popup to transform text

  • Create new text file here

  • Open PowerShell here

  • In-line calculator

  • and more...

What's your favorite ahk script?


r/AutoHotkey • • Dec 08 '20

Meta / Discussion Not here to post any questions, just wanted to say thanks to the people who made AHK and to the people who dedicate their time and effort on helping noobs like me.

110 Upvotes

Recently, I had to RMA my Corsair keyboard. It has a lot of macros that I've made using iCUE that I use for work daily. I bought a cheaper temporary keyboard to use for the meantime and that one is from a different brand, so I can't use iCUE on it and it has no dedicated macro keys, but thanks to AHK, I can still perform all the things that my other keyboard can do.

Took me a few hours to write the script (mostly just binding single keys to multiple keys), but it was worth it.

:D


r/AutoHotkey • • Jan 11 '25

Meta / Discussion Win 11 update has new "Recall" feature and I wanted to make sure people knew about it.

104 Upvotes

Not the normal kind of post I do, but I thought one was warranted.

For Win11 users, you might want to consider something from the 24H2 update.

Microsoft now installs something called "Recall" and it's something you should at least know about.

The really short end of it:
Microsoft Recall is designed to continuously screenshot a computer.
It saves the photos and uses them with copilot+ to "recall" things you've seen or typed in the past while using your computer.
It's pretty much created to log your entire experience, like how you type stuff and "Undo/Redo" remembers what you typed or even untyped.

The screenshotting happens every X amount of seconds and is done indiscriminately.
The problem here: things like passwords, personal information, SSN, bank/routing numbers, profile associations, photographs you don't want others seeing, anything "intimate", and anything else you can think of that you'd normally keep private is being actively recorded and saved.

There's a LOT to all this so I'm really glossing over some stuff.
Like yes, they do encrypt the images. You can't just open a folder and BAM, there are millions of photos.
But there is a problem. People have already found ways to exploit Recall.
Watch the MentalOutlaw video listed below for more info.

An overview of Recall can be found on MSDN.

But here are some articles/videos created by people who aren't Microsoft.
None of them seem keen on talking about Recall in a positive manner like MS does.

You have to ask yourself: "Am I OK with someone sitting over my shoulder with a camera, video recording my every moment on the computer just as long as they promise they'll never do anything bad with what they're recording?"
That's essentially what's happening.
I feel like I'm being "that super paranoid guy" right now, but the idea of my screen being actively recorded and then being fed into some giant neural net that Microsoft has is just really unsettling. It's data gathering on a whole new level.
IDK...

Anyway, when I found out about Recall, I went down a mild rabbit hole.
This is what I've put together so far:

Originally, this was supposed to only be for PCs that have an NPU (Neural Processing Unit which are the new thing they're apparently adding onto CPUs. Like how a GPU is designed to handle graphics, these NPUs are designed to do neural net/AI-oriented stuff.)

The problem is that "Full Speed Mac & PC" recently posted a video showing that Recall is now on all versions of Win11 since build 24H2.
From what I can tell, this means all computers, not just ones with NPUs, have it installed.
It might not be enabled, but it is installed.

Another big problem: This "feature" is opt-out.
For those not familiar with opt-out vs opt-in:
Opt-out = This is forced on you and you have to tell them you don't want it. If you don't know it's there and/or don't know how to opt-out, that's your problem.
Opt-in = You're given the choice, the option, to install something. It's not forced on you but it's there if you decide you want to use it. This is what most things should be.

And Microsoft opened a bag of Scummy Bears on this topic.
It started as opt-out originally but got a lot of backlash for it.
In an attempt to save face and get a little trust back, they switched Recall to opt-in.
But after the dust had settled and months had gone by, they switched it back to opt-out.
(And MS doesn't understand why we don't trust them...)

But wait! There's more!
You were originally able to completely uninstall Recall like you can any other feature in Windows.
However, they said "the ability to uninstall it was a bug"...
SO THEY FIXED IT! 🤦‍♂️
Meaning it's no longer uninstallable.
You can disable it, but not uninstall it.
And if you know anything about MS, you know they LOVE to reenable things that have been disabled.
Relevant tangent: Anyone here remember the whole "auto-update" debacle when Win10 was new? Every single time you disabled auto-updates, it'd magically get re-enable and then proceed to reboot when IT wanted to reboot, thus loosing any unsaved work.

Me: ಠ_ಠ

From what I understand, the Enterprise edition of Windows will allow you to uninstall Recall, but not the consumer versions.
Consumers are restricted to enabling/disabling only.
Was that the bug? They forgot to flip the bit that disabled uninstalling in the consumer version? Really?

Let's discuss how to Check Status, Disable, and Enable Recall:

It's all done through DISM (Deployment Image Servicing and Management).
You'll need a prompt in admin mode to do this.
These instructions are for Cmd but you can do it with PowerShell, too.

  • Open the start bar search
    Type Cmd or Command Prompt
    Right click on Command Prompt and Run as Admin

  • Or use the run box.
    Press Win+R to open Run
    Type cmd
    Holding Ctrl+Shift when you press enter or click OK causes it to launch in admin.

To Check Recall Status:
Dism /Online /Get-Featureinfo /Featurename:Recall

If installed, it should look like this.
If not on the system, you'll get a feature unknown error.

To Disable Recall:
Dism /Online /Disable-Feature /Featurename:Recall
To Enable Recall:
Dism /Online /Enable-Feature /Featurename:Recall

I encourage everyone to always research a topic and verify things.

If any factual inaccuracies are found, please let me know so I can update this.
I don't want to be a source of bad information.


r/AutoHotkey • • Feb 04 '20

Relax, an entire compiled programming language, written in (exclusively) AHK.

102 Upvotes

Relax, a compiled C-like language implemented entirely in AHK.

(Although it probably could have also been called 'sleep-deprivation' or 'over-ambition')

This sounds like an advertisement, and I wish it was, but sadly this project is only a learning experience. Don't even get me started on how much money I would have made if I got a job instead of writing this.

Relax is a statically typed, compiled programming language. Relax is not as feature-full as other languages, however, it is my first language, and isn't intended for everyday use.

Relax is missing structures, array types, and complex types (such as function pointers), but is still very usable, and generates relatively small output files.

Every part of Relax is implemented in AHK, including compiling to machine code, and building .exe files.

Relax is ~6000 lines total, and takes much longer to run than most compilers, however, the .exe files built are very fast (considering they aren't being interpreted by AHK).

I've had lots of fun writing this language, and over time I've realized more and more just how ridiculous this project is.

If you'd told me that someone could write an entire programming language in AHK when I first started with it, I would have called you an idiot and gone back to my navy seal copypasta sender script.

However, here it is anyway: The language nobody asked for, written in a language that has no right being as powerful as it is.

Even if it is useless, I've learned loads from this, and figure I might as well share it after putting in so much work.

If you're interested in hearing some of my struggles or details on how it all works, I've done a whole writeup in the docs, which I tried to put a bit of humor into.


r/AutoHotkey • • Jan 05 '21

Meta / Discussion Who the hell here keeps downvoting people who show their work?

99 Upvotes

Sure, not showing any attempt and just demanding a script should merit a downvote. I agree with that.

But just as much, anyone who shows any attempt at having tried to figure out AutoHotkey on their own should at minimum not be downvoted, and in fact should be upvoted, no matter how trivial their question may be. We are (or should be) all here to learn and/or help, not to belittle.

Whoever's uniformly downvoting every post in this sub should seriously reevaluate their life. Do something that's more helpful, please, for others or yourself.


r/AutoHotkey • • May 08 '21

Script / Tool Batch Deleting Messages from DM

98 Upvotes

NOTE: Discord doesn't allow you to delete messages from the other user. So, the only solution is to ask them nicely to delete theirs, or close DM, and block them until you feel like you can view their messages.

<------------------------------------------------------------->

I spent a lot of time looking for a method and could not find the right script here anywhere. The ones I did find were buggy, cuz they were like, 4 or 5 years old. They were also fairly simple.

Anyways, here's how you can bulk delete your DM messages without having to delete them individually.

First of all, you need to download AutoHotKey.

After it's installed. You need to open Notepad and copy and paste the following script:

^d::

Loop, 100
{
    send, {Space}
    sleep, 100
    send, {BS}
    send, {Up}
    sleep, 200
    send, ^a
    sleep, 100
    send, {BS}
    sleep, 200
    send, {Enter}
    sleep, 100
    send, {Enter}
    sleep, 1000
}
Return

After you've done that, save it with an ".ahk" extension. e.g. "discord.ahk" and save it to desktop for convenience. Once it's on the desktop, double-tap it and the script should now be active.

The final step is to head over to the DM you want to delete your messages from, and press Ctrl+D. The messages should now start deleting.

Now, How does this work and how is this different?

It does a couple of actions for you. You can try this out yourself. Open a DM, tap on the message icon, press the Up Arrow, then Ctrl+A, then backspace, followed by Enter two times. AutoHotKey does all of these actions for you.

The previous scripts I've come across work, but only for the first message. Here is a post similar to all the others I've found on the Internet. Some are a bit more advanced but they still fail after the first message. The problem being? You see, after you've deleted the message with the steps I mentioned above, the text area is unfocused. So if you press Up Arrow, mess happens.

However, to fix this issue, I went to Keybinds on Discord and saw that pressing any key focuses on the text area

So, all I had to do was add in a key that would trigger the text area and allow me to carry out the rest of the operations. That is the reason that you see me having included "Space" and "BS"(backspace) included on the top of the script. And it works like a charm! (✿◡‿◡)

And there you go. I hope people find this helpful.


r/AutoHotkey • • Jul 26 '19

For people new to autothotkey and in need of scripts to make their lives easier, here's a huge collection of free scripts that are awesome! (not mine)

88 Upvotes

the collection

I can personally vouch for the usefulness of:

  • Captain.ahk (changes the title of your active window to whatever you want with the middle mouse button)

  • Accents.ahk (adds accents to your vowels for other languages that need them by repeatedly pressing the same key quickly -- like this : å a ä ï ø)

  • ClipStep.ahk (gives you 7 clipboards instead of one! It uses a tooltip right next to the mouse to show you which one you're accessing, and you can delete several or all at once. VERY HANDY. 10/10 script)

  • TransOther.ahk (makes any window except the active one transparent so you can focus more on the active -- at least that's what I think it's for. maybe just for aesthetics idk)

  • MoveInactiveWin.ahk (lets you move any window without making it active by holding down alt + left mouse)

  • SmallMeasure.ahk (gives you a little ruler that you can drag to measure the pixels across your screen. could be useful in a variety of ways. the stock script doesn't let you exit out easily, so in the code just add a line at the bottom like : Esc::ExitApp)


r/AutoHotkey • • Nov 19 '20

AutoHotkey 2020 User Survey - Tell us about how you use AHK!

80 Upvotes

It's that time of the decade again, time for the 2020 AutoHotkey user survey!

This is the second user survey, following the first one which was held in 2016 (results can be found here in the May 2016 webinar) and responded to by 408 people. Let's see if we can make that number bigger this time around!

The survey will take around 4 minutes to complete and allow you to enter to win a $50 Amazon gift card or one of four AHK Udemy courses.

Some select data from last time include:

The survey can be found here: https://survey.alchemer.com/s3/5206084/AutoHotKey-User-Survey?src=rdt

Thank you for taking your time to fill it out! The results will be shared in a webinar just like the first survey, and will be emailed to people who want a copy of the report. Your expert opinions are just what we needed! (Yes, even you brand new experts!)


r/AutoHotkey • • Jan 02 '24 Take My Silver Heart of Silver

Resource Groggy's 2024 contribution: I rewrote the definition file and udpated the ahk2.json file for THQBY's AHKv2 addon. This update adds a vast amount of information, functionality, and updates to the addon. Plenty of pics and video demonstrations included.

79 Upvotes

GitHub link - AHKv2 Addon Definition File and JSON File Rewrite


Intro:

Everyone knows that THQBY's AHK v2 addon for Visual Studio Code is the gold standard for writing AHK v2 code.

It incorporates so many good things.

However, one thing that I've felt that is in desperate need of an update is the definitions file.
This is the file that contains all the information on all functions, classes, methods, and properties in the v2 language.

I noticed that some parameters are missing, tons of options aren't listed, return values are absent, some items have no information at all, some methods/properties are blanketed to cover multiple object types, and a bunch of other stuff that I feel could be improved.
There's a major opportunity to update this.

So, over the last 6 or 7 months, I did.

Remember my recent post about mapping out v2's structure?
It was inspired heavily by this project, which involved me going through each and every class, function, property, and method.

So what does this mean?
I rewrote the definition file entirely from scratch and with the information I think should be available.
The definition file is pretty much a giant AHK file that includes every function and class in the entire language and defines everything using JSDoc tags.
The addon uses these tags to generate specific intellisense popups that are filled with information, options, links, and examples.

I created a template for each "type" (method/property/class/function) and then went through and applied those templates to each part of AHK's class/function structure.
The original file is ~4,200 lines and ~184,000 characters.
My updated file is over 24,000 lines and ~1,500,000 characters.
(Having a moment of reflection: Holy crap. That's a lot of characters. Like, way more than I realized.)
A good chunk of the additional characters are due to the inclusion of numerous hyperlinks, markdown formatting, and the fact that I created individualized cards for everything instead of keeping blanket statements. After creating the templates, it was only a matter of going through each class and function one at a time.

Learning about everything that JSDocs and markdown has to offer, I heavily applied it to the defintion file. Here's a comparison of how a current tag is written vs one of my updated tags.

Text is processed quickly and this size increase doesn't seem to affect performance.

While everything is complete in the sense that all functions, methods, properties, and classes are done, it's still very much a work in progress.
I'm constantly changing things, reformatting, rewording, etc.


Installing the files:

Putting this up top for those that just want to dive in and don't want to read through the information:

Download the files ahk2.d.ahk file and the ahk2.json file and put them in the syntaxes folder of the current version.
Alternatively, you can copy and paste the code over the current text in the files.
However, you may want to consider backing up the originals in case you don't care for my version.

All of the v2 addon files are stored in this path:

C:\Users\<USERNAME>\.vscode\extensions\thqby.vscode-autohotkey2-lsp-<VERSION_NUMBER>\syntaxes

You may need to restart VS Code for the changes to take effect.
Or reload the window. Ctrl+R I think.
There are no settings or anything to mess with. It just applies the new tags and incorporates all the changes I've made.

But be aware that until (or rather IF) THQBY makes this part of the addon, it'll get erased each update and you'll need to reapply the two files to any new versions.


Different widgets:

VS Code has different widget (popup window) types and they affect how things look, the order of information, style highlighting, and other stuff.
There's the hover widget, the autocomplete widget, the parameter widget, and some others.
One limitation to mention is that the parameter widget can NOT be resized (and I don't know why because all the other ones are resizeable).
Another difference is the parameter widget and autocomplete widget don't get the nice syntax highlighting that the top of the hover widget gets. Again, I don't know why. It's just how things are. I asked THQBY and he told me that they're defaulted that way and can't be changed. But I digress...

Let's look at the different widget types using the InputBox() function:
Hover widget shows up when hovering over an item with the mouse. It shows all the tags/information about that item.
This window is resizeable. I've enlarged to to show all the information I can.
Throughout this post, I'll be using mostly expanded windows just to show the information being provided.

vs
Autocomplete widget which shows up when you're typing and VS Code is trying to help you get to where you wanna go.
This window is also resizeable but can also be hidden completely by pressing ctrl+space.

vs
The parameter widget that shows up when typing inside a function or method's parentheses.
The top displayed item of this widget type is always the current parameter's information. I like that THQBY chose to do this.

That being said, let's cover some of the changes/updates I've made.


Hyperlinks:

Lots of 'em!
Anything showing up as blue text is a working hyperlink.
Everything in the definition file now has a hyperlink to its respective online doc page. It's always the first part of all @description tags.
Most of the cards include a plethora of hyperlinks.
Other commonly hyperlinked items include concepts, built-in variables, types, other functions/methods/properties/classes, external docs like MSDN links, and more.

There's an @see JSDoc tag that's used for all related links.
This includes the related items from the docs page as well as links I thought would be beneficial.
Examples: Anything that uses a WinTitle parameter has a link to the WinTitle, SetTitleMatchMode(), and Last Found Window docs.
The RegEx cards (oh god, I spent a lot of time on RegExMatch()/RegExReplace()) include links to regex101.com, a regex cheat sheet, and a site to learn regex. To me, these seem like good things to have quick access to.


Stylizing:

Instead of flat, plain-looking text, I've utilized the provided markdown and added things like bold, italics, bulleted lists, tables, code blocking, headers, and more.
I think this helps a lot with information consumption and makes the cards more aesthetically pleasing.

Compare the current MsgBox() with my updated MsgBox(). Note that there's more below and some of the cards do require scrolling b/c there are so many options.
This is a constant tradeoff. Either don't include all options or deal with scrolling to see all options when there are many of them (looking at you, GUI control options...).
¯_(ツ)_/¯

I'm continuously trying to condense things as I feel some parts may still be a bit bloated.

Again, it's a work in progress.


Custom written examples:

I've handwritten many examples already.
But there are still quite a few left to do.
It takes time and I have to be in the right mindset to churn out example code.

These examples always show up at the very bottom of any widget. As it should be, b/c they can be long.

I think examples are extremely important because there are plenty of people who learn quickest by example. They just need to see it implemented and they get it.
Some examples give a bunch of different variations, like Click().
Others, like the GUI examples, give fully functional code. And I try to make it interesting/fun when I can.
The AddSlider() example code creates a working GUI that will control the computer's volume.
It demonstrates making the gui, adding the slider, adding an event and callback to the slider, it shows how the callback should be written, and it demonstrates using the gui control parameter along with SoundSet() to make the adjustments.

In a proselytization attempt, ALL function and method calls in the new definition file include parentheses ()!
This includes all the example code as well as any mention of a function or method in the card descriptions.
I'm really big on this b/c I feel it makes the code look cleaner and if you always include them, you're never wrong. I hope this encourages that mindset.
And let's be fair here. It's a single extra keystroke. VS Code adds the closing parenthesis for you!


Types, return values, and parameters:

All parameters, return values, and properties have a defined type so there's no confusion about what you're working with.

When it comes to types, it should be noted that Number means it can be Integer or Float.
Primitive means it can be a Number or a String.
If you're not familiar with all the different object types and primitive types in v2, check out the Built-In Class Hierarchy Page. I really like this page because it demonstrates the object-oriented nature of v2.

All functions and methods have an @returns tag that gives you more specific information about what's being returned.
You'll see EmptyString a lot as a return value. This means there's no actual defined return value and you're getting AHK's default "empty string".
I ensured that EmptyString is never used with a function or method that intentionally returns an empty string as a type of valid value. It's strictly meant to convey there is no actual return value defined.

All optional parameters show what their default value is if there is one. Otherwise, unset is used.


Content and verbiage:

I want to mention that this definition file is NOT a 1:1 copy+paste of the docs.
While I did copy a lot of information from the docs, I spent an immense amount of time hand-typing a good majority of it, or at least restructuring it.
If I felt something wasn't explained well or that I could improve on it, I did so.
I also changed the names of some parameters to improve clarity. This doesn't affect he code in any way, it just clarifies what's expected in that parameter slot.

This may make the cards more understandable, but it also means expect errors.
It's 24,000 lines. You know I messed up more than a couple times.
Please, let me know about any errors you find so I can fix them.
Make a GitHub Issue post or leave a comment on this thread.

Another change I made was to overloaded functions/methods.
They've since been reworded so that everything fits under one card while still clearly showing each option.
Hotstring() would be a good example of this.
In the docs, it's listed as 5 different things:

; Make an actual hotstring
Hotstring(String , Replacement, OnOffToggle)

; Set new default hotstring options
Hotstring(NewOptions)

; Change the ending character for hotstrings
OldValue := Hotstring("EndChars" , NewValue)Hotstring()

; Change if mouse clicks reset the recognizer
OldValue := Hotstring("MouseReset" , NewValue)

; Reset the hotstring recognizer
Hotstring("Reset")

I restructured the parameters so everything falls under this format Hotstring(Option [,Value, Enabled]) => String | Integer.


Structuring and accuracy of methods and properties:

There are some "blanket methods and properties" being used in the definition file. The biggest culprit is the Gui.Control class.
I dislike that all the methods and properties are generalized across all control types. So I got rid of that setup and rewrote the definition file's class structure to include each individual control with cards specifically written for that control type.

Example: The Value property for GUI controls has different meanings depending on the control.
Instead of a blanket value definition that doesn't tell much, each control is defined.
Checkbox value only explains how it affects a checkbox and edit control's value only pertains to the edit control.

Instead of a blanket OnEvent() method that includes all the possible options available across all control types, it focuses on each control.
A Button control's OnEvent() method now contains only the events that a button can have.
This is no "Change" option like an Edit box has because a button doesn't have a change event listener.
Similarly, the Edit control doesn't have a "Click" event because it doesn't possess a click listener.

Each event needs a callback to use when an event occurs.
A callback is a function or method that's called when something happens, in this case, an event.
The catch is each event sends different parameters to the callback.
The solution? I included callback definitions with each event type that also includes each callback parameter definition.
Pro trick here: The callback definitions (and any other text on an intellisense popup) can be copied and pasted directly from the tooltip into your code.


Additions:

I added quite a few things.
Unfortunately, I didn't keep track of them.

Things like RegExMatch() and RegExReplace() now have my own personally created RegEx cheat sheet covering all the different main parts to the RegEx language.
I went through a couple of different versions but felt they were too big, so I trimmed them down to this.

I've also added an InputBox object class to the definition file that contains a Result and Value property.
This class object is affiliated with the InputBox() return value.
This results in the AutoComplete widget knowing to list Result and Value as available default properties when dealing with any object returned from the InputBox() function.

IDK what else to list. I'm sure there's other stuff I'm forgetting.


The ahk2.json file:

In addition to rewriting the definition file, I also updated the ahk2.json.
This file contains things like flow control, directives, key lists, and built-in vars, as they're not included in the definition file.

This file allows each item to be handled in sections or fields.
It also allows for menu selections containing different values or predefined text that's prehighlighted, allowing you to delete an optional section you might not want.

Using this, you can create directives and flow control statements that kind of build themselves by providing you with the information or options you need.

To navigate to the next section/field, hit tab.

When I figured this out, I went through everything and created a lot of autofill options.
Some of the things I updated include:


THQBY:

I have not spoken with THQBY about incorporating these files into the actual addon, but I will in the near future.
I'd like to condense more stuff, continue to restructure things, and take some more time to find errors.
You guys can really help out with finding errors. Again, file an issue on GitHub or leave a comment here. I want to hear about it so I can make it better.

Hopefully, he feels this is an upgrade and chooses to incorporate it.

If anyone wants to put in a good word about it to him, I wouldn't object. :D


Outro:

I hope you guys enjoy this.
Lots of time went into this and I hope it benefits everyone who uses it.


GitHub link - AHKv2 Addon Definition File and JSON File Rewrite


r/AutoHotkey • • Jul 17 '25

Meta / Discussion 🎉 Congratulations to /r/AutoHotkey for hitting the 30,000 subscriber mark. 🎉

75 Upvotes

🎉 30K Post 🎉

On November 8th, 2011, /u/Sidola became the head moderator of /r/AutoHotkey.
To my knowledge, he was the original creator of the sub and had the foresight to establish a place, other than the main forums, for the AutoHotkey community to engage with each other. Nearly 15 years later, the AHK subreddit continues to grow and thrive.
And on Tuesday, July 15th, 2025 we officially reached 30,000 subscribers.

I wanted to give a massive congratulations to both the subreddit, the AHK community, and to everyone who has contributed over the years.
It only takes one post to inspire someone to jump into the world of programming.
It takes one helpful comment to convince someone they're actually capable of coding when they might otherwise think it an impossible skill to learn.
It takes one code example to cause that 💡 light bulb moment 💡 to happen; that moment when a person goes from not understanding to completely understanding something.

It's fantastic that more and more people are discovering how useful and versatile AutoHotkey can be.

Being this post is social in nature, I want to encourage everyone to jump in and share any thoughts or experiences or ideas pertaining to AHK.
Things like:

  • Post your favorite script, function, or class

  • Share how you use AHK, whether for work, daily productivity, accessibility, gaming, or anything else

  • Talk about something interesting you've learned recently about the language or how it's used or what it's capable of

  • Share tips or tricks related to AHK, VS Code, or other tools you find helpful

  • Post a link to your GitHub page or any AHK-related projects you'd like others to have eyes on

  • Ask a question about a programming concept, function, class/method/property, etc. that you don't understand

  • But please save any 'help with my script' requests for their own separate posts

Keep it fun, keep it civil, and maybe even learn something new!

Cheers to all the AHK users out there and here's to 30,000. 🥂


r/AutoHotkey • • Nov 25 '21

Solved! AHK just saved me weeks of work

75 Upvotes

At work our ERP system has all the routings for parts that we build. This shows production every step that they have to do to make a part. Well, to enable our scheduling software, I needed to make a small change to every since step of every single routing.

We're talking thousands of parts, each with several production steps. This would have required lots of tedious clicking, saving, and closing screens. I learned about AHK a couple weeks ago and I was able to make a simple macro to help me out. I completed the routing update in about 6-8hrs including programming time instead of literal weeks of screwing around. Even with my incredibly crude program AHK has saved me so much time!

I'm hooked!


r/AutoHotkey • • Jan 17 '26

Meta / Discussion Mod change announcement

73 Upvotes

Hello,
Not too long ago I was appointed a moderator of this subreddit, and as of today I am no longer a moderator. This was partly my decision and partly the result of a misalignment and lack of communication with the existing mod, u/GroggyOtter.

During my time moderating, I tried several times to contact u/GroggyOtter to discuss moderation strategies and our vision for the subreddit. I reached out via PM and modmail but did not receive a response. Because of that, I assumed I was expected to handle day-to-day moderation on my own, as his post introducing me suggested I would be moderating independently.

Based on that understanding, I:

  • Created a clear set of rules (there were none before),

  • Set up AutoModerator to enforce some of those rules, and

  • Started looking for additional mods to share the workload (even if the load is small, nobody can be here 24/7/365).

I first recruited u/yellowizer (with limited permissions for a trial period). They have prior Reddit moderation experience, a long-standing Reddit account, and we seemed to share similar moderation views. Their AutoHotkey experience was limited, but they were enthusiastic, and most moderation decisions don’t require deep programming knowledge.

After that, u/GroggyOtter removed u/yellowizer from the mod team and contacted me, questioning that choice and indicating that I was expected to moderate alone. At that point it became clear that our expectations and approaches to moderation were not aligned, and I indicated that I was willing to step down if that was preferable.

The result is that I am no longer part of the mod team. Whether this change will affect the rules or how strictly they’re enforced is up to the remaining moderation. I hope u/GroggyOtter will clarify their plans for the subreddit going forward.

I’d like to thank everyone who engaged constructively while I was moderating. Please keep any discussion about this situation civil and do not harass anyone involved.

That’s all from me: thanks for your time and for being part of this community.


r/AutoHotkey • • Aug 19 '24 Take My Energy

v2 Tool / Script Share AHK Macro Recorder

72 Upvotes

I made a Macro Recorder in v2 based on feiyue's original script. This records keystrokes and has several options for mouse movement. You can run multiple instances of the script to set up as many keys as you want. This is my daily driver, but I figured a few of you could benefit from this.

https://youtu.be/9_l0rIXO9cU

https://github.com/raeleus/AHK-Macro-Recorder

Feiyue's original: https://www.autohotkey.com/boards/viewtopic.php?f=6&t=34184&sid=03fb579fcaef3c186e5568b72390ef9e


r/AutoHotkey • • Mar 24 '19

Over 40 Excel & AutoHotkey tutorials

72 Upvotes

I put together over 40 Excel & AutoHotkey tutorials. Using COM with AutoHotkey is a super-reliable way to automate Excel!

http://the-automator.com/excel-autohotkey/


r/AutoHotkey • • Mar 01 '25

General Question I automated my tasks, my boss loved it… but now I’m stuck

70 Upvotes

So, for the past 1.5 months, I’ve been automating my routine work tasks using AutoHotkey. A few days ago, I decided to show my scripts to my boss, and she was really impressed. She even introduced me to some project managers, who were also excited about the possibilities. Now they want to explore whether I can develop some simple scripts for the company.

Sounds great, right? Well… here’s the catch.

Before I can move forward, I need to get official approval to use AutoHotkey at work. As part of the process, my direct manager has to sign a document stating that she takes responsibility for my use of the program. And here’s where things get complicated.

I’ve only been using AutoHotkey for a short time, so I don’t fully understand the potential risks. I know I wouldn't intentionally cause issues, but what if I accidentally mess something up? On top of that, my manager isn’t very tech-savvy, and I worry that she doesn’t really understand what she’d be signing. If something goes wrong, we could both end up paying the price.

For context, I work for one of the largest companies in my country (Western Europe), so I assume they have decent IT security measures in place. But I’m stuck between wanting to move forward with automation and not wanting to put my boss—or myself—at risk.

Has anyone been in a similar situation? How did you handle it?


r/AutoHotkey • • May 19 '22

Meta / Discussion Shout out to the documentation

65 Upvotes

AHK was the first language I ever learned.

I think the only reason I was able to get anywhere with it was because of its amazing documentation.

Intuitive to find things.

Simple to read and understand.

F*#@ING CODE BLOCK EXAMPLES FOR E-V-E-R-Y THING

I have yet to see another language with documentation that even comes close.

Just wanted to say thanks!


r/AutoHotkey • • Oct 09 '26

Meta / Discussion Lexikos needs your help!

64 Upvotes

Note: Hopefully, it is okay to post this here. Please let me know if not.

Hello all, just thought I'd share this. Please consider sponsoring Lexikos (main AHK developer) if you are able to and you've enjoyed using AutoHotkey!

More is explained here: https://github.com/sponsors/Lexikos

He's poured countless hours into the tool we all know and love. In fact, nearly two decades!

If you are feeling generous and it's within your means, please think about it. 😄


r/AutoHotkey • • Dec 31 '21

I know it's not AHK related but...

63 Upvotes

There's an awesome team at work here on a regular basis and you know who you are - you're the backbone that keeps this sub together and I couldn't be more proud to be a part of it...

Special shout-out to the mods who keep this sub active despite working full-time jobs too!

So, from myself (Will), I'd like to wish you all a very Happy New Year, and all the very best for 2022!


r/AutoHotkey • • Mar 01 '20

The Magic of AutoHotkey - A rundown of my AutoHotkey stack

62 Upvotes

First time on this sub. I don't know if articles get published a lot here, but I didn't see anything in the rules against it so, I'm hoping this is okay.

I've started documenting my automation stack that I've been developing + using for the past seven years. I hope to do a part-2 in a week or two if there's interest.

https://sharats.me/posts/the-magic-of-autohotkey/

Thank you for checking it out!


r/AutoHotkey • • Nov 15 '25

Resource I built a tool that turns any Autohotkey script into a native windows service

60 Upvotes

Whenever I needed to run an app as a windows service, I usually relied on tools like sc.exe, nssm, or winsw. They get the job done but in real projects their limitations became painful. After running into issues too many times, I decided to build my own tool: Servy.

Servy is a Windows tool that lets you turn any app including any Autohotkey script into a native windows service with full control over the working directory startup type, process priority, logging, health checks, environment variables, dependencies, pre-launch and post-launch hooks, and parameters. It's designed to be a full-featured alternative to NSSM, WinSW, and FireDaemon Pro.

Servy offers a desktop app, a CLI, and a PowerShell module that let you create, configure, and manage Windows services interactively or through scripts and CI/CD pipelines. It also includes a Manager app for easily monitoring and managing all installed services in real time.

To run an AutoHotkey script as a Windows service, you just need to:

  1. Set service name

  2. Set process path to: C:\Program Files\AutoHotkey\v2\AutoHotkey.exe

  3. Set process parameters to your AutoHotkey script, for example: C:\scripts\service.ahk

  4. Click install then start

If you need to keep Autohotkey scripts running reliably in the background at boot, before logon, and without rewriting them as services, this might help.

GitHub Repo: https://github.com/aelassas/servy

Demo video: https://www.youtube.com/watch?v=biHq17j4RbI

Sample AutoHotkey script used for testing: https://github.com/aelassas/servy/blob/main/tests/AutoHotkey.ahk

Any feedback is welcome.