I tried to convert an existing script, and am getting the following error:
Error: This variable has not been assigned a value.
Specifically: local Monitor (same name as a global)
011: If GetKeyState("Control")
012: {
▶ 013: If (Monitor = "gaming")
014: {
015: run("c:\controlmymonitor\ControlMyMonitor.exe /SetValue Primary 60 17")
I noticed by adding Global above the line: if GetKeyState("Control"), it executes
the script,
Code: Select all
#Requires AutoHotkey v2
#MaxThreadsPerHotkey 2
Persistent
Monitor := "gaming"
^g::
~LButton & RButton::
{
if GetKeyState("Control")
{
if (Monitor = "gaming")
{
run "c:\controlmymonitor\ControlMyMonitor.exe /SetValue Primary 60 17" ; switch to work pc
Monitor := "work"
}
}
else
{
run "c:\controlmymonitor\ControlMyMonitor.exe /SetValue Primary 60 1" ; switch to gaming pc
Monitor := "gaming"
}
return
}