March 9, 2022

Running AHK Script from the command line / Use Teamsy with the Stream Deck

I got this question "How to run the Teamsy PowerTool for Microsoft Teams from the Stream Deck using the command line". I had myself to look deeper at it and learned some stuff I share in this post.

Screencast


Question

How to run the Teamsy PowerTool for Microsoft Teams from the Stream Deck using the command line?

Answer

Teamsy.ahk Source code

If (A_Args.Length() = 0)  {
    PowerTools_MenuTray()
    PowerTools_Help("Teamsy") ; open help page
    TrayTip, Teamsy, See help. Script shall not be run standalone!

    ; Tooltip
    If !a_iscompiled
        FileGetTime, LastMod , %A_ScriptFullPath%
    Else
        LastMod := LastCompiled
    FormatTime LastMod, %LastMod% D1 R

    sTooltip = Teamsy %LastMod%`nRight-Click on icon to access help/support.
    Menu, Tray, Tip, %sTooltip%
} ; end icon tray

If (A_Args.Length() > 0)
    Teamsy(A_Args[1])
return

To run the source ahk file via command line, you need to call the AHK.exe before the .ahk script as explained in the documentation, for example like this:
C:\Users\thierry.dalon\PortableApps\AutoHotkey\AutoHotkeyU64.exe C:\GitHub\ahk\Teamsy.ahk mu

Calling the .ahk file directly like this doesn't work

C:\GitHub\ahk\Teamsy.ahk mu

The argument is not passed.

But calling a compiled script from the command directly with arguments like this, works:

C:\GitHub\ahk\PowerTools\Teamsy.exe mu

If you have spaces in the path you need to put the path between quotes "
For the argument, you don't have to use quotes.

See also

Scripts - Definition & Usage | AutoHotkey

autohotkey - How to pass command-line arguments to AHK script? - Super User

No comments:

Post a Comment