Import an AutoHotkey script
Open a compatible AutoHotkey script, see what it needs and play it. AutoHotkey never runs and your file is never changed.
What this does
AutoHotkey is a separate program that plays small script files ending in .ahk. LuvMacro can open some of them. It reads the file as plain text, turns the parts it understands into a macro it can play, and tells you what it found.
Open a script
- Press Open… and choose the .ahk file. Opening a file never plays it.
- LuvMacro converts the script and says what it found: how many pictures it needs, which keys it uses and which screen size it was written for.
- Press Import details in the main window to read the full list before you play.
- Press Play or F7. When the start delay is over, the status says Playing.
- Many scripts wait for their own key, such as F1. Switch to the window you want to control and press that key. LuvMacro lists the keys before it starts.
- Press Stop or F8 whenever you want it to end. See Emergency stop.
While a script plays, its own keys work. If a script wants the same key as LuvMacro's Record, Play or Stop shortcut, LuvMacro keeps its own and leaves the script's key out, so you can always stop.
If a script keeps running until you stop it, a Start over button appears while it plays. It runs the script again from the beginning.
Which scripts work
AutoHotkey version 2 scripts are the main target. A smaller part of version 1 also works. A line such as #Requires AutoHotkey v2.0 at the top tells LuvMacro which version to expect.
If LuvMacro cannot tell which version a script is written for, it stops and asks for a #Requires line (LM-8003). It does not guess.
What LuvMacro can convert
- Pressing keys and typing text (
Send,SendText) - Moving the mouse and clicking (
MouseMove,Click,MouseClick) - Waiting (
Sleep) - Repeating things and choosing between things (loops,
ifandelse) - Remembering values in variables, lists and maps, and small functions
- Timers (
SetTimer) and the script's own hotkeys such asF1:: - Looking for a picture or a colour on the screen (
ImageSearch,PixelSearch,PixelGetColor) - Showing a message or a tooltip
Version 1 scripts can use the older style of the same commands. A few parts of version 1 are not converted, for example for loops, switch and Goto.
What is refused, and why
If any part of a script that affects what it does cannot be converted, LuvMacro refuses the whole import. It lists exactly what and where. Nothing is skipped silently, and nothing is run.
- Blocked for your safety (LM-8008). LuvMacro macros can only press keys, move the mouse, look at the screen and show messages. A script that starts other programs (
Run), loads system libraries (DllCall), reads or writes files, changes the registry, downloads things, runs text as code or includes other files is refused. - Not converted yet (LM-8004). Examples are hotstrings, classes, regular expressions, many text functions (
InStr,StrReplace,Format,Random),KeyWait,GetKeyStateand hotkeys that depend on a condition. - Too big or too tangled (LM-8005). The script is longer or more deeply nested than LuvMacro will import.
- A mistake in the script (LM-8006). LuvMacro names the line and column.
- The file itself (LM-8001, LM-8002, LM-8003). It could not be read or is over 1 MB, it is not an AutoHotkey script, or LuvMacro cannot tell which version it is written for.
Search the code in Error codes for the steps to try.
Pictures and the img folder
Scripts that look for a picture on the screen need the picture files, and an .ahk file does not contain them. Put the PNG pictures in a folder called img next to the script, or in the same folder as the script, then open the script again.
LuvMacro finds pictures by file name. Capital letters do not matter, and it ignores any folder names written inside the script. Each picture can be up to 2 MB.
Import details lists the pictures it found and the pictures it is missing. A script that is missing pictures will not play. LuvMacro names them and presses nothing. See Missing pictures.
Screen size
Many scripts are written for one screen size, often 1920 × 1080. Import details shows the size the script was written for and your own. If they differ, LuvMacro tells you in plain words. Clicks and picture searches may land in the wrong places on a different screen. See Screen sizes and scaling.
How it differs from AutoHotkey
Import details lists the differences that apply to your script. The main ones:
- Stopping ends everything that is running. Pressing Stop, or a script stopping one of its timers, also ends the part of the script that was still running. AutoHotkey would let it finish. This is on purpose, so that a key can never be left held down.
- Starting again starts from the top. All the script's variables go back to their first values.
- The mouse jumps. Mouse speed settings are ignored, so the pointer moves straight to its place.
- Some settings are ignored. Key delay and mouse delay settings, for example, are reported and then ignored.
- Lists start at zero inside LuvMacro. LuvMacro adjusts the numbers for you, so the script behaves as you wrote it.
- Small display differences. Tooltip positions, message box titles and icons are not kept.
LuvMacro also warns when it sees a pattern that behaves differently, such as a timer that waits inside itself, or a clock that keeps counting while the game window is not in front.
Edit and save
You can edit a converted script step by step. See Edit a macro. LuvMacro cannot save or export AutoHotkey: there is no "save as .ahk". Saving writes a new .luvmacro file. You can read the original script, read only, from the editor's Original script button.
