Jump to content

Search the Community

Showing results for tags 'multimonitor'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 2 results

  1. Multi-monitor aware window centring function. Can handle various work area setups as outlined below: Those are the variants I've tested. #include <Math.au3> #include <WinAPI.au3> #include <WinAPIConstants.au3> #include <WinAPIGdi.au3> #include <WinAPISys.au3> #include <WindowsConstants.au3> Func activeWindowCenter() Const $window = WinGetHandle('[ACTIVE]') Const $monitorInfo = _WinAPI_GetMonitorInfo(_WinAPI_MonitorFromWindow($window)) Const $area[] = [DllStructGetData($monitorInfo[1], 1), DllStructGetData($monitorInfo[1], 3), DllStructGetData($monitorInfo[1], 2), DllStructGetData($monitorInfo[1], 4)] Const $size = WinGetPos($window) If @error Then Return EndIf If BitAND(_WinAPI_GetWindowLong($window, $GWL_STYLE), $WS_MAXIMIZE) Then Return EndIf Const $areaWidth = _Max($area[0], $area[1]) - _Min($area[0], $area[1]) Const $windowOffsetX = ($areaWidth - $size[2]) / 2 Const $x = _Min($area[0], $area[1]) + $windowOffsetX Const $areaHeight = _Max($area[2], $area[3]) - _Min($area[2], $area[3]) Const $windowOffsetY = ($areaHeight - $size[3]) / 2 Const $y = _Min($area[2], $area[3]) + $windowOffsetY WinMove($window, '', $x, $y, $size[2], $size[3], 2) EndFunc Here's simple usage: ; include the definition HotKeySet('#o', 'activeWindowCenter') While 1 Sleep(1000) WEnd
  2. 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?
×
×
  • Create New...