#Region header and includes ;#include #include "GDIPlus.au3" #include "WinAPI.au3" HotKeySet('{end}', 'bb') #EndRegion header and includes ; header and includes #region Opt("TrayMenuMode",1) $accept = TrayCreateItem("Accept Incoming") TrayCreateItem("") $stop = TrayCreateItem("Stop Connection") TrayCreateItem("") $close = TrayCreateItem("Close") #endregion 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 $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 ;可以改高度 ;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 #Region Tune it here ;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ Global $nPORT = 80 ; 1-(255*255) Global $MAX_CONNECTIONS = 100 ; 1-10? limited by network bandwith Global $JPEG_SIZE = 0.8 ; 0.01-1 Global $JPEG_QUALITY = 80 ; 1-100% ;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ #EndRegion FEEL FREE TO CHANGE THIS ; Settings #Region TCP Globals ;@@@@@@@@@@@@@@@@@@@@@@@ ;Global $szIPADDRESS = @IPAddress1 Global $szIPADDRESS = "127.0.0.1" Global $MainSocket=-1 Global $ConnectedSocket Global $recv Global $SOC_DB[$MAX_CONNECTIONS] Global $CONNECTED = 0 $MAX_CONNECTIONS -= 1 For $i = 0 To $MAX_CONNECTIONS $SOC_DB[$i] = 0 Next Global $TCP_ConnectTimer = TimerInit() ;@@@@@@@@@@@@@@@@@@@@@@@ #EndRegion TCP Globals ; TCP #Region Streaming initialise ;@@@@@@@@@@@@@@@@@@@@@@@ Global $iW = $thisisdesktopwidth *$thisisidpirate Global $iH = $thisisdesktopheight*$thisisidpirate Global $iWa = $iW * $JPEG_SIZE Global $iHa = $iH * $JPEG_SIZE Global $fTmp = @TempDir & "\tmp.jpg" Global $_hWnd = _WinAPI_GetDesktopWindow() Global $_hDDC = _WinAPI_GetDC($_hWnd) _GDIPlus_Startup() Global $_sCLSID = _GDIPlus_EncodersGetCLSID('jpg') ; set paremeters for compression Global $_GtParams = _GDIPlus_ParamInit(1) Global $_GtData = DllStructCreate("int Quality") DllStructSetData($_GtData, "Quality", $JPEG_QUALITY) _GDIPlus_ParamAdd($_GtParams, $GDIP_EPGQUALITY, 1, $GDIP_EPTLONG, DllStructGetPtr($_GtData)) Global $_GpParams = DllStructGetPtr($_GtParams) ;@@@@@@@@@@@@@@@@@@@@@@@ #EndRegion Streaming initialise ; Streaming #Region Main Loop ;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ TCP_init() AdlibRegister('TCP_LOOP', 5000); has to be large enough to let enything else to execute in between Func TCP_LOOP() $ConnectedSocket = TCPAccept($MainSocket) If $ConnectedSocket == -1 Then Return EndIf If TimerDiff($TCP_ConnectTimer) < 100 Then c('Connecting too often.') TCP_Send_HTML($ConnectedSocket, "Try Connecting again in 5 sec.") Return EndIf $free = TCP_getFreeSoc() If $free == -1 Then c('No more connections available') TCP_respond_full($ConnectedSocket) Return EndIf c('Connect request') $recv = TCPRecv($ConnectedSocket, 3) If $recv == '' Then Return c('Connect request receved') If $recv == 'GET' Then c(Stream_init($ConnectedSocket)) c(TCP_Add($ConnectedSocket, $free)) Else c($recv) EndIf EndFunc ;==>TCP_LOOP While True $msg = TrayGetMsg() Select Case $msg = $accept TCP_init() Case $msg = $stop TCP_Exit() Case $msg = $close bb() EndSelect Stream_Send() WEnd ;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ #EndRegion Main Loop ; Main #Region TCP functions Func TCP_init() if $MainSocket<>-1 then TCP_Exit() For $i = 0 To $MAX_CONNECTIONS $SOC_DB[$i] = 0 Next TCPStartup() $MainSocket = TCPListen($szIPADDRESS, $nPORT ,$MAX_CONNECTIONS) If $MainSocket = -1 Then Exit $ConnectedSocket = -1 EndFunc ;==>TCP_init Func TCP_Add($soc,$free) $SOC_DB[$free] = $soc SetError(0) $TCP_ConnectTimer = TimerInit() Return 'Added Socket index: ' & $free EndFunc ;==>TCP_Add Func TCP_SendToAll(ByRef $Packet) For $i = 0 To $MAX_CONNECTIONS If $SOC_DB[$i] <> 0 Then TCPSend($SOC_DB[$i], $Packet) If @error Then c(TCP_Drop($i)) EndIf Next EndFunc ;==>TCP_SendToAll func TCP_RecvFromAll() For $i = 0 To $MAX_CONNECTIONS If $SOC_DB[$i] <> 0 Then TCPRecv($SOC_DB[$i] , 1024) If @error Then c(TCP_Drop($i)) EndIf Next EndFunc Func TCP_Respond_Full(ByRef $soc) ; let it talk while TCPRecv($soc, 10240) sleep(10) WEnd Local $Packet = Binary("HTTP/1.1 200 OK" & @CRLF & _ "Connection: close" & @CRLF & _ "Content-Type: text/html" & @CRLF & _ @CRLF & _ "

