Search code examples
autohotkey

How to get an AHK console?


I'm constantly trying to run quick tests in AHK. It's a pain to have to think of a new hot key, write all the environmental variables, save, build, etc. I'd like to be able to type out a short test, press enter, and get some feedback from AHK.

Where is the AHK console? / Is there a way to run quick commands from a console-type entity?

For instance: I'd type Run, Notepad in an AHK console, press enter, Notepad opens, and some feedback is displayed in the console. Then I can go back, play around with options, press enter, etc. So it would look like this:

> Run, Notepad
Running Notepad.exe
Activating Window Untitled - Notepad, ahk_class Notepad, ahk_id ...
Window Active
> Run, NotARealThing
Error: Could not find 'NotARealThing'
> 

Things I've tried

  1. GirlGamer's "Script for quick run of scripts" However...

    • I get an error at Run, TempScript.ahk because the system could not find it, even though FileAppend is supposed to create a new file if it doesn't exist.
    • With that said, the GUI (^!W) is pretty close to what I'm looking for. But, I'd like to press Enter and have it run, and Shift+Enter goes to the next line...
    • Also there's no feedback in the window. It would be nice to see everything AHK is doing while it's processing my quick test.
  2. AutoHotkey Console Log/WriteLine Equivalent.

    • Initially I thought this was the solution, but it says "If you run this from console..." What console?

    • Furthermore, it claims you can do something like > AutoHotKey test.ahk but I see a few problems with this:

    • My system doesn't recognize AutoHotKey as a command. I'm sure this means I simply need to add the path to AutoHotKey.exe to my PATH variable.
    • Will this only allow me to run saved files? If so, That defeats the purpose of having a console to run quick tests.
    • "AutoHotKey" is not something I want to type every time I run a quick test. I'd much rather run a console from SCiTE4AHK and do rapid tests there.
  3. SCiTE4AHK but I don't see anything that says "console" there...

  4. Hachi's answer to "Best way for debug ?"

    • "so run from console myscript.ahk >log.txt or myscript.ahk |more"

    • Is this referring to an actual AHK console, or that his script would create a console-esque entity?
  5. Also a bunch of Google search results. But it seems like everything refers to the console, never how to actually get to the console. What am I missing?


Solution

  • Ahk doesn't work like that, out of the box. The Console they are referring to is the Windows Command console. Now with that said:

    Check this out: https://github.com/G33kDude/Console And this: https://autohotkey.com/boards/viewtopic.php?f=6&t=6113