Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 08/09/2023 in all areas

  1. can you show the console output from the script i suggested? indeed, the mouse lives in its world (with a zoom factor of 200% it makes half the journey), while the ToolTip goes normally to its position however the problem seems to be fixed by using DPIAwareness.au3 which I found after digging in CV as suggested by @argumentum DPIAwareness.au3 Example ; https://www.autoitscript.com/forum/topic/210653-mousemove-and-scaling-issue/#comment-1522551 #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #include <WindowsConstants.au3> #include <WinAPIGdi.au3> #include "DPIAwareness.au3" _WinAPI_SetDPIAwareness() Global $hGui = GUICreate('Au3Gui', 500, 500, -1, -1, $WS_OVERLAPPEDWINDOW) WinSetTrans($hGui, '', 100) Global $Label1 = GUICtrlCreateLabel("", 200, 200, 300, 300) GUICtrlSetFont(-1, 200, 900, 0, "MS Sans Serif") GUISetState(@SW_SHOW, $hGui) Global $aMon = _GetMonitorsArray() If IsArray($aMon) Then #Region ===( test1 )=== For $i = 1 To $aMon[0][0] WinMove($hGui, "", $aMon[$i][1], $aMon[$i][2], $aMon[$i][3], $aMon[$i][4]) GUISetState(@SW_MAXIMIZE, $hGui) GUICtrlSetData($Label1, $i) ConsoleWrite(" index: " & $i & @CRLF) ConsoleWrite("- [0]=handle=" & $aMon[$i][0] & @CRLF) ConsoleWrite("- [1]=left=" & $aMon[$i][1] & @CRLF) ConsoleWrite("- [2]=top=" & $aMon[$i][2] & @CRLF) ConsoleWrite("- [3]=width=" & $aMon[$i][3] & @CRLF) ConsoleWrite("- [4]=height=" & $aMon[$i][4] & @CRLF) ConsoleWrite("" & @CRLF) _GetMonitorInfo($hGui) Sleep(2000) Next GUIDelete($hGui) #EndRegion ===( test1 )=== #Region ===( test2 )=== Global $iX, $iY For $i = 1 To $aMon[0][0] ;the start point $iX = $aMon[$i][1] $iY = $aMon[$i][2] ;plus the midle point $iX += $aMon[$i][3] / 2 $iY += $aMon[$i][4] / 2 ConsoleWrite($iX & ", " & $iY & @CRLF) ToolTip("Mouse x, y:" & @CRLF & $iX & ", " & $iY, $iX, $iY, "midle point:", 1, 3) MouseMove($iX, $iY, 70) Global $aPos = MouseGetPos() ConsoleWrite("MouseGetPos x, y:" & $aPos[0] & ", " & $aPos[1] & @CRLF) Sleep(3000) ToolTip("") Next #EndRegion ===( test2 )=== EndIf ;---------------------------------------------------------------------------------------- Func _GetMonitorInfo($hWindow) Local $hMonitor = _WinAPI_MonitorFromWindow($hWindow, $MONITOR_DEFAULTTONULL) Local $aData = _WinAPI_GetMonitorInfo($hMonitor) ConsoleWrite('MonitorInfo **********************' & @CRLF) If Not @error Then ConsoleWrite('Handle: ' & $hMonitor & @CRLF) ConsoleWrite('Rectangle: ' & DllStructGetData($aData[0], 1) & ', ' & DllStructGetData($aData[0], 2) & ', ' & DllStructGetData($aData[0], 3) & ', ' & DllStructGetData($aData[0], 4) & @CRLF) ConsoleWrite('Work area: ' & DllStructGetData($aData[1], 1) & ', ' & DllStructGetData($aData[1], 2) & ', ' & DllStructGetData($aData[1], 3) & ', ' & DllStructGetData($aData[1], 4) & @CRLF) ConsoleWrite('Primary: ' & $aData[2] & @CRLF) ConsoleWrite('Device name: ' & $aData[3] & @CRLF) ConsoleWrite("**********************************" & @CRLF & @CRLF) EndIf EndFunc ;==>_GetMonitorInfo ;---------------------------------------------------------------------------------------- Func _GetMonitorsArray() Local $aPos, $aData = _WinAPI_EnumDisplayMonitors() If IsArray($aData) Then ReDim $aData[$aData[0][0] + 1][5] For $i = 1 To $aData[0][0] $aPos = _WinAPI_GetPosFromRect($aData[$i][1]) For $j = 0 To 3 $aData[$i][$j + 1] = $aPos[$j] Next Next EndIf Return $aData EndFunc ;==>_GetMonitorsArray ;---------------------------------------------------------------------------------------- ;comment / uncomment the _WinAPI_SetDPIAwareness() func to see the different
    2 points
  2. if CV ( control viewer mod ) works then maybe you can use part of the UDF I'm putting together.
    2 points
  3. You can also have a Picture control and you can use GDI+ to draw things in the control. In this way you don't have to care about redrawing when a window overlaps your graphics. #include <GDIPlus.au3> Global $hGUI, $idPicture Global Const $STM_SETIMAGE = 0x0172 $hGUI = GUICreate("GDI+ Test", 400, 450) $idPicture = GUICtrlCreatePic('', 5, 5, 390, 390, 0x1000) ; SS_SUNKEN $idDraw = GUICtrlCreateButton('Draw', 50, 410, 100, 30) $idClear = GUICtrlCreateButton('Clear', 250, 410, 100, 30) GUISetState() While True Switch GUIGetMsg() Case -3 ; GUI_EVENT_CLOSE Exit Case $idDraw DrawImage() Case $idClear ClearImage() EndSwitch WEnd Func DrawImage() ; Create a sample image _GDIPlus_Startup() Local $hBitmap = _GDIPlus_BitmapCreateFromScan0(390, 390) Local $hContext = _GDIPlus_ImageGetGraphicsContext($hBitmap) Local $hBrush = _GDIPlus_BrushCreateSolid(0xFFFCA311) _GDIPlus_GraphicsClear($hContext, 0xFFCCD5AE) _GDIPlus_GraphicsFillEllipse($hContext, 100, 100, 50, 75, $hBrush) _GDIPlus_BrushSetSolidColor($hBrush, 0xFF264653) _GDIPlus_GraphicsFillRect($hContext, 220, 230, 80, 115, $hBrush) ; Draw to picture control Local $hHBITMAP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) _WinAPI_DeleteObject(GUICtrlSendMsg($idPicture, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBITMAP)) _WinAPI_DeleteObject($hHBITMAP) ; Dispose resources _GDIPlus_BrushDispose($hBrush) _GDIPlus_GraphicsDispose($hContext) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_Shutdown() EndFunc Func ClearImage() _WinAPI_DeleteObject(GUICtrlSendMsg($idPicture, $STM_SETIMAGE, $IMAGE_BITMAP, 0)) ; or GUICtrlSetImage($idClear, '') EndFunc
    1 point
  4. cdeb

    udf Deepl API

    👌
    1 point
  5. Thanks BTW there was a typo in my previous expression Here it is #Include <Array.au3> $text = FileRead(@ScriptDir & "\" & "database.txt") $database = StringRegExp($text, 'category":\h+"([^"]+)"\s+},\s+(\d+)', 3) _ArrayDisplay($database) To get numbers only, just remove the parenthesis of the first capturing group StringRegExp($text, 'category":\h+"[^"]+"\s+},\s+(\d+)', 3) You may also use the solution from pixelsearch StringRegExp($text, '(?m)\h*(\d+)', 3) But depending on the content of the text, it could be less reliable
    1 point
  6. 1 point
  7. cdeb

    udf Deepl API

    I don't think there are any better alternatives to DeepL...it certainly gives its best with longer sentences. At least that is my opinion
    1 point
  8. @Shark007 For me it is still not working - getting the same error message! Regarding Win8 -> the function _WinAPI_GetDpiForWindow() requires Win10 v1607+. I've added another GDI+ function to get the DPI which should work, too. Can you test please? Here the code: ;Coded by UEZ build 2023-07-21 beta #include <Array.au3> #AutoIt3Wrapper_Res_HiDpi=y #include <GUIConstantsEx.au3> #include <GDIPlus.au3> #include <WinAPIGdiDC.au3> #include <WinAPISysWin.au3> #include <WindowsConstants.au3> #Region $DPI_AWARENESS_CONTEXT ;https://learn.microsoft.com/en-us/windows/win32/api/windef/ne-windef-dpi_awareness Global Enum $DPI_AWARENESS_INVALID = -1, $DPI_AWARENESS_UNAWARE = 0, $DPI_AWARENESS_SYSTEM_AWARE = 1, $DPI_AWARENESS_PER_MONITOR_AWARE = 2 ;https://learn.microsoft.com/en-us/windows/win32/hidpi/dpi-awareness-context Global Const $DPI_AWARENESS_CONTEXT_UNAWARE = $DPI_AWARENESS_UNAWARE - 1 Global Const $DPI_AWARENESS_CONTEXT_SYSTEM_AWARE = $DPI_AWARENESS_UNAWARE - 2 Global Const $DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE = $DPI_AWARENESS_UNAWARE - 3 Global Const $DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 = $DPI_AWARENESS_UNAWARE - 4 Global Const $DPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED = $DPI_AWARENESS_UNAWARE - 5 #EndRegion $DPI_AWARENESS_CONTEXT ; enum _MONITOR_DPI_TYPE Global Enum $MDT_EFFECTIVE_DPI = 0, $MDT_ANGULAR_DPI, $MDT_RAW_DPI Global Const $MDT_DEFAULT = $MDT_EFFECTIVE_DPI Global Const $WM_DPICHANGED = 0x02E0, $WM_DPICHANGED_BEFOREPARENT = 0x02E2, $WM_DPICHANGED_AFTERPARENT = 0x02E3, $WM_GETDPISCALEDSIZE = 0x02E4 Global $dpiScaledX, $dpiScaledY, $aCtrlFS[5][2], $hGUI, $hGUI_child, $g_iDPI_ratio2, $iLable_child, $iPic_child, $sImage = "c:\Program Files (x86)\AutoIt3\Examples\GUI\Merlin.gif" Global $hDLL = DllOpen("user32.dll") Example1() DllClose($hDLL) Func Example1() ;thanks to alpines for the main GUI layout If _WinAPI_SetDPIAwareness($DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2) = -1 Then Exit MsgBox(16, "ERROR", "Cannot set DPI awareness!", 10) Local $iDPI If @OSBuild < 14393 Then $iDPI = _GDIPlus_GraphicsGetDPIRatio() Else Local $hGUI_dummy = GUICreate("", 1, 1, 0, 0) $iDPI = _WinAPI_GetDpiForWindow($hGUI_dummy) GUIDelete($hGUI_dummy) EndIf Local $iDPI_ratio = $iDPI / 96 $g_iDPI_ratio2 = 96 / $iDPI $hGUI = GUICreate("Example 1", 314 * $iDPI_ratio, 130 * $iDPI_ratio, -1, 10) GUISetFont(12 * $iDPI_ratio, 400, 0, "Times New Roman") $aCtrlFS[0][0] = GUICtrlCreateLabel("Label1", 16 * $iDPI_ratio, 16 * $iDPI_ratio, 40 * $iDPI_ratio, 21 * $iDPI_ratio) $aCtrlFS[0][1] = 10 GUICtrlSetBkColor(-1, 0x3399FF) GUICtrlSetResizing(-1, $GUI_DOCKAUTO) $aCtrlFS[1][0] = GUICtrlCreateLabel("Label2", 64 * $iDPI_ratio, 16 * $iDPI_ratio, 40 * $iDPI_ratio, 21 * $iDPI_ratio) $aCtrlFS[1][1] = 10 GUICtrlSetBkColor(-1, 0x3399FF) GUICtrlSetResizing(-1, $GUI_DOCKAUTO) $aCtrlFS[2][0] = GUICtrlCreateLabel("Label3", 112 * $iDPI_ratio, 16 * $iDPI_ratio, 40 * $iDPI_ratio, 21 * $iDPI_ratio) $aCtrlFS[2][1] = 10 GUICtrlSetBkColor(-1, 0x3399FF) GUICtrlSetResizing(-1, $GUI_DOCKAUTO) $aCtrlFS[3][0] = GUICtrlCreateInput("Input1", 160 * $iDPI_ratio, 16 * $iDPI_ratio, 137 * $iDPI_ratio, 22 * $iDPI_ratio) $aCtrlFS[3][1] = 10 GUICtrlSetResizing(-1, $GUI_DOCKAUTO) $aCtrlFS[4][0] = GUICtrlCreateButton("Close", 16 * $iDPI_ratio, 48 * $iDPI_ratio, 283 * $iDPI_ratio, 65 * $iDPI_ratio) $aCtrlFS[4][1] = 16 GUICtrlSetResizing(-1, $GUI_DOCKAUTO) $hGUI_child = GUICreate("Child", 320 * $iDPI_ratio, 260 * $iDPI_ratio, -1, -1, -1, -1, $hGUI) GUISetBkColor(0xFFFFFF) $iLable_child = GUICtrlCreateLabel("Label11", 16, 16, 288 * $iDPI_ratio, 168 * $iDPI_ratio) GUICtrlSetFont(-1, 65, 400, 0, "Times New Roman", 5) $iPic_child = GUICtrlCreatePic($sImage, 0, 160 * $iDPI_ratio, 68 * $iDPI_ratio, 71 * $iDPI_ratio) ResizeFont($hGUI) GUISetState(@SW_SHOW, $hGUI) GUISetState(@SW_SHOW, $hGUI_child) GUIRegisterMsg($WM_DPICHANGED_BEFOREPARENT, "WM_DPICHANGED") ;requires Win 8.1+ / Server 2012 R2+ ;~ GUIRegisterMsg($WM_GETDPISCALEDSIZE, "WM_GETDPISCALEDSIZE") While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $aCtrlFS[4][0] GUIDelete($hGUI) ExitLoop EndSwitch WEnd EndFunc ;==>Example1 Func ResizeFont($hWnd) Local $iDPI = _WinAPI_GetDpiForWindow($hWnd), $dpi_ratio = $iDPI / 96 Switch $hWnd Case $hGUI Local $i For $i = 0 To UBound($aCtrlFS) - 1 GUICtrlSetFont($aCtrlFS[$i][0], $aCtrlFS[$i][1] * $dpi_ratio * $g_iDPI_ratio2, 400, 0, "Times New Roman", 5) Next Case $hGUI_child GUICtrlSetFont($iLable_child, 65 * $dpi_ratio * $g_iDPI_ratio2, 400, 0, "Times New Roman", 5) EndSwitch EndFunc ;==>ResizeFont Func _WinAPI_FindWindowEx($hWndParent, $hWndChildAfter = 0, $sClassName = "", $sWindowName = "") Local $aResult = DllCall($hDLL, "hwnd", "FindWindowEx", "hwnd", $hWndParent, "hwnd", $hWndChildAfter, "wstr", $sClassName, "wstr", $sWindowName) If @error Then Return SetError(@error, @extended, 0) Return $aResult[0] EndFunc ;==>_WinAPI_FindWindowEx #Region WinAPI DPI ;https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-isvaliddpiawarenesscontext Func _WinAPI_IsValidDpiAwarenessContext($DPI_AWARENESS_CONTEXT_value) Local $aResult = DllCall($hDLL, "bool", "IsValidDpiAwarenessContext", "int", $DPI_AWARENESS_CONTEXT_value) ;requires Win10 v1607+ / no server support If @error Then Return SetError(@error, @extended, 0) Return $aResult[0] EndFunc ;==>_WinAPI_IsValidDpiAwarenessContext ;https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-logicaltophysicalpointforpermonitordpi Func _WinAPI_LogicalToPhysicalPointForPerMonitorDPI($hWnd) Local $tPOINT = DllStructCreate($tagPOINT) Local $aResult = DllCall($hDLL, "bool", "LogicalToPhysicalPointForPerMonitorDPI", "hwnd", $hWnd, "struct*", $tPOINT) ;requires Win 8.1+ / no server support If @error Then Return SetError(@error, @extended, 0) Return $tPOINT EndFunc ;==>_WinAPI_LogicalToPhysicalPointForPerMonitorDPI ;https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-physicaltologicalpointforpermonitordpi Func _WinAPI_PhysicalToLogicalPointForPerMonitorDPI($hWnd) Local $tPOINT = DllStructCreate($tagPOINT) Local $aResult = DllCall($hDLL, "bool", "PhysicalToLogicalPointForPerMonitorDPI", "hwnd", $hWnd, "struct*", $tPOINT) ;requires Win 8.1+ / no server support If @error Then Return SetError(@error, @extended, 0) Return $tPOINT EndFunc ;==>_WinAPI_PhysicalToLogicalPointForPerMonitorDPI ;https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getdpiforwindow Func _WinAPI_GetDpiForWindow($hWnd) Local $aResult = DllCall($hDLL, "uint", "GetDpiForWindow", "hwnd", $hWnd) ;requires Win10 v1607+ / no server support If @error Then Return SetError(@error, @extended, 0) Return $aResult[0] EndFunc ;==>_WinAPI_GetDpiForWindow ;https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getdpiforsystem Func _WinAPI_GetDpiForSystem() Local $aResult = DllCall($hDLL, "uint", "GetDpiForSystem") ;requires Win10 v1607+ / no server support If @error Then Return SetError(@error, @extended, 0) Return $aResult[0] EndFunc ;==>_WinAPI_GetDpiForSystem ;https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getthreaddpiawarenesscontext Func _WinAPI_GetThreadDpiAwarenessContext() Local $aResult = DllCall($hDLL, "int", "GetThreadDpiAwarenessContext") ;requires Win10 v1607+ / no server support If @error Then Return SetError(@error, @extended, 0) Return $aResult[0] EndFunc ;==>_WinAPI_GetThreadDpiAwarenessContext ;https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getdpifromdpiawarenesscontext Func _WinAPI_GetDpiFromDpiAwarenessContext($DPI_AWARENESS_CONTEXT_value) Local $aResult = DllCall($hDLL, "int", "GetDpiFromDpiAwarenessContext", "int", $DPI_AWARENESS_CONTEXT_value) ;requires Win10 v1803+ / Windows Server 2016+ If @error Then Return SetError(@error, @extended, 0) Return $aResult[0] EndFunc ;==>_WinAPI_GetDpiFromDpiAwarenessContext ;https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getdpiawarenesscontextforprocess Func _WinAPI_GetDpiAwarenessContextForProcess($hProcess) Local $aResult = DllCall($hDLL, "int", "GetDpiAwarenessContextForProcess", "handle", $hProcess) ;requires Win10 v1803+ / Windows Server 2016+ If @error Then Return SetError(@error, @extended, 0) Return $aResult[0] EndFunc ;==>_WinAPI_GetDpiAwarenessContextForProcess ;https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getsystemdpiforprocess Func _WinAPI_GetSystemDpiForProcess($hProcess) Local $aResult = DllCall($hDLL, "uint", "GetSystemDpiForProcess", "handle", $hProcess) ;requires Win10 v1803+ / Windows Server 2016+ If @error Then Return SetError(@error, @extended, 0) Return $aResult[0] EndFunc ;==>_WinAPI_GetSystemDpiForProcess ;https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getwindowdpiawarenesscontext Func _WinAPI_GetWindowDpiAwarenessContext($hWnd) Local $aResult = DllCall($hDLL, "uint", "GetWindowDpiAwarenessContext", "hwnd", $hWnd) ;requires Win10 v1607+ / no server support If @error Then Return SetError(@error, @extended, 0) Return $aResult[0] EndFunc ;==>_WinAPI_GetWindowDpiAwarenessContext ;https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setprocessdpiawarenesscontext Func _WinAPI_SetProcessDpiAwarenessContext($DPI_AWARENESS_CONTEXT_value) Local $aResult = DllCall($hDLL, "bool", "SetProcessDpiAwarenessContext", "int", $DPI_AWARENESS_CONTEXT_value) ;requires Win10 v1703+ / Windows Server 2016+ If @error Then Return SetError(@error, @extended, 0) Return $aResult[0] EndFunc ;==>_WinAPI_SetProcessDpiAwarenessContext ;https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setthreaddpiawarenesscontext Func _WinAPI_SetThreadDpiAwarenessContext($DPI_AWARENESS_CONTEXT_value) Local $aResult = DllCall($hDLL, "bool", "SetThreadDpiAwarenessContext", "int", $DPI_AWARENESS_CONTEXT_value) ;requires Win10 v1703+ / Windows Server 2016+ If @error Then Return SetError(@error, @extended, 0) Return $aResult[0] EndFunc ;==>_WinAPI_SetThreadDpiAwarenessContext ;https://learn.microsoft.com/en-us/windows/win32/api/shellscalingapi/nf-shellscalingapi-setprocessdpiawareness Func _WinAPI_SetProcessDpiAwareness($PROCESS_DPI_AWARENESS = $DPI_AWARENESS_PER_MONITOR_AWARE) ;https://docs.microsoft.com/en-us/windows/desktop/api/shellscalingapi/nf-shellscalingapi-setprocessdpiawareness Local $iResult = DllCall("Shcore.dll", "long", "SetProcessDpiAwareness", "int", $PROCESS_DPI_AWARENESS) ;requires Win 8.1+ / Server 2012 R2+ If @error Or $iResult Then Return SetError(1, 0, 0) Return 1 EndFunc ;==>_WinAPI_SetProcessDpiAwareness ;https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-adjustwindowrectexfordpi Func _WinAPI_AdjustWindowRectExForDpi($dpi, $dwStyle, $dwExStyle, $bMenu = False) Local $tRECT = DllStructCreate($tagRECT) Local $aResult = DllCall($hDLL, "bool", "AdjustWindowRectExForDpi", "struct*", $tRECT, "dword", $dwStyle, "bool", $bMenu, "dword", $dwExStyle, "uint", $dpi) ;requires Win10 v1607+ / no server support If @error Then Return SetError(@error, @extended, 0) Return $tRECT EndFunc ;==>_WinAPI_AdjustWindowRectExForDpi #EndRegion WinAPI DPI Func _GDIPlus_GraphicsGetDPIRatio($iDPIDef = 96) _GDIPlus_Startup() Local $hGfx = _GDIPlus_GraphicsCreateFromHWND(0) If @error Then Return SetError(1, @extended, 0) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetDpiX", "handle", $hGfx, "float*", 0) If @error Then Return SetError(2, @extended, 0) _GDIPlus_GraphicsDispose($hGfx) _GDIPlus_Shutdown() Return $aResult[2] EndFunc ;==>_GDIPlus_GraphicsGetDPIRatio Func _WinAPI_GetDpiForPrimaryMonitor($dpiType = $MDT_DEFAULT, $hMOnitor = 0, $iDPIDef = 96) ;https://learn.microsoft.com/en-us/windows/win32/api/shellscalingapi/nf-shellscalingapi-getdpiformonitor If $hMOnitor = 0 Then Local $aMonitors = _WinAPI_EnumDisplayMonitors() If @error Then Return SetError(1, 0, 0) Local $i For $i = 1 To $aMonitors[0][0] If _WinAPI_GetMonitorInfo($aMonitors[$i][0])[2] = 1 Then $hMOnitor = $aMonitors[$i][0] ExitLoop EndIf Next EndIf Local $tX = DllStructCreate("uint x"), $tY = DllStructCreate("uint y") Local $aRet = DllCall("Shcore.dll", "long", "GetDpiForMonitor", "long", $hMOnitor, "int", $dpiType, "struct*", $tX, "struct*", $tY) If @error Or Not IsArray($aRet) Then Return SetError(2, 0, 0) Local $aDPI[2] = [$iDPIDef / $tX.x, $tX.x / $iDPIDef] Return $aDPI EndFunc ;==>_WinAPI_GetDpiForPrimaryMonitor Func WM_GETDPISCALEDSIZE($hWnd, $iMsg, $wParam, $lParam) Local $tSize = DllStructCreate($tagSIZE, $lParam) Return True EndFunc ;==>WM_GETDPISCALEDSIZE Func WM_DPICHANGED($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $wParam ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $lParam = ' & $lParam & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console Local $tRECT = DllStructCreate($tagRECT, $lParam) Local $iX = $tRECT.left, $iY = $tRECT.top, $iW = $tRECT.right - $iX, $iH = $tRECT.bottom - $iY ;requires Win10 v1607+ / no server support DllCall($hDLL, "bool", "AdjustWindowRectExForDpi", "struct*", $tRECT, "dword", BitOR($WS_BORDER, $WS_CAPTION, $WS_CLIPSIBLINGS, $WS_GROUP, $WS_POPUP, $WS_SYSMENU, $WS_VISIBLE), "bool", False, "dword", $WS_EX_WINDOWEDGE, "uint", _WinAPI_HiWord($wParam)) _WinAPI_SetWindowPos($hWnd, 0, $iX, $iY, $iW, $iH, BitOR($SWP_NOZORDER, $SWP_NOACTIVATE)) ResizeFont($hWnd) Local Const $iDPI = _WinAPI_GetDpiForWindow($hWnd), $dpi_ratio = $iDPI / 96, $dpi_ratio2 = 96 / $iDPI Local $aPos = ControlGetPos($hWnd, "", $iPic_child) If UBound($aPos) = 4 Then _WinAPI_MoveWindow(GUICtrlGetHandle($iPic_child), $aPos[0] * $dpi_ratio2 * $g_iDPI_ratio2, $aPos[1] * $dpi_ratio2 * $g_iDPI_ratio2, $aPos[2] * $dpi_ratio * $g_iDPI_ratio2, $aPos[3] * $dpi_ratio * $g_iDPI_ratio2) GUICtrlSetImage($iPic_child, $sImage) EndIf $tRECT = 0 Return 1 EndFunc ;==>WM_DPICHANGED Func _WinAPI_SetDPIAwareness($DPIAwareContext = $DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE, $iMode = 1) Switch @OSBuild Case 6000 To 9199 If Not DllCall($hDLL, "bool", "SetProcessDPIAware") Then Return SetError(1, 0, 0) ;requires Vista+ / Server 2008+ Return 1 Case 9200 To 13999 _WinAPI_SetProcessDpiAwareness($DPIAwareContext) ;requires Win 8.1+ / Server 2012 R2+ If @error Then Return SetError(2, @error, 0) Return 1 Case @OSBuild > 13999 _WinAPI_SetProcessDpiAwarenessContext_int($DPIAwareContext, $iMode) If @error Then Return SetError(3, @error, 0) Return 1 EndSwitch Return -1 EndFunc ;==>_WinAPI_SetDPIAwareness Func _WinAPI_SetProcessDpiAwarenessContext_int($DPIAwareContext = $DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE, $iMode = 1) $DPIAwareContext = ($DPIAwareContext < -5) ? -5 : ($DPIAwareContext > -1) ? -1 : $DPIAwareContext $iMode = ($iMode < 1) ? 1 : ($iMode > 2) ? 2 : $iMode Switch $iMode Case 1 _WinAPI_SetProcessDpiAwarenessContext($DPIAwareContext) If @error Then Return SetError(1, 0, 0) Case 2 ;https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setprocessdpiawarenesscontext _WinAPI_SetThreadDpiAwarenessContext($DPIAwareContext) ;requires Win10 v1607+ / no server support If @error Then Return SetError(2, 0, 0) EndSwitch Return 1 EndFunc ;==>_WinAPI_SetProcessDpiAwarenessContext_int _WinAPI_SetDPIAwareness.zip
    1 point
  9. Subz

    Excel - Freeze the top row

    Couple of ways: #include <Excel.au3> ;~ Example 1 Local $oExcel = _Excel_Open() $oExcel.ActiveWindow.FreezePanes = False Local $sWorkbook = @ScriptDir & "\FileName.xlsx" Local $oWorkbook = _Excel_BookOpen($oExcel, $sWorkbook) $oWorkbook.ActiveSheet.Range("B2").Select $oExcel.ActiveWindow.FreezePanes = True ;~ Example 2 Local $oExcel = _Excel_Open() $oExcel.ActiveWindow.FreezePanes = False Local $sWorkbook = @ScriptDir & "\FileName.xlsx" Local $oWorkbook = _Excel_BookOpen($oExcel, $sWorkbook) _Excel_FreezePanes($oExcel, 2, 2) Func _Excel_FreezePanes($oExcel, $iCol = 0, $iRow = 1) If Not IsObj($oExcel) Or ObjName($oExcel, 1) <> "_Application" Then Return $oExcel.ActiveWindow.SplitColumn = $iCol $oExcel.ActiveWindow.SplitRow = $iRow $oExcel.ActiveWindow.FreezePanes = True EndFunc
    1 point
×
×
  • Create New...