My script worked well, but since yesterday I get this message when trying to run the following script:Error: This variable has not been assigned a value.
Specifically: global vscode
If (A_ThisMenuItemPos = 1)
{
▶ Run(vscode ' ' RW1Script), WinWait(winTitle,, 3)
WinActivate()
}
running !a to show Menu Command, and clicking on fx. Arrays → should open Arrays.ahk in VScode:
Code: Select all
#Requires AutoHotkey v2.0
SendMode("Input") ; Recommended for new scripts due to its superior speed and reliability.
#SingleInstance Force
SetWorkingDir(A_ScriptDir) ; Ensures a consistent starting directory.
#Include "%A_ScriptDir%/lib/Hotstrings.ahk"
global vscode, winTitle, RW1Script, RW2Script, Arrays,
vscode := EnvGet('LOCALAPPDATA') "\Programs\Microsoft VS Code\Code.exe"
winTitle := 'ahk_exe' vscode
RW1Script := A_ScriptDir "/RW1Script.ahk"
RW2Script := A_ScriptDir "/RW2Script.ahk"
Arrays := A_ScriptDir '\lib\Arrays.ahk'
#HotIf !WinActive("ahk_class OpusApp")
~!a::
{
MyMenu := Menu()
MyMenu.Add("1.RWscript", MenuHandlerA)
MyMenu.Add("2.RWscript", MenuHandlerA)
MyMenu.Add("Arrays.ahk", MenuHandlerA)
MyMenu.Show()
}
MenuHandlerA(A_ThisMenuItem, A_ThisMenuItemPos, MyMenu)
{
If (A_ThisMenuItemPos = 1) {
Run(vscode ' ' RW1Script), WinWait(winTitle,, 3)
WinActivate
} else if (A_ThisMenuItemPos = 2) {
Run(vscode ' ' RW2Script), WinWait(winTitle,, 3)
WinActivate
} else if (A_ThisMenuItemPos = 3) {
If !WinExist(winTitle)
Run(vscode ' ' Arrays), WinWait(winTitle,, 3)
WinActivate
}
}
it would also be nice to adjust the script so any errors will come up when trying to run the main script (clicking on the above script´s .ahk file) instead of getting an error message first when trying to use the !a hotkey to open a file.