Sign in to follow this  
Followers 0
saywell

Win 7 Display detect

17 posts in this topic

Hi,

I've just set up a new Win 7 box for photographic work, and have added a second monitor.

Monitor 1 is the old monitor, shared via KVM switch with other PCs. monitor 2 is connected only to this new PC.

There's a bug/feature in Win 7 such that if one display is disconnected [eg the main monitor switched to another PC by KVM], it loses the other monitor output also.

It comes back if you get Win 7 to 'detect'. This can be done via a right-click to the desktop and select 'change resolution', where there's a link [not button] to detect displays. This dialogue can also be forunfd via control panel.

OR

By pressing <WIN><P> which brings up the projector/multi-monitor dialogue strip, on which there's also a 'detect' option.

I'd like to write a script for a single hot-key press to automate this, but am having no joy interacting with these controls - the autoit windows info tool doesn't recognise them.

I can do s Send to emulate the <WIN><P> presses but sometimes it opens with focus at the start, and sometimes it remembers the last used, and sets focus at 'detect' so i can't just send a couple of Tabs and a return to simulate the key presses.

Anyone got any suggestions to help here?

Regards,

William

PS the Nvidia software doesn't have this ability, so it has to be via Windows7.

Share this post


Link to post
Share on other sites



You need to transalte the German strings!!!

pt('MustDeclareVars', 1)
HotKeySet('{ESC}', '_exit')
_toggleMonitor()
_exit()
Func _toggleMonitor()
; Settings
Local Const $SystemSleepTime = 2000
Local Const $OnScreenText = 'Bitte Warten ... ESC = Abbruch'
; Script variables
Local Const $screenshot_BMP = @TempDir & 'second_Monitor_screenshot.jpg'
Local Const $title = 'Eigenschaften von Anzeige'
Local Const $text = '&Windows-Desktop auf diesem Monitor erweitern'
_ScreenCapture_SetBMPFormat(4)
_ScreenCapture_Capture($screenshot_BMP)
SplashImageOn("", $screenshot_BMP, @DesktopWidth, @DesktopHeight, -2, -2, 1)
Local $hwnd = GUICreate('', @DesktopWidth, @DesktopHeight, @DesktopWidth * 0.3, @DesktopHeight - 150, $WS_POPUP, BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))
GUISetBkColor(0x00FF00)
Local $rgn = CreateTextRgn($hwnd, 'Bitte Warten ... ESC = Abbruch', 40, "Arial", 1000)
SetWindowRgn($hwnd, $rgn)
GUISetState(@SW_SHOW, $hwnd)
DllCall('User32.dll', 'int', 'ShowCursor', 'int', False)
; Eingeschaftenfenster öffnen
Run("rundll32.exe shell32.dll,Control_RunDLL DESK.CPL,,3", @WindowsDir, @SW_HIDE)
; Auf Monitorreiter wechseln
WinWait($title, '', 3)
If Not WinActive($title) Then WinActivate($title)
ControlSend($title, '', 'SysTabControl321', '^+{TAB}')
Do
  ControlCommand($title, '', 'SysTabControl321', 'TabRight', '')
Until StringInStr(WinGetText($title, ''), 'Ordnen Sie die Monitorsymbole so an, dass sie der physikalischen Anordnung Ihrer Monitore entsprechen.') <> 0
WinWait($title, $text)
If Not WinActive($title, $text) Then WinActivate($title, $text)
ControlSend($title, '', 1801, 2) ; 2ten Monitor fokusieren
; Wenn an --> aus und wenn aus --> an :-)
If ControlCommand($title, $text, 'Button4', 'IsChecked', '') Then
  ControlCommand($title, $text, 'Button4', 'UnCheck', '')
Else
  ControlCommand($title, $text, 'Button4', 'Check', '')
