MarkRobbins Posted July 30, 2013 Share Posted July 30, 2013 (edited) 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. #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? Edited July 30, 2013 by MarkRobbins Link to comment Share on other sites More sharing options...
guinness Posted July 31, 2013 Share Posted July 31, 2013 MarkRobbins got that function from here. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _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 parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
jaberwacky Posted July 31, 2013 Share Posted July 31, 2013 Seems like it returns the correct information. The reason that it wouldn't return the whole display coords on the first mon is because of the taskbar. The opposite for the second monitor. This is my theory. I'm not a Windows guru. Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now