Home | Blog | Software | Reviews and Features | Forum | Help | Donate | About us
topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • September 27, 2016, 08:44:13 PM
  • Proudly celebrating 10 years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: Need a script to auto detect display  (Read 2554 times)

glasskuter

  • Supporting Member
  • Joined in 2015
  • **
  • default avatar
  • Posts: 4
    • View Profile
    • Donate to Member
Need a script to auto detect display
« on: July 14, 2015, 03:27:16 PM »
Hi Guys, I have an old kvm switch  that does not have active ddm so I am always having to go to screen resolution and  "detect display"
so that I have the proper resolution..
Could someone help me write a script that I could make a shortcut to that would accomplish this.  Also, since I don't know anything about scripts, do I need some sort of program to run it?
Thanks
« Last Edit: July 14, 2015, 03:33:39 PM by glasskuter »

4wd

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 4,403
    • View Profile
    • Donate to Member
Re: Need a script to auto detect display
« Reply #1 on: July 14, 2015, 10:44:18 PM »
If you open a Powershell console you can try the following:

Code: PowerShell [Select]
  1. Get-CimInstance -Namespace root\wmi -ClassName WmiMonitorBasicDisplayParams

Attached is a script with the command and a shortcut to run it.

You should get something similar to the following output, (output for each monitor connected):

Code: Text [Select]
  1. Active                        : True
  2. DisplayTransferCharacteristic : 120
  3. InstanceName                  : DISPLAY\VSCD920\5&22dca72a&0&UID261_0
  4. MaxHorizontalImageSize        : 41
  5. MaxVerticalImageSize          : 26
  6. SupportedDisplayFeatures      : WmiMonitorSupportedDisplayFeatures
  7. VideoInputType                : 1
  8. PSComputerName                :
  9.  
  10. Active                        : True
  11. DisplayTransferCharacteristic : 120
  12. InstanceName                  : DISPLAY\DEL4005\5&22dca72a&0&UID262_0
  13. MaxHorizontalImageSize        : 34
  14. MaxVerticalImageSize          : 27
  15. SupportedDisplayFeatures      : WmiMonitorSupportedDisplayFeatures
  16. VideoInputType                : 1
  17. PSComputerName                :
  18.  
  19.  
  20. Press a key to exit ...

If it works and you don't want the output:
Code: PowerShell [Select]
  1. Get-CimInstance -Namespace root\wmi -ClassName WmiMonitorBasicDisplayParams | Out-Null
« Last Edit: August 31, 2015, 09:05:26 PM by 4wd »

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,159
    • View Profile
    • Miles Ahead Software
    • Donate to Member
Re: Need a script to auto detect display
« Reply #2 on: July 15, 2015, 02:22:35 PM »
I was under the impression the OP wanted something that would put the monitor into the desired resolution without having to drill down manually into the setting.  But I could be mistaken.

My Belkin kvma switch used to set the screen mode when switching to another machine, even if the monitor was already in the desired mode.  There was some reason they did it that way but I can't remember it now.  :)


4wd

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 4,403
    • View Profile
    • Donate to Member
Re: Need a script to auto detect display
« Reply #3 on: July 15, 2015, 09:33:26 PM »
I guess it depends how you read it:

... I am always having to go to screen resolution and  "detect display"
so that I have the proper resolution..

I read it as the system doesn't automatically detect the native resolution of the monitor, (so defaults to 1024x768 or something), because DDC isn't being resent/requested on switch-over, so telling the system to go identify monitors should get it resent and fix the resolution.

@glasskuter: Can you clarify what you mean, (eg. you need to set resolution also)?
« Last Edit: July 16, 2015, 01:07:49 AM by 4wd »

glasskuter

  • Supporting Member
  • Joined in 2015
  • **
  • default avatar
  • Posts: 4
    • View Profile
    • Donate to Member
Re: Need a script to auto detect display
« Reply #4 on: July 16, 2015, 10:09:51 AM »
4wd your script does exactly what I needed. Wish I had found this site a long time ago. Excellent work.  I really appreciate your time and effort on my part.  I wish I was as proficient in dealing with code.  I hope all fellow kvm users find this solution.  Thank you so much.

glasskuter

  • Supporting Member
  • Joined in 2015
  • **
  • default avatar
  • Posts: 4
    • View Profile
    • Donate to Member
Re: Need a script to auto detect display
« Reply #5 on: July 16, 2015, 10:29:55 AM »
4wd, I just now  donated to this site but can't figure out how to give you donation credits.  Says I don't have any $ in the account.

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 36,261
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: Need a script to auto detect display
« Reply #6 on: July 16, 2015, 10:36:15 AM »
glasskuter, after you donate you will receive an email with a license key (for our other big software), and a link to visit that will upgrade your forum account and put the money in your account where you can give it out.  so just visit that link and then you'll be able to give out your donation.

Let me just say how great it is to see threads like this, where someone has a request and someone else solves it.   The icing on the cake is when the original person who made the request is willing to go through the steps to give a donation to the coder -- it means a lot.  :-*

In cases like this, it's important not just that people donate, but that they go through with the extra step as you are, and send their donation to the person who helped them.  If anyone ever gets lost and needs help directing their donation to someone on the site, and can't figure out how to do it, please don't hesitate to contact us (mouser@donationcoder.com) and I will assist.  :up:

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,159
    • View Profile
    • Miles Ahead Software
    • Donate to Member
Re: Need a script to auto detect display
« Reply #7 on: July 16, 2015, 01:16:09 PM »
@glasskuter glad you and 4wd were on the same page after all.   :up:

4wd

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 4,403
    • View Profile
    • Donate to Member
Re: Need a script to auto detect display
« Reply #8 on: July 16, 2015, 08:48:49 PM »
4wd your script does exactly what I needed. ...  Thank you so much.

You're welcome, actually you don't even need the script, it can all be done in the shortcut, ie. change the Target field to:

Code: PowerShell [Select]
  1. %SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -noprofile -executionpolicy bypass -Command "Get-CimInstance -Namespace root\wmi -ClassName WmiMonitorBasicDisplayParams | Out-Null"

Attached below.
« Last Edit: August 31, 2015, 09:05:52 PM by 4wd »