;#include #include #include Global $search2 ; DeviceCap Property Global Constant Definitions Global Const $DRIVERVERSION = 0 ;Device driver version Global Const $TECHNOLOGY = 2 ;Device classification Global Const $HORZSIZE = 4 ;Horizontal size in millimeters Global Const $VERTSIZE = 6 ;Vertical size in millimeters Global Const $HORZRES = 8 ; Horizontal width in pixels Global Const $VERTRES = 10 ;Vertical height in pixels Global Const $BITSPIXEL = 12 ;Number of bits per pixel Global Const $PLANES = 14 ;Number of planes Global Const $NUMBRUSHES = 16 ;Number of brushes the device has Global Const $NUMPENS = 18 ;Number of pens the device has Global Const $NUMMARKERS = 20 ;Number of markers the device has Global Const $NUMFONTS = 22 ;Number of fonts the device has Global Const $NUMCOLORS = 24 ;Number of colors the device supports Global Const $PDEVICESIZE = 26 ;Size required for device descriptor Global Const $CURVECAPS = 28 ;Curve capabilities Global Const $LINECAPS = 30 ;Line capabilities Global Const $POLYGONALCAPS = 32 ;Polygonal capabilities Global Const $TEXTCAPS = 34 ;Text capabilities Global Const $CLIPCAPS = 36 ;Clipping capabilities Global Const $RASTERCAPS = 38 ;Bitblt capabilities Global Const $ASPECTX = 40 ;Length of the X leg Global Const $ASPECTY = 42 ;Length of the Y leg Global Const $ASPECTXY = 44 ;Length of the hypotenuse Global Const $SHADEBLENDCAPS = 45 ;Shading and Blending caps ;Global Const $LOGPIXELSX = 88 ;Logical pixels inch in X ;Global Const $LOGPIXELSY = 90 ;Logical pixels inch in Y Global Const $SIZEPALETTE = 104 ;Number of entries in physical palette Global Const $NUMRESERVED = 106 ;Number of reserved entries in palette Global Const $COLORRES = 108 ;Actual color resolution Global Const $PHYSICALWIDTH = 110 ;Physical Width in device units Global Const $PHYSICALHEIGHT = 111 ;Physical Height in device units Global Const $PHYSICALOFFSETX = 112 ;Physical Printable Area x margin Global Const $PHYSICALOFFSETY = 113 ;Physical Printable Area y margin Global Const $SCALINGFACTORX = 114 ;Scaling factor x Global Const $SCALINGFACTORY = 115 ;Scaling factor y Global Const $VREFRESH = 116 ;Current vertical refresh rate of the display device (for displays only) in Hz Global Const $DESKTOPVERTRES = 117 ;Horizontal width of entire desktop in pixels Global Const $DESKTOPHORZRES = 118 ;Vertical height of entire desktop in pixels Global Const $BLTALIGNMENT = 119 ;Preferred blt alignment HotKeySet('{end}', 'bb') Func bb() Exit EndFunc ;==>bb ;@@@@@@@@@@@@@@@@@@@@@@@ Local $szIPADDRESS = "127.0.0.1" ;Local $szIPADDRESS = @IPAddress1 Local $nPORT = 80 Local $MainSocket, $ConnectedSocket Local $recv ;@@@@@@@@@@@@@@@@@@@@@@@ msgbox(0,"",$szIPADDRESS) ;@@@@@@@@@@@@@@@@@@@@@@@ $dpirateone = _getdpirate() $dpiratetwo = _GetDPI()/96 if $dpirateone > $dpiratetwo Then ;msgbox(0,"","1") $thisisidpirate = $dpirateone if _GDIPlus_GraphicsGetDPIRatio()[0] = 1 Then $getmonitorsize2 = StringFormat('%.2f', _Getmonitorsize()*$thisisidpirate) EndIf Else ;msgbox(0,"","2") $thisisidpirate = $dpiratetwo $getmonitorsize2 = _Getmonitorsize() EndIf if $thisisidpirate > 1 Then if _GDIPlus_GraphicsGetDPIRatio()[0] = 1 Then ;msgbox(0,"","test2") $thisisdesktopwidth = @DesktopWidth $thisisdesktopheight = @DesktopHeight Else ;msgbox(0,"","test"&_GDIPlus_GraphicsGetDPIRatio()[0]) $thisisdesktopwidth = round(@DesktopWidth/$thisisidpirate) $thisisdesktopheight = round(@DesktopHeight/$thisisidpirate) EndIf Else $thisisdesktopwidth = @DesktopWidth $thisisdesktopheight = @DesktopHeight EndIf ;$thisisdesktopwidth = 3840 ;可以改寬度 ;$thisisdesktopheight = 2160 ;可以改高度 $iW = $thisisdesktopwidth *$thisisidpirate $iH = $thisisdesktopheight*$thisisidpirate ;msgbox(0,"",$thisisidpirate&"-"&$thisisdesktopwidth&"-"&$thisisdesktopheight) ;單螢幕 ;Global $iW = _WinAPI_GetSystemMetrics(0) + 1 ;Global $iH = _WinAPI_GetSystemMetrics(1) + 1 ;雙螢幕 ;Global $iW = _WinAPI_GetSystemMetrics(78) + 1 ;Global $iH = _WinAPI_GetSystemMetrics(79) + 1 Global $iWa = $iW / 2 Global $iHa = $iH / 2 Global $fTmp = @TempDir & "\tmp.jpeg" Global $_hWnd = _WinAPI_GetDesktopWindow() Global $_hDDC = _WinAPI_GetDC($_hWnd) _GDIPlus_Startup() Global $_sCLSID = _GDIPlus_EncodersGetCLSID('jpeg') ; set paremeters for compression Global $_GtParams = _GDIPlus_ParamInit(1) Global $_GtData = DllStructCreate("int Quality") DllStructSetData($_GtData, "Quality", 80) _GDIPlus_ParamAdd($_GtParams, $GDIP_EPGQUALITY, 1, $GDIP_EPTLONG, DllStructGetPtr($_GtData)) Global $_GpParams = DllStructGetPtr($_GtParams) ;@@@@@@@@@@@@@@@@@@@@@@@ ;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ TCPStartup() While True $MainSocket = TCPListen($szIPADDRESS, $nPORT) If $MainSocket = -1 Then Exit EndIf $ConnectedSocket = -1 While True $ConnectedSocket = TCPAccept($MainSocket) $recv = TCPRecv($ConnectedSocket, 2048) If $recv == '' Then ContinueLoop If StringLeft($recv, 3) == 'GET' Then _StartStream($ConnectedSocket) ;Exit TCPCloseSocket($MainSocket) ExitLoop 1 EndIf WEnd WEnd ;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ Func _StartStream(ByRef $i) $Packet = Binary("HTTP/1.1 200 OK" & @CRLF & _ "Connection: close" & @CRLF & _ "Content-Type: multipart/x-mixed-replace;boundary=myboundary" & @CRLF & _ @CRLF & _ "--myboundary" & @CRLF) TCPSend($i, $Packet) If @error Then Return 0 While True $tt = TimerInit() captureToFile() ; function takes all the time in the world to run $hFile = FileOpen($fTmp,16) $imagedata = FileRead($hFile) FileSetPos($hFile, 0, $FILE_END) $imagesize = FileGetPos($hFile) $Packet = Binary("Content-Type: image/jpeg" & @CRLF & _ "Content-Length: " & $imagesize & @CRLF & _ @CRLF) & _ $imagedata & _ Binary(@CRLF & "--myboundary" & @CRLF) TCPSend($i, $Packet) If @error Then Return 0 c(Round(1000 / TimerDiff($tt)) & ' fps') WEnd TCPCloseSocket($i) EndFunc ;==>_StartStream Func captureToFile() ; Capture Local $hHBITMAP = _WinAPI_CreateCompatibleBitmap($_hDDC, $iW, $iH) Local $hCDC = _WinAPI_CreateCompatibleDC($_hDDC) _WinAPI_SelectObject($hCDC, $hHBITMAP) _WinAPI_BitBlt($hCDC, 0, 0, $iW, $iH, $_hDDC, 0, 0, 0x00CC0020) _WinAPI_DeleteDC($hCDC) $hBITMAPscr = _GDIPlus_BitmapCreateFromHBITMAP($hHBITMAP) ; screen bitmap ; resize $hBMP = _WinAPI_CreateCompatibleBitmap($_hDDC, $iWa, $iHa) ; create blank $hImage1 = _GDIPlus_BitmapCreateFromHBITMAP($hBMP) ; blank bitmap $hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage1) ; create blank graphics _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBITMAPscr, 0, 0, $iWa, $iHa) ; Write to file _GDIPlus_ImageSaveToFileEx($hImage1, $fTmp, $_sCLSID, $_GpParams) ; Clean _GDIPlus_ImageDispose($hImage1) _GDIPlus_ImageDispose($hBITMAPscr) _GDIPlus_GraphicsDispose($hGraphic) _WinAPI_DeleteObject($hBMP) _WinAPI_DeleteObject($hHBITMAP) EndFunc ;==>tofile #cs HTTP/1.0 200 OK\r\n Content-Type: multipart/x-mixed-replace;boundary=myboundary\r\n \r\n --myboundary\r\n Content-Type: image/jpeg\r\n Content-Length: 15656\r\n \r\n \r\n --myboundary\r\n Content-Type: image/jpeg\r\n Content-Length: 14978\r\n \r\n \r\n --myboundary\r\n Content-Type: image/jpeg\r\n Content-Length: 15136\r\n \r\n \r\n --myboundary\r\n #ce Func _DualMonitor() ;確認是單或多螢幕 $strComputer = "." $temp = 0 $objWMIService = ObjGet("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" _ & $strComputer & "\root\cimv2") $colComputers = $objWMIService.ExecQuery _ ("Select * from Win32_DesktopMonitor") For $objComputer in $colComputers $temp +=1 Next If $temp > 1 Then Return 1 Else Return 0 EndIf EndFunc ;==>_DualMonitor Func c($t) ConsoleWrite($t & @CRLF) Return $t EndFunc ;==>c Func _getdpirate() local $DISPLAY_DEVICE_MIRRORING_DRIVER = 0x00000008 local $ENUM_CURRENT_SETTINGS = -1 local $DISPLAY_DEVICE = "int;char[32];char[128];int;char[128];char[128]" local $DEVMODE = "byte[32];short;short;short;short;int;int[2];int;int" & _ ";short;short;short;short;short;byte[32]" & _ ";short;ushort;int;int;int;int" Dim $MonitorPos[1][4] $dev = 0 $id = 0 $dll = DllOpen("user32.dll") $msg = "" Dim $dd = DllStructCreate($DISPLAY_DEVICE) DllStructSetData($dd, 1, DllStructGetSize($dd)) Dim $dm = DllStructCreate($DEVMODE) DllStructSetData($dm, 4, DllStructGetSize($dm)) Do $EnumDisplays = DllCall($dll, "int", "EnumDisplayDevices", _ "ptr", "NULL", _ "int", $dev, _ "ptr", DllStructGetPtr($dd), _ "int", 0) $StateFlag = Number(StringMid(Hex(DllStructGetData($dd, 4)), 3)) If ($StateFlag <> $DISPLAY_DEVICE_MIRRORING_DRIVER) And ($StateFlag <> 0) Then;ignore virtual mirror displays $id += 1 ReDim $MonitorPos[$id+1][5] $EnumDisplaysEx = DllCall($dll, "int", "EnumDisplaySettings", _ "str", DllStructGetData($dd, 2), _ "int", $ENUM_CURRENT_SETTINGS, _ "ptr", DllStructGetPtr($dm)) $MonitorPos[$id][0] = DllStructGetData($dm, 7, 1) $MonitorPos[$id][1] = DllStructGetData($dm, 7, 2) $MonitorPos[$id][2] = DllStructGetData($dm, 18) $MonitorPos[$id][3] = DllStructGetData($dm, 19) $msg &= "Monitor " & ($id) & " start point:(" & _ DllStructGetData($dm, 7, 1) & "," & _ DllStructGetData($dm, 7, 2) & ") " & @TAB & "Screen resolution: " & _ DllStructGetData($dm, 18) & "x" & _ DllStructGetData($dm, 19) & @LF EndIf $dev += 1 Until $EnumDisplays[0] = 0 $MonitorPos[0][0] = $id DllClose($dll) ;MsgBox(0,"Screen Info",$msg) ;msgbox(0,"", "ReWidth="&@DesktopWidth&"ReHeight="&@DesktopHeight&" - Width="&$MonitorPos[1][2]&"Height="&$MonitorPos[1][3]) $monitorsizeresult = StringFormat('%.2f', $MonitorPos[1][2]/@DesktopWidth) ;msgbox(0,"", $monitorsizeresult) Return $monitorsizeresult EndFunc Func _GetDPI() Local $iDPI, $iDPIRat, $Logpixelsy = 90, $hWnd = 0 Local $hDC = DllCall("user32.dll", "long", "GetDC", "long", $hWnd) Local $aRet = DllCall("gdi32.dll", "long", "GetDeviceCaps", "long", $hDC[0], "long", $Logpixelsy) DllCall("user32.dll", "long", "ReleaseDC", "long", $hWnd, "long", $hDC) $iDPI = $aRet[0] ;; Set a ratio for the GUI dimensions based upon the current DPI value. If $iDPI < 145 And $iDPI > 121 Then $iDPIRat = $iDPI / 95 ElseIf $iDPI < 121 And $iDPI > 84 Then $iDPIRat = $iDPI / 96 ElseIf $iDPI < 84 And $iDPI > 0 Then $iDPIRat = $iDPI / 105 ElseIf $iDPI = 0 Then $iDPI = 96 $iDPIRat = 94 Else $iDPIRat = $iDPI / 94 EndIf ;MsgBox(64, "", "DPI= " & $iDPI & @CRLF & " DPIRat= " & $iDPIRat) Return $iDPI EndFunc ;==>_GetDPI Func _Getmonitorsize() local $LOGPIXELSX = 88 ;Logical pixels inch in X local $LOGPIXELSY = 90 ;Logical pixels inch in Y Local $hWnd = 0 Local $hDC = DllCall("user32.dll", "long", "GetDC", "long", $hWnd) Local $aRet2 = DllCall("gdi32.dll", "long", "GetDeviceCaps", "long", $hDC[0], "long", $HORZSIZE) Local $aRet3 = DllCall("gdi32.dll", "long", "GetDeviceCaps", "long", $hDC[0], "long", $VERTSIZE) Local $aReths = DllCall("gdi32.dll", "long", "GetDeviceCaps", "long", $hDC[0], "long", $HORZRES) Local $aRetvs = DllCall("gdi32.dll", "long", "GetDeviceCaps", "long", $hDC[0], "long", $VERTRES) Local $aRethslx = DllCall("gdi32.dll", "long", "GetDeviceCaps", "long", $hDC[0], "long", $LOGPIXELSX) Local $aRetvsly = DllCall("gdi32.dll", "long", "GetDeviceCaps", "long", $hDC[0], "long", $LOGPIXELSY) Local $aRethslxdx = DllCall("gdi32.dll", "long", "GetDeviceCaps", "long", $hDC[0], "long", $DESKTOPHORZRES) Local $aRethslxdy = DllCall("gdi32.dll", "long", "GetDeviceCaps", "long", $hDC[0], "long", $DESKTOPVERTRES) DllCall("user32.dll", "long", "ReleaseDC", "long", $hWnd, "long", $hDC) ;msgbox(0,"","Xsize_mm = "& $aRet2[0]& " Ysize_mm = " & $aRet3[0] & " Xresolution = " & $aReths[0] & " Yresolution = "& $aRetvs[0] & " Xlogpixels = " & $aRethslx[0] & " Ylogpixels = "& $aRetvsly[0]& " DYresolution = "& $aRethslxdy[0]& " DXresolution = "& $aRethslxdx[0]) $monitorsizeresult = StringFormat('%.2f', ((($aRet2[0]^2)+($aRet3[0]^2)) ^ (1/2))/25.4) ;msgbox(0,"",$aRet2[0]&" - "&$aRet3[0]) ;顯示螢幕真實尺吋單位是mm ;msgbox(0,"",$monitorsizeresult) #CS $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" $strComputer = "localhost" $Output="" $Output = $Output & "Computer: " & $strComputer & @CRLF $Output = $Output & "==========================================" & @CRLF $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_DesktopMonitor", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) then For $objItem In $colItems $Output = $Output & "Availability: " & $objItem.Availability & @CRLF $Output = $Output & "Bandwidth: " & $objItem.Bandwidth & @CRLF $Output = $Output & "Caption: " & $objItem.Caption & @CRLF $Output = $Output & "ConfigManagerErrorCode: " & $objItem.ConfigManagerErrorCode & @CRLF $Output = $Output & "ConfigManagerUserConfig: " & $objItem.ConfigManagerUserConfig & @CRLF $Output = $Output & "CreationClassName: " & $objItem.CreationClassName & @CRLF $Output = $Output & "Description: " & $objItem.Description & @CRLF $Output = $Output & "DeviceID: " & $objItem.DeviceID & @CRLF $Output = $Output & "DisplayType: " & $objItem.DisplayType & @CRLF $Output = $Output & "ErrorCleared: " & $objItem.ErrorCleared & @CRLF $Output = $Output & "ErrorDescription: " & $objItem.ErrorDescription & @CRLF $Output = $Output & "InstallDate: " & WMIDateStringToDate($objItem.InstallDate) & @CRLF $Output = $Output & "IsLocked: " & $objItem.IsLocked & @CRLF $Output = $Output & "LastErrorCode: " & $objItem.LastErrorCode & @CRLF $Output = $Output & "MonitorManufacturer: " & $objItem.MonitorManufacturer & @CRLF $Output = $Output & "MonitorType: " & $objItem.MonitorType & @CRLF $Output = $Output & "Name: " & $objItem.Name & @CRLF $Output = $Output & "PixelsPerXLogicalInch: " & $objItem.PixelsPerXLogicalInch & @CRLF $Output = $Output & "PixelsPerYLogicalInch: " & $objItem.PixelsPerYLogicalInch & @CRLF $Output = $Output & "PNPDeviceID: " & $objItem.PNPDeviceID & @CRLF $strPowerManagementCapabilities = $objItem.PowerManagementCapabilities(0) $Output = $Output & "PowerManagementCapabilities: " & $strPowerManagementCapabilities & @CRLF $Output = $Output & "PowerManagementSupported: " & $objItem.PowerManagementSupported & @CRLF $Output = $Output & "ScreenHeight: " & $objItem.ScreenHeight & @CRLF $Output = $Output & "ScreenWidth: " & $objItem.ScreenWidth & @CRLF $Output = $Output & "Status: " & $objItem.Status & @CRLF $Output = $Output & "StatusInfo: " & $objItem.StatusInfo & @CRLF $Output = $Output & "SystemCreationClassName: " & $objItem.SystemCreationClassName & @CRLF $Output = $Output & "SystemName: " & $objItem.SystemName & @CRLF ;if Msgbox(1,"WMI Output",$Output) = 2 then ExitLoop $search2 = "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\DISPLAY\"&StringSplit($objItem.PNPDeviceID , "\")[2] $result3 = ExampleKey($search2) $result4 = Check_key_value(1,$search2,"EDID","Device Parameters") $binary_h = 1 $binary_get_bit = 16 ;msgbox(0,"",BinaryMid($result4, ($binary_h*16)+1, $binary_get_bit)) Local $dExtract = BinaryMid($result4, ($binary_h*16)+1, $binary_get_bit) $b0 = Dec(Hex(BinaryMid($dExtract,6,1))) $b1 = Dec(Hex(BinaryMid($dExtract,7,1))) $monitorsize = StringFormat('%.2f', ((($b0^2)+($b1^2)) ^ (1/2))/2.54) ;msgbox(0,"",$b0 & " " & $b1) $Output="" Next Else ;Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_DesktopMonitor" ) Endif ;msgbox(0,"",$monitorsize) ;EDID DATA 算出來 ;msgbox(0,"",$monitorsizeresult) ;DeviceCaps 算出來 ;Return $monitorsize #CE Return $monitorsizeresult EndFunc ;==>_GetDPI Func ExampleKey($search1) $lastkey = "" Local $getregkey = "", $i = 1 While 1 ;msgbox(0,"", $i) $getregkey = RegEnumKey($search1, $i) ;msgbox(0,"",$getregkey) If @error Then ;return "i="&$i-1&"|Val="&$lastkey return $i-1 ExitLoop EndIf If $getregkey <> "" Then $lastkey = $getregkey ;msgbox(0,"", $getregkey) ;msgbox(0,"", @extended) ;msgbox(0,"", $getregkey & " " &$aRegValueType[@extended]) ;msgbox(0,"", "data") Else return $i-1 ExitLoop EndIf $i += 1 WEnd ;RegEnumKey 機碼 ;RegEnumVal 名稱 EndFunc Func Check_key_value($keynumber , $regpath ,$val ,$key) For $i = 1 To $keynumber $getregkey = RegEnumKey($regpath, $i) ;msgbox(0,"",$regpath&"\"&$getregkey) $readvalue = RegRead($regpath&"\"&$getregkey&"\"&$key,$val) Return $readvalue ;if $readvalue = 0 Then ; msgbox(0,"","Web has been to use!") ;EndIf Next EndFunc Func _GDIPlus_GraphicsGetDPIRatio($iDPIDef = 96) Local $aResults[2] = [1, 1] _GDIPlus_Startup() Local $hGfx = _GDIPlus_GraphicsCreateFromHWND(0) If @error Then Return SetError(1, @extended, $aResults) Local $aResult ;#forcedef $__g_hGDIPDll, $ghGDIPDll $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetDpiX", "handle", $hGfx, "float*", 0) If @error Then Return SetError(2, @error, $aResults) Local $iDPI = $aResult[2] Local $aResults[2] = [$iDPIDef / $iDPI, $iDPI / $iDPIDef] _GDIPlus_GraphicsDispose($hGfx) _GDIPlus_Shutdown() Return $aResults EndFunc ;==>_GDIPlus_GraphicsGetDPIRatio Func WMIDateStringToDate($dtmDate) Return (StringMid($dtmDate, 5, 2) & "/" & _ StringMid($dtmDate, 7, 2) & "/" & StringLeft($dtmDate, 4) _ & " " & StringMid($dtmDate, 9, 2) & ":" & StringMid($dtmDate, 11, 2) & ":" & StringMid($dtmDate,13, 2)) EndFunc