Windows 7 detecting monitor

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Basilisk
Posts: 4
Joined: 19 Apr 2017, 11:30

Windows 7 detecting monitor

19 Apr 2017, 11:51

Apparently, if you boot Windows 7 and are using a KVM switch
that isn't switched to that computer, Windows won't load the
driver last used, and the screen resolution is wrong.

Trying to write a script that detects the monitor and sets the
proper screen resolution. Here's what I have:

Code: Select all

; Define hotkey combo: Ctrl-Shift-Alt-K
^+!k::

; Minimize All Windows
WinMinimizeAll

; Wait a bit
Sleep 200

; Right click in the upper left of the screen:
MouseClick, right, 1, 1

; Wait a bit:
Sleep, 5

; Windows 7 -----------------------------------
; Send the letter "c" to get sCreen Resolution:
Send, c

; Or send "down":
; Send, {Down 9}

; Wait a bit:
Sleep, 5

; Select by sending Enter:
; Send, {Enter}

; Wait a bit:
Sleep, 20

; Click the button --- DOESN'T WORK:
; ControlClick, Detect, Screen Resolution

; Send the letter "c" to get deteCt -- DOESN'T WORK:
; Send, c

; Click the button -- DOESN'T WORK:
ControlClick, x700 y180, Screen Resolution

Any ideas on how to click the "Detect" button or select the
proper driver or set the proper screen resolution?

Thanks for any light you can shed.
chef423
Posts: 213
Joined: 28 Aug 2016, 12:10
Contact:

Re: Windows 7 detecting monitor

19 Apr 2017, 12:32

Good luck I am trying to get help on this very issue a few posts down...
Basilisk
Posts: 4
Joined: 19 Apr 2017, 11:30

Re: Windows 7 detecting monitor

22 Apr 2017, 13:50

This is what I came up with finally:

Code: Select all

MonitorDetected := FALSE

; Begin: While loop
While(MonitorDetected = FALSE)
  {

  ; Minimize All Windows
  WinMinimizeAll

  ; Wait a bit
  Sleep 200

  ; Start: get focus on desktop ---------------------------------
  WinActivate, Program Manager

  ;WM_LBUTTONDOWN  0x0201
  PostMessage, 0x201, 1, 0, SysListView321, Program Manager

  ;WM_LBUTTONUP  0x0202
  PostMessage, 0x202, 0, 0, SysListView321, Program Manager

  Send, {AppsKey}
  ; End: get focus on desktop ---------------------------------

  ; Right click in the upper left of the screen:
  MouseClick, right, 1, 1

  ; Wait a bit:
  Sleep, 200

  ; Windows 7 -----------------------------------
  ; Send the letter "c" to get sCreen Resolution:
  Send, c

  ; Or send "down":  -- doesn't work
  ; Send, {Down 9}

  ; Select by sending Enter: -- doesn't work
  ; Send, {Enter}

  ; Wait a bit:
  Sleep, 200

  ; Click the button -- Doesn't work:
  ; ControlClick, Detect, Screen Resolution

  ; Send the letter "c" to get deteCt: -- Doesn't work
  ; Send, c

  ; Click the button - works!
  ControlClick, x700 y180, Screen Resolution

  ; Get the title of the window with focus:
  WinGetActiveTitle, DisplayWinTitle
  ; MsgBox The title is: %DisplayWinTitle%

  ; Get the text of that window:
  WinGetText, DisplayWinText, %DisplayWinTitle%

  ; Show found text:
  ; MsgBox Found text: %DisplayWinText%

  ; What is the monitor string of our monitor?
  SearchString = XXXXXX
  ; MsgBox The SearchString: %SearchString%

  ; Has that string been found?
  IfInString, DisplayWinText, %SearchString%
    {
    MonitorDetected := TRUE
    ; MsgBox, The string %SearchString% was found.
    }
  else
    {
    ; MsgBox, The string %SearchString% was not found.
    }

  ; End: While loop
  }

; Wait a bit:
Sleep, 200

; Close the Screen Resolution window:
WinClose Screen Resolution

; Wait a bit:
Sleep, 200

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 399 guests