EndIf
ControlClick($title, $text, 'OK')
FileDelete($screenshot_BMP)
Sleep($SystemSleepTime)
WinSetState("Eigenschaften von Anzeige", "", @SW_HIDE)
SplashOff()
EndFunc   ;==>_toggleMonitor
Func _exit()
Exit (0)
EndFunc   ;==>_exit
Func SetWindowRgn($h_win, $rgn)
DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $h_win, "long", $rgn, "int", 1)
EndFunc   ;==>SetWindowRgn
Func CreateTextRgn(ByRef $CTR_hwnd, $CTR_Text, $CTR_height, $CTR_font = "Microsoft Sans Serif", $CTR_weight = 1000)
Local Const $ANSI_CHARSET = 0
Local Const $OUT_CHARACTER_PRECIS = 2
Local Const $CLIP_DEFAULT_PRECIS = 0
Local Const $PROOF_QUALITY = 2
Local Const $FIXED_PITCH = 1
Local Const $RGN_XOR = 3
If $CTR_font = "" Then $CTR_font = "Microsoft Sans Serif"
If $CTR_weight = -1 Then $CTR_weight = 1000
Local $gdi_dll = DllOpen("gdi32.dll")
Local $CTR_hDC = DllCall("user32.dll", "int", "GetDC", "hwnd", $CTR_hwnd)
Local $CTR_hMyFont = DllCall($gdi_dll, "hwnd", "CreateFont", "int", $CTR_height, "int", 0, "int", 0, "int", 0, _
   "int", $CTR_weight, "int", 0, "int", 0, "int", 0, "int", $ANSI_CHARSET, "int", $OUT_CHARACTER_PRECIS, _
   "int", $CLIP_DEFAULT_PRECIS, "int", $PROOF_QUALITY, "int", $FIXED_PITCH, "str", $CTR_font)
Local $CTR_hOldFont = DllCall($gdi_dll, "hwnd", "SelectObject", "int", $CTR_hDC[0], "hwnd", $CTR_hMyFont[0])
DllCall($gdi_dll, "int", "BeginPath", "int", $CTR_hDC[0])
DllCall($gdi_dll, "int", "TextOut", "int", $CTR_hDC[0], "int", 0, "int", 0, "str", $CTR_Text, "int", StringLen($CTR_Text))
DllCall($gdi_dll, "int", "EndPath", "int", $CTR_hDC[0])
Local $CTR_hRgn1 = DllCall($gdi_dll, "hwnd", "PathToRegion", "int", $CTR_hDC[0])
Local $CTR_rc = DllStructCreate("int;int;int;int")
DllCall($gdi_dll, "int", "GetRgnBox", "hwnd", $CTR_hRgn1[0], "ptr", DllStructGetPtr($CTR_rc))
Local $CTR_hRgn2 = DllCall($gdi_dll, "hwnd", "CreateRectRgnIndirect", "ptr", DllStructGetPtr($CTR_rc))
DllCall($gdi_dll, "int", "CombineRgn", "hwnd", $CTR_hRgn2[0], "hwnd", $CTR_hRgn2[0], "hwnd", $CTR_hRgn1[0], "int", $RGN_XOR)
DllCall($gdi_dll, "int", "DeleteObject", "hwnd", $CTR_hRgn1[0])
DllCall("user32.dll", "int", "ReleaseDC", "hwnd", $CTR_hwnd, "int", $CTR_hDC[0])
DllCall($gdi_dll, "int", "SelectObject", "int", $CTR_hDC[0], "hwnd", $CTR_hOldFont[0])
DllClose($gdi_dll)
Return $CTR_hRgn2[0]
EndFunc   ;==>CreateTextRgn

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

I can do s Send to emulate the <WIN><P> presses but sometimes it opens with focus at the start, and sometimes it remembers the last used, and sets focus at 'detect' so i can't just send a couple of Tabs and a return to simulate the key presses.

Can you press HOME or anything to set the cursor to a predefined point then traverse from there? I'd like to test this but I don't have Win7, try holding LEFT ARROW does it just scroll and wrap or does it stop at a beginning point? Just trying to offer some ideas.

I am not a lawyer.  (-_-) Xandy About  (^o^) Discord - Xandy Programmer

Share this post


Link to post
Share on other sites

C:WindowsSystem32DisplaySwitch.exe

DisplaySwitch.exe /internal - Switch to Primary only

DisplaySwitch.exe /external - Switch to Secondary only

DisplaySwitch.exe /clone - Clone desktop on both screens (Not HDCP compliant!)

DisplaySwitch.exe /extend - Extend desktop to both screens


I see fascists...

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Thanks.

Rover:

The displaySwitch probably won't work [i'll try when i get home as XP only here at work] as when it needs to be used,Windows can only 'see' one monitor. The second has to be detected before switching/cloning/extending.

Xenobiologist:

