How To Use "_displaychange"

43 views
Skip to first unread message

PeterC

unread,
May 2, 2019, 6:11:30 PM5/2/19
to Bayden
Hi

I'd like more help re. how to use the event handler "_displaychange" please.

I'm hoping it can be used to detect the display resolution and set the position of SR automatically to predefined coords based on the screen size being detected.

I currently use two SlickRun words to set it to my two common display resolutions that I use frequently when I change from using the laptop builtin display to using it via remote desktop (at a much higher resolution).

Thanks
Peter C

EricLaw

unread,
May 14, 2019, 2:09:22 PM5/14/19
to Bayden
Hi, Peter--

In SlickRun, you can create MagicWords that move the window to a particular location using the SavePos "factory" MagicWord. (e.g. see https://groups.google.com/forum/#!searchin/bayden/_displaychange%7Csort:date/bayden/TbPZbeDC080/KmcZzHS1tywJ)

Now, what you're looking for is a bit more advanced-- you want to use _displaychange to invoke a script that evaluates the screen resolution and then invokes SlickRun with a SavePos-created MagicWord depending on the resolution. Sadly, this is currently a "Some Assembly Required" task. You can use wmic desktopmonitor get screenwidth to get the screen's width, but you'd still have to write a bit of code to interpret that.

One way to do this is to use VBScript. Save the following as MoveSR.vbs

strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_DesktopMonitor",,48)

' Find widest monitor
maxWidth = 0
For Each objItem in colItems
if (maxWidth < objItem.ScreenWidth) then maxWidth = objItem.ScreenWidth
Next

WScript.Echo (maxWidth)

Set objShell = CreateObject("Wscript.Shell")  
if (maxWidth < 1000) then 
   objShell.run "sr.exe corner"
else
   objShell.run "sr.exe gohome"
End if

... replacing the yellow-highlighted pieces with the resolution and MagicWord names of your choice. Then, create a MagicWord like

MagicWord: _DISPLAYCHANGE
Filename: wscript
Parameters: C:\tools\moveSR.vbs
Notes: Move SlickRun based on screen resolution

Peter Carless

unread,
May 14, 2019, 6:22:43 PM5/14/19
to bay...@googlegroups.com
Eric

Thank you very much for "going beyond the call of duty" in providing the extra code.

I certainly give it a go!

Again, thank you.
Peter Carless
0414 374 763


--
You received this message because you are subscribed to the Google Groups "Bayden" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bayden+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bayden/3167a280-0d16-4a40-a6b9-131162f81b60%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

PeterC

unread,
May 14, 2019, 8:33:46 PM5/14/19
to Bayden
Eric

Unfortunately this only provides the dimensions of the physically attached screen (e.g. 1920), not the remote desktop screen (e.g. 2560).

Doing a web search I couldn't find an answer to how to get the RDP window size :-(

Looks like I'm stuck with doing it manually each time I log on to a different screen resolution.

Thanks
Peter C
To unsubscribe from this group and stop receiving emails from it, send an email to bayden+unsubscribe@googlegroups.com.

EricLaw

unread,
May 20, 2019, 12:30:37 PM5/20/19
to Bayden
Interesting. If you run wmic path Win32_VideoController get VideoModeDescription
from a console inside the RDP session, what information does it return?

PeterC

unread,
May 20, 2019, 4:36:54 PM5/20/19
to Bayden
It displays the physical local monitor screen resolution, not the RDP screen, i.e. 1920 x 1080, not the 2560 x 1440 remote screen.
To unsubscribe from this group and stop receiving emails from it, send an email to bay...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages