Script error when running on new pc

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
Gligum
Posts: 3
Joined: 14 Dec 2024, 00:56

Script error when running on new pc

Post by Gligum » 14 Dec 2024, 01:09

I've been using a script for switching between the same windows of a given application on Windows(similar to "cmd + `" on mac) for quite a while, and have had no issues with it. I did a fresh install of windows on a new hard drive today, and I can't get the script process correctly. I have rolled back to the version that was installed on my old hard drive(v2.0.15) and copied the script over, but I get the same error on v2.0.15 as I did on a fresh install with v2.0.18, but only after my fresh windows install. Any insight into something I might be missing?

Error:

Code: Select all

Error: Function calls require a space or "(".  Use comma only between parameters.
Text:	WinGet, ActiveProcessName, ProcessName, A
Line:	2

Script:

Code: Select all

!`::
WinGet, ActiveProcessName, ProcessName, A
WinGet, WinClassCount, List, ahk_exe %ActiveProcessName%

if (WinClassCount = 1)
    return

if (NextWindow = "")
    NextWindow := 2

element := % WinClassCount%NextWindow%

WinSet, Top,, ahk_id %element%
WinActivate, ahk_id %element%

NextWindow += 1

if (NextWindow > WinClassCount || !getKeyState("Alt"))
    NextWindow := 2

return

just me
Posts: 9866
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Script error when running on new pc

Post by just me » 14 Dec 2024, 05:11

Your code is v1! Try to add

Code: Select all

#Requires AutoHotkey v1.1
at the top of your script.

Gligum
Posts: 3
Joined: 14 Dec 2024, 00:56

Re: Script error when running on new pc

Post by Gligum » 14 Dec 2024, 10:53

Is this despite the fact that the version installed on my previous drive is v2.0.15? This was one of the first things I verified, what version was installed previously vs now, and whether or not I get any warnings about a v1 script vs v2

User avatar
gregster
Posts: 9253
Joined: 30 Sep 2013, 06:48

Re: Script error when running on new pc

Post by gregster » 14 Dec 2024, 11:09

Your script above can not work on v2.
If it worked, you had also a v1 version installed. After all, AHK is designed to have both v1 and v2 versions installed at the same time.

Compare https://www.autohotkey.com/docs/v2/Program.htm#launcher

Gligum
Posts: 3
Joined: 14 Dec 2024, 00:56

Re: Script error when running on new pc

Post by Gligum » 14 Dec 2024, 16:09

Ok, that's clear enough, I hadn't realized apparently that I had installed v2 on top of v1, nor that both existing simultaneously was supported. Thanks for clearing that up!

Post Reply

Return to “Ask for Help (v2)”