I suspect the same will apply to your solution [i'll look more closely tonight to see how it worsks] - but please feel free to correct me if I'm wrong!

Songersoft:

I'll try this when I get home. Tabbing wraps around, but I haven't tried home/end to see if that gives a fixed reference.

Regards,

William

Edited by saywell

Share this post


Link to post
Share on other sites

Home/End work as predicted, so i can send win-p, home, rt-arrow, rt-arrow to get where i want.

Haven't had time to write it yet, but how do i divert the 'sends' to the windows OS rather than the active window?

Or perhaps i don't need to? - Win-E opens explorer even if a window has focus; win-P may be the same. I'll have a play tonight.

William

Share this post


Link to post
Share on other sites

Update.

Cand get sending the winkey + P to work, BUT my assumption re Rover's suggestion was wrong.

DisplaySwitch.exe /extend does work, so I presume the 'extend' is internally preceded by a 'detect' action.

For the moment, i've just created a shortcup, copied it into the taskbar and click it when needed.

If I can figure out how to detect the monitors changing, I'll try to automate it.

Thanks, Rover!

William

Share this post


Link to post
Share on other sites

C:WindowsSystem32DisplaySwitch.exe

DisplaySwitch.exe /internal - Switch to Primary only

DisplaySwitch.exe /external - Switch to Secondary only

DisplaySwitch.exe /clone - Clone desktop on both screens (Not HDCP compliant!)

DisplaySwitch.exe /extend - Extend desktop to both screens

Thanks, learnt something new today.

_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

I've now got this set up as a shortcut on the taskbar, so only one click needed.

The next step is to write a script that polls the system and detects when the second monitor has become unrecognised, and then call the DisplaySwitch.exe /extend command.

I've found references to EnumDisplayMonitors and EnumDisplayDevices but I don't know how to use them [i'm not a WinAPI guru!}.

Anyone know a bit [or, probably, a lot] more about this than I do?

William

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

saywell (William),

I created this the other day, I don't know if it's any use to you >>

#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7
#AutoIt3Wrapper_Icon=BinICON_1.ico
#AutoIt3Wrapper_Outfile=ExtendedDesktop.exe
#AutoIt3Wrapper_UseUpx=Y
#AutoIt3Wrapper_Res_Description=ExtendedDesktop.
#AutoIt3Wrapper_Res_Fileversion=1.0.0.0
#AutoIt3Wrapper_Res_LegalCopyright=nocopyright
#AutoIt3Wrapper_Res_Language=2057
#AutoIt3Wrapper_Run_Obfuscator=Y
#Obfuscator_Parameters=/SF /SV /OM /CS=0 /CN=0
#AutoIt3Wrapper_res_requestedExecutionLevel=asInvoker
#AutoIt3Wrapper_Outfile_Type=exe
#AutoIt3Wrapper_UseX64=N
#NoTrayIcon

#include <WinAPI.au3>
#include <WindowsConstants.au3>

_Main()

Func _Main()
    Local $sParameter
    Switch _WinAPI_GetSystemMetrics($SM_CMONITORS)
        Case 1
            $sParameter = "/extend"

        Case Else
            $sParameter = "/internal"

    EndSwitch
    Return Run(@SystemDir & "DisplaySwitch.exe " & $sParameter, @SystemDir, @SW_HIDE)
EndFunc   ;==>_Main
Edited by guinness
1 person likes this

_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Greetings guinness

I've not had any luck with that. It always returns 1 even if the monitor is disconnected.

Returns 1 on a machine with analog and lcd monitors connected. (on XP and 7)

MS added new WMI monitor classes as of Vista that read directly from the connected monitors.

Now you can read the EDID product/serial and other data and even set brightness of connected monitor(s).

Only one of the brightness classes has events, so you have to poll every sec or so.

Member norry posted code using one of the new (Vista+) WMI classes for reading the monitor EDID

WMI Reference: MSMonitorClass class

http://msdn.microsoft.com/en-us/library/windows/desktop/aa392707(v=vs.85).aspx

@saywell

This should detect the primary monitor disconnection,

if there isn't DDC/EDID emulation on that KVM port.

Opt("TrayOnEventMode", 1)
Opt("TrayMenuMode", 1)

TrayCreateItem("Exit")
TrayItemSetOnEvent(-1, "ExitEvent")
TraySetState()

_MonDetect("SNYEA01") ;product code for your primary monitor - uncomment the other ExecQuery statement and the InstanceName consolewrite to get the value
ConsoleWrite("!Error " & @error & @CRLF)

Func _MonDetect($sCode = "")
;Vista+ only
Local $oErrorHandler, $strcomputer = ".", $oWMI, $oMonitor, $fDetect = True, $fMon1 = False
$oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc")
If @error Or Not IsObj($oErrorHandler) Then ConsoleWrite("!No COM error handler" & @CRLF)
$oWMI = ObjGet("winmgmts:" & "{impersonationLevel=impersonate}!" & $strcomputer & "rootWMI")
If @error Or Not IsObj($oWMI) Then Return SetError(1, 0, -1) ;Failed to Connect to WMI

While Sleep(1000)
  $fDetect = True
  $oMonitor = 0
  ;$oMonitor = $objWMI.ExecQuery("SELECT * FROM WmiMonitorConnectionParams WHERE Active='True'") ;use this one to get your product code
  $oMonitor = $oWMI.ExecQuery("SELECT * FROM WmiMonitorConnectionParams WHERE InstanceName LIKE '%"&$sCode&"%'") ;only check the primary monitor

  If IsObj($oMonitor) Then
   For $oItem In $oMonitor  ;single pass loop. If primary monitor disconnected, loop is bypassed.
    ;ConsoleWrite('-InstanceName = ' & $oItem.InstanceName & @crlf) ;get monitor product code from here (DISPLAY********** value between the backslashes)
    ;ConsoleWrite('-VideoOutputTechnology = ' & $oItem.VideoOutputTechnology & @crlf) ;HD15=0, DVI=4, HDMI=5, etc.
    ;D3DKMDT_VIDEO_OUTPUT_TECHNOLOGY enumeration: [url="http://msdn.microsoft.com/en-us/library/ff546605.aspx"]http://msdn.microsoft.com/en-us/library/ff546605.aspx[/url]
    ;ConsoleWrite('-Active = ' & $oItem.Active() & @crlf)
    $fDetect = False
    $fMon1 = True
   Next
  EndIf

  ;ConsoleWrite("!COM error " & @error & @CRLF) ;COM error here if monitor disconnected, not Vista+ or WMI problem
  If $fDetect And $fMon1 Then ;run once when primary monitor disconnected/switched
   $fMon1 = False
   Run(@SystemDir & "DisplaySwitch.exe /extend", @SystemDir)
  EndIf
WEnd
EndFunc   ;==>_MonDetect

Func ExitEvent()
    Exit
EndFunc   ;==>ExitEvent

; User's COM error function. Will be called if COM error occurs
Func _ErrFunc($oError)
    ; Do anything here.
Return
    ConsoleWrite("err.number is: " & @TAB & $oError.number & @CRLF & _
            "err.windescription:" & @TAB & $oError.windescription & @CRLF & _
            "err.description is: " & @TAB & $oError.description & @CRLF & _
            "err.source is: " & @TAB & $oError.source & @CRLF & _
            "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _
            "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _
            "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _
            "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _
            "err.retcode is: " & @TAB & $oError.retcode & @CRLF & @CRLF)
EndFunc   ;==>_ErrFunc
Edited by rover

I see fascists...

Share this post


Link to post
Share on other sites

Thanks, Rover.

I'll give it a try when I get home - only have XP/single monitor at work to play on [hell to pay if I run DIY stuff on the 3-monitor - but still XP - PACS workstation!!].

Regards,

William

Share this post


Link to post
Share on other sites

I've not had any luck with that. It always returns 1 even if the monitor is disconnected.

Returns 1 on a machine with analog and lcd monitors connected. (on XP and 7)

OK, I think I tested it, but it was over a week ago (so probably not) and it was created for a 'just in case' scenario.

Thanks for revising the code, I will test as well, though knowing your ability I say it works already.

Sorry saywell for posting non-working code.


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

Hi guinness, no apologies necessary,

the older API's don't return realtime information on the connected monitors and it's not clear until you delve into this subject.

The EnumDisplayDevices API only reports display adapters, not connected monitor status.

I've not seen any DeviceIO API code to do this either.

Previously (pre-Vista ) there wasn't wmi or api support for knowing the monitor state in real-time, only registry EDID entries (listed monitors included history of previously connected monitors, and no realtime updating)

Apps like EnTech's utilities use libraries and video drivers to access monitors, beyond what most of us would know how to code for. (no examples on the forum from what I have read on this subject in the past)

other than the EnTech utilities, this is the only other (not free) code I found http://www.nicomsoft.com/wini2cddc/

Looks like Dxva2.dll has the API functions of the WMI classes in Vista+

Edit: typos, again...

Edited by rover

I see fascists...

Share this post


Link to post
Share on other sites

Any particular reason to not set your monitor connected to KVM as Win7's secondary monitor?

I have a dual monitor setup and my secondary is connected to KVM for my Win 98 machine. I have no problems switching between pcs


010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Share this post


Link to post
Share on other sites

I don't use a multi monitor desktop or KVM, just the built in HDMI switching with DDC/EDID emulation on my Sony LCD,

so I have not experienced this issue.

Perhaps the solutions in this epic thread will help.

Windows Client TechCenter > Windows 7 IT Pro Forums > Windows 7 Miscellaneous > Disable 'Monitor Off' detection, how?

http://social.technet.microsoft.com/Foru...ead/8a9b5aa7-fe33-4e6d-b39b-8a


I see fascists...

Share this post


Link to post
Share on other sites

I've had enough of this forum and these people who never acknowledge posted working answers.


I see fascists...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0