Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all articles
Browse latest Browse all 12506

Desktop Workarea, multiple monitors

$
0
0

I can get the 'workarea' of the primary monitor using:

Func _GetDesktopArea()   Local Const $SPI_GETWORKAREA = 48   Local $tWorkArea = DllStructCreate($tagRECT)   _WinAPI_SystemParametersInfo($SPI_GETWORKAREA, 0, DllStructGetPtr($tWorkArea))   Local $aReturn[4] = [DllStructGetData($tWorkArea, "Left"), DllStructGetData($tWorkArea, "Top"), _           DllStructGetData($tWorkArea, "Right") - DllStructGetData($tWorkArea, "Left"), DllStructGetData($tWorkArea, "Bottom") - DllStructGetData($tWorkArea, "Top")]   Return $aReturn EndFunc   ;==>_GetDesktopArea

MSDN says to use GetMonitorInfo() to get workarea of monitors other than the Primary.

 

However, when I do this the rect I receive from this function for Primary or Secondary is not a workarea, but a fullscreen rect.

AutoIt         
#include <WinApi.au3> #include <Array.au3> #include <StructureConstants.au3> ;get monitor handles Local $edm=_WinAPI_EnumDisplayMonitors();$hDC = 0, $tRECT = 0 If @Error Then MsgBox(0,'Error','_WinAPI_EnumDisplayMonitors') Local $mh1=$edm[2][0]; 1 for first handle, 2 for second Local $mr1=$edm[1][1]; supposedly a rect ; use my handle to get monitor infos Local $vh=_WinAPI_GetMonitorInfo($mh1) If @Error Then MsgBox(0,'Error','_WinAPI_GetMonitorInfo') ; $vh now filled with ; [0] - $tagRECT structure that specifies the display monitor rectangle, in virtual-screen coordinates. ; [1] - $tagRECT structure that specifies the work area rectangle of the display monitor that can be used by applications, in virtual-screen coordinates. ; [2] - 1 (True) for the primary display monitor, or 0 (False) otherwise. ; [3] - The device name of the monitor being used, e.g. "\\.\DISPLAY1". Local $aReturn[4] = [DllStructGetData($vh[1], 'Left') _                     ,DllStructGetData($vh[1], 'Top') _                     ,DllStructGetData($vh[1], 'Right') - DllStructGetData($vh[1], 'Left') _                     ,DllStructGetData($vh[1], 'Bottom') - DllStructGetData($vh[1], 'Top') _                     ] _ArrayDisplay($aReturn) Exit

So to reiterate- the MonitorInfo workarea rect does not jive with the one gotten with SPI for the Primary monitor, therefore it doesn't work for the Secondary monitor either - it just gets the true (virtual) dimensions.

 

I smell a Microsoft thing. I have looked on StackOverflow with no success. Can anyone get a workarea!=desktop with this code?


Viewing all articles
Browse latest Browse all 12506

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>