" & $MAX_CONNECTIONS + 1 & " available connections are bizzy.

" & @CRLF) TCPSend($soc, $Packet) TCPCloseSocket($soc) EndFunc ;==>TCP_Respond_Full Func TCP_Send_HTML(ByRef $soc, $HTML) while TCPRecv($soc, 10240) sleep(10) WEnd Local $Packet = Binary("HTTP/1.1 200 OK" & @CRLF & _ "Connection: close" & @CRLF & _ "Content-Type: text/html" & @CRLF & _ @CRLF & _ "

" & $HTML & "

" & @CRLF) TCPSend($soc, $Packet) TCPCloseSocket($soc) EndFunc ;==>TCP_Send_HTML Func TCP_Drop($soc_index) If $SOC_DB[$soc_index] == 0 Then SetError(1) Return 'Socket is invalid' EndIf TCPCloseSocket($SOC_DB[$soc_index]) $SOC_DB[$soc_index] = 0 $TCP_ConnectTimer = TimerInit() SetError(0) Return 'Droped Socket index: ' & $soc_index EndFunc ;==>TCP_Drop func TCP_Exit() For $i = 0 To $MAX_CONNECTIONS If $SOC_DB[$i] <> 0 Then c(TCP_Drop($i)) EndIf Next TCPShutdown() $MainSocket = -1 Endfunc #EndRegion TCP functions ; TCP #Region TCP math functions Func TCP_getFreeSoc() Local $i = 0 While $i <= $MAX_CONNECTIONS If $SOC_DB[$i] == 0 Then Return $i EndIf $i += 1 WEnd Return -1 EndFunc ;==>TCP_getFreeSoc Func countConnected() Local $i = 0 Local $num = 0 While $i <= $MAX_CONNECTIONS If $SOC_DB[$i] <> 0 Then $num += 1 $i += 1 WEnd Return $num EndFunc ;==>countConnected Func isConnected() Local $i = 0 While $i <= $MAX_CONNECTIONS If $SOC_DB[$i] <> 0 Then Return 1 $i += 1 WEnd Return 0 EndFunc ;==>isConnected #EndRegion TCP math functions ; TCP #Region Streaming functions Func Stream_Init(ByRef $soc) while TCPRecv($soc, 10240) sleep(10) WEnd $Packet = Binary("HTTP/1.1 200 OK" & @CRLF & _ "Connection: close" & @CRLF & _ "Content-Type: multipart/x-mixed-replace;boundary=myboundary" & @CRLF & _ @CRLF & _ "--myboundary" & @CRLF) TCPSend($soc, $Packet) If @error Then Return 'Failed to initialise a stream' Else Return 'New stream started' EndIf EndFunc ;==>Stream_Init Func Stream_Send() If Not isConnected() Then Sleep(100) Return EndIf 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) TCP_SendToAll($Packet) EndFunc ;==>Stream_Send 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 ;==>captureToFile #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 #EndRegion Streaming functions ; Streaming #Region Other Functions Func bb() TCP_Exit() Exit EndFunc ;==>bb Func c($t) ConsoleWrite($t & @CRLF) Return $t EndFunc ;==>c #EndRegion Other Functions ; Other 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