sysget MonitorWorkArea not a number on negative values...

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Corne Beerse

sysget MonitorWorkArea not a number on negative values...

11 Dec 2015, 04:28

[Moderator's note: Topic moved from Bug Reports.]

With SysGet, example 2 on https://autohotkey.com/docs/commands/SysGet.htm, I fetch %MonitorWorkAreaLeft%. This prints as expected. With my left most monitor, I see the next text:

Code: Select all

Monitor: #3
Name: \\.\DISPLAY3
Left:  -1600 (-1600 work)
Top:   0 (0 work)
Right: 0 (0 work)
Bottom: 1200 (1200 work)
With WinMove, I like to put my application window 50 points inside the left side border. Hence I use the next code:

Code: Select all

; VissionApp on highest monitor number.
SysGet, VissionAppMonitor, MonitorCount
SysGet, MonitorName, MonitorName, %VissionAppMonitor%
SysGet, Monitor, Monitor, %VissionAppMonitor%
SysGet, MonitorWorkArea, MonitorWorkArea, %VissionAppMonitor%
; use the work areay, not the full area to leave room for the windows bar
;  resize to a little smaller than the monitor size (50 pixels within the monitor)
VissionAppSubTop := (%MonitorWorkAreaTop% + 50)
VissionAppSubLeft := (%MonitorWorkAreaLeft% + 50)
VissionAppSubRight := (%MonitorWorkAreaRight% - 50)
VissionAppSubBottom := (%MonitorWorkAreaBottom% - 50)
WinMove, VissionAppCBee - visionapp Remote Desktop,, %VissionAppSubLeft%, %VissionAppSubTop%, %VissionAppSubRight%, %VissionAppSubBottom%
The above code is bailing out with the next error:

Code: Select all

Error: The following variable name containts an illegal character: "-1600"
Line#
        043: SysGet, MonitorName, MonitorName, %VissionAppMonitor%
        044: SysGet, Monitor, Monitor, %VissionAppMonitor%
        045: SysGet, MonitorWorkArea, MonitorWorkArea, %VissionAppMonitor%
        046: VissionAppSubTop := (%MonitorWorkAreaTop% + 50)
--->   047: VissionAppSubLeft := (%MonitorWorkAreaLeft% + 50)
        048: VissionAppSubRight := (%MonitorWorkAreaRight% - 50)
        046: VissionAppSubBottom := (%MonitorWorkAreaBottom% - 50)
So somehow the code at line 045, the SysGet fetches nice numbers: Line 046 works, %MonitorWorkAreaTop% contains a valid number. However, if the number is negative ("-1600"), it is not regarded as a negative number and bailing out with an error.

Is there something I can do to work around this issue? Should I use a 'convert text to number' function? (which one?).

The program works as long as my primary monitor is the top and/or left most monitor. However, the program fails if I like to put a window on any window with negative locations, like one on the left or one at the top.
just me
Posts: 9458
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: sysget MonitorWorkArea not a number on negative values...

11 Dec 2015, 04:41

Code: Select all

VissionAppSubTop := (%MonitorWorkAreaTop% + 50)
is an expression, so remove the % signs. (See also.)

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: filipemb, jaka1 and 171 guests