Page 1 of 1

Monitor sysget breaks code that works with ghost variables?

Posted: 19 Oct 2018, 05:50
by Noo0B
Hi,
I had this script working perfectly, but today I noticed I could have deleted this code:
SysGet, Monitor2, Monitor, 2

I tried adding it again, but it started breaking the script.
So I changed it to Mon2 for the output variable, and noticed the part of the script still using Monitor2 would work, but not the one using mon2.
So I wrote this test script, and basically it would work with anything but the SysGet OutputVar:
XButton1 & 1::
If (Monitor2Left = -%A_ScreenWidth% OR Monitor2Right = 2*%A_ScreenWidth%)
MsgBox DualScreen 1
Return
XButton1 & 2::
SysGet, Monitor2, Monitor, 2
If (PrettyMuchAnything = -%A_ScreenWidth% OR AnythingReally = 2*%A_ScreenWidth%)
MsgBox DualScreen 2
Return
XButton1 & 3::
SysGet, Monitor2, Monitor, 2
If (Monitor2Left = -%A_ScreenWidth% OR Monitor2Right = 2*%A_ScreenWidth%)
MsgBox DualScreen 3
Return

Is anyone else able to confirm this?
Best regards.

Re: Monitor sysget breaks code that works with ghost variables?  Topic is solved

Posted: 19 Oct 2018, 06:25
by swagfag

Code: Select all

If (PrettyMuchAnything = -%A_ScreenWidth% OR AnythingReally = 2*%A_ScreenWidth%)
u use %% inside an expression if (). dont use %% here. this expression is evaluated as follows:
1. get the value of A_Screenwidth, lets say 1080
2. %1080% - look for a variable called '1080' and get its value. Its blank, since the variable doesnt exist
3. PrettyMuchAnything is also blank.
4. blank = blank => True

Re: Monitor sysget breaks code that works with ghost variables?

Posted: 19 Oct 2018, 11:20
by Noo0B
Thanks for the answer!
I have used these variables without quotes all the time on all my other scripts.
Somehow in this script It took some time to get it going with the quotes and it worked for about a month with them, and now testing it works without them like all other scripts again.
I wonder if I typoed something on the sysget parameter.
I took this line from this script and used it in another script; then used it to replace what I accidentally erased.
Maybe I typoed and corrected it on the other script, not quite sure, I might have a vague memory of doing so.
Regardless, seems to be the only way to explain how the code worked with them quotes.
Very smart of you!
Thanks again!
Best regards!
Now, back to my moving perimeter breach scan code test :D