Sign in to follow this  
Followers 0
Rhyono

Fetch the width and height of a specific monitor

3 posts in this topic

Using

Local $size = WinGetClientSize("Program Manager")
I can get the width of all three monitors summed, but how would I get just one monitor?

Share this post


Link to post
Share on other sites



After looking at I've decided it'll be more economical to just set it...

Share this post


Link to post
Share on other sites

I can't take any credit for this

#include <Array.au3>
Global $__MonitorList[1][5]
$__MonitorList[0][0] = 0
$res = _GetMonitors()
_ArrayDisplay($res)
#Region thanks to xrxca for these functions
Func _GetMonitors()
 $__MonitorList[0][0] = 0 ;  Added so that the global array is reset if this is called multiple times
 Local $handle = DllCallbackRegister("_MonitorEnumProc", "int", "hwnd;hwnd;ptr;lparam")
 DllCall("user32.dll", "int", "EnumDisplayMonitors", "hwnd", 0, "ptr", 0, "ptr", DllCallbackGetPtr($handle), "lparam", 0)
 DllCallbackFree($handle)
 Local $i = 0
 For $i = 1 To $__MonitorList[0][0]
  If $__MonitorList[$i][1] < $__MonitorList[0][1] Then $__MonitorList[0][1] = $__MonitorList[$i][1]
  If $__MonitorList[$i][2] < $__MonitorList[0][2] Then $__MonitorList[0][2] = $__MonitorList[$i][2]
  If $__MonitorList[$i][3] > $__MonitorList[0][3] Then $__MonitorList[0][3] = $__MonitorList[$i][3]
  If $__MonitorList[$i][4] > $__MonitorList[0][4] Then $__MonitorList[0][4] = $__MonitorList[$i][4]
 Next
 Return $__MonitorList
EndFunc   ;==>_GetMonitors
Func _MonitorEnumProc($hMonitor, $hDC, $lRect, $lParam)
 Local $Rect = DllStructCreate("int left;int top;int right;int bottom", $lRect)
 $__MonitorList[0][0] += 1
 ReDim $__MonitorList[$__MonitorList[0][0] + 1][5]
 If $hDC = $hDC Then
 EndIf
 If $lParam = $lParam Then
 EndIf
 $__MonitorList[$__MonitorList[0][0]][0] = $hMonitor
 $__MonitorList[$__MonitorList[0][0]][1] = DllStructGetData($Rect, "left")
 $__MonitorList[$__MonitorList[0][0]][2] = DllStructGetData($Rect, "top")
 $__MonitorList[$__MonitorList[0][0]][3] = DllStructGetData($Rect, "right")
 $__MonitorList[$__MonitorList[0][0]][4] = DllStructGetData($Rect, "bottom")
 Return 1 ; Return 1 to continue enumeration
EndFunc   ;==>_MonitorEnumProc
#EndRegion thanks to xrxca for these functions

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

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