Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 07/24/2023 in all areas

  1. Are you trying to say that you came up with nothing or did you paste the wrong link?
    3 points
  2. UEZ

    AutoIt Snippets

    _WinAPI_SetDPIAwareness.au3 ;Coded by UEZ build 2023-07-25 beta ;To get it working properly, please compile script first and start the exe afterwards #AutoIt3Wrapper_Res_HiDpi=y #AutoIt3Wrapper_UseX64=n #AutoIt3Wrapper_Change2CUI=y #include <GUIConstantsEx.au3> #include <Misc.au3> #include <WinAPIGdiDC.au3> #include <WinAPISysWin.au3> #include <WindowsConstants.au3> #Region _WinAPI_SetDPIAwareness ;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 ; 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 ;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("user32.dll", "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 Func _WinAPI_GetDPI($hWnd = _WinAPI_GetDesktopWindow()) Local Const $hDC = _WinAPI_GetDC($hWnd) If @error Then Return SetError(1, 0, 0) Local Const $iDPI = _WinAPI_GetDeviceCaps($hDC, $LOGPIXELSX) If @error Or Not $iDPI Then _WinAPI_ReleaseDC($hWnd, $hDC) Return SetError(2, 0, 0) EndIf _WinAPI_ReleaseDC($hWnd, $hDC) Return $iDPI EndFunc ;==>_WinAPI_GetDPI ;https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getdpiforwindow Func _WinAPI_GetDpiForWindow($hWnd) Local $aResult = DllCall("user32.dll", "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-setprocessdpiawarenesscontext Func _WinAPI_SetProcessDpiAwarenessContext($DPI_AWARENESS_CONTEXT_value) Local $aResult = DllCall("user32.dll", "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("user32.dll", "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) 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 Func _WinAPI_SetDPIAwareness($DPIAwareContext = $DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE, $iMode = 1) Switch @OSBuild Case 6000 To 9199 If Not DllCall("user32.dll", "bool", "SetProcessDPIAware") Then Return SetError(1, 0, 0) Case 9200 To 13999 $DPIAwareContext = ($DPIAwareContext < 0) ? 0 : ($DPIAwareContext > 2) ? 2 : $DPIAwareContext _WinAPI_SetProcessDpiAwareness($DPIAwareContext) If @error Then Return SetError(2, @error, 0) Case @OSBuild > 13999 $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(3, 0, 0) Case 2 _WinAPI_SetThreadDpiAwarenessContext($DPIAwareContext) If @error Then Return SetError(4, 0, 0) EndSwitch EndSwitch If @OSBuild < 14393 Then $iDPI = _WinAPI_GetDPI() If @error Then Return SetError(5, 0, 0) Else Local Const $hGUI_dummy = GUICreate("", 1, 1, 0, 0) $iDPI = _WinAPI_GetDpiForWindow($hGUI_dummy) GUIDelete($hGUI_dummy) If @error Then Return SetError(6, 0, 0) EndIf Return $iDPI EndFunc ;==>_WinAPI_SetDPIAwareness #EndRegion 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" Example1() Func Example1() Local $iDPI = _WinAPI_SetDPIAwareness($DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2) If @error Or Not $iDPI Then Exit MsgBox($MB_ICONERROR, "ERROR", "Cannot set DPI awareness!", 10) ConsoleWrite("DPI read: " & $iDPI & @CRLF) 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, "WM_DPICHANGED") While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $aCtrlFS[4][0] GUIDelete($hGUI_child) 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 WM_DPICHANGED($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $wParam Local $dpi_ratio2 = 96 / _WinAPI_LoWord($wParam) Local $dpi_ratio = _WinAPI_LoWord($wParam) / 96 Local $tRECT = DllStructCreate($tagRECT, $lParam) Local $iX = $tRECT.left, $iY = $tRECT.top, $iW = $tRECT.right - $iX, $iH = $tRECT.bottom - $iY _WinAPI_AdjustWindowRectExForDpi(_WinAPI_HiWord($wParam), BitOR($WS_BORDER, $WS_CAPTION, $WS_CLIPSIBLINGS, $WS_GROUP, $WS_POPUP, $WS_SYSMENU, $WS_VISIBLE), $WS_EX_WINDOWEDGE) _WinAPI_SetWindowPos($hWnd, 0, $iX, $iY, $iW, $iH, BitOR($SWP_NOZORDER, $SWP_NOACTIVATE)) ResizeFont($hWnd) 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 ConsoleWrite("DPI change to " & _WinAPI_LoWord($wParam) & " detected and applied to the GUI elements" & @CRLF) Return 1 EndFunc ;==>WM_DPICHANGED
    3 points
  3. It's not a bug. 'float' is not a html-atttribute but part of a html-attribute-value. The regexp you are using is based on detecting and ignoring html-attributes and uses the trailing '=' to detect and ignore these. To handle detecting html-attribute-value you will need a different regexp because there is no trailing '='. Please show some examples of the html code where 'float' must be replaced.
    2 points
  4. New version - 17 Jun 23 ======================= Added: Added 24hr unpadded H mask. New UDF in zip below. Changelog: Changelog.txt Here is my version of a UDF to transform date/time formats. It is entirely self-contained and although it defaults to English for the month/day names, you can set any other language very simply, even having different ones for the input and output. You need to provide a date/time string, a mask to tell the UDF what is in the string, and a second mask to format the output - the masks use the standard "yMdhmsT" characters. This is an example script showing some of the features: #include <Constants.au3> ; Only required for MsgBox constants #include "DTC.au3" Global $sIn_Date, $sOut_Date ; Basic format $sIn_Date = "13/08/02 18:30:15" $sOut_Date = _Date_Time_Convert($sIn_Date, "yy/MM/dd HH:mm:ss", "dddd, d MMMM yyyy at h:mm TT") MsgBox($MB_SYSTEMMODAL, "DTC Conversion", $sIn_Date & @CRLF & $sOut_Date) ; Note how day name is corrected $sIn_Date = "2013082 Sun 12:15:45 PM" $sOut_Date = _Date_Time_Convert($sIn_Date, "yyyyMMd ddd hh:mm:ss TT", "dddd, dd MMM yy") MsgBox($MB_SYSTEMMODAL, "DTC Conversion", $sIn_Date & @CRLF & $sOut_Date) ; Note use of $i19_20 parameter to change century $sIn_Date = "13/08/02 18:30:15" $sOut_Date = _Date_Time_Convert($sIn_Date, "yy/MM/dd HH:mm:ss", "dddd, d MMMM yyyy at h:mm TT", 10) MsgBox($MB_SYSTEMMODAL, "DTC Conversion", $sIn_Date & @CRLF & $sOut_Date) $sIn_Date = "18:30:15 13/08/02" $sOut_Date = _Date_Time_Convert($sIn_Date, "HH:mm:ss yy/MM/dd", "h:mm TT on ddd d MMM yyyy") MsgBox($MB_SYSTEMMODAL, "DTC Conversion", $sIn_Date & @CRLF & $sOut_Date) ; Just to show it works both ways $sIn_Date = "Friday, 2 August 2013 at 6:30 PM" $sOut_Date = _Date_Time_Convert($sIn_Date, "dddd, d MMMM yyyy at h:mm TT", "dd/MM/yy HH:mm") MsgBox($MB_SYSTEMMODAL, "DTC Conversion", $sIn_Date & @CRLF & $sOut_Date) $sIn_Date = $sOut_Date $sOut_Date = _Date_Time_Convert($sIn_Date, "dd/MM/yy HH:mm", "dddd, d MMMM yyyy at h:mm TT") MsgBox($MB_SYSTEMMODAL, "DTC Conversion", $sIn_Date & @CRLF & $sOut_Date) ; Note false returns for non-specified elements $sIn_Date = "6:15 P" $sOut_Date = _Date_Time_Convert($sIn_Date, "h:m T", "yy/MM/dd HH:mm:ss") MsgBox($MB_SYSTEMMODAL, "DTC Conversion", $sIn_Date & @CRLF & $sOut_Date) ; Note use of "x" in place of actual spacing/punctuation $sIn_Date = "Sun 12:15:45 PM" $sOut_Date = _Date_Time_Convert($sIn_Date, "dddxhhxmmxssxTT", "dddd HH:mm") MsgBox($MB_SYSTEMMODAL, "DTC Conversion", $sIn_Date & @CRLF & $sOut_Date) ; Output month/day strings changed to French _Date_Time_Convert_Set("smo", "jan,fév,mar,avr,mai,juin,juil,août,sept,oct,nov,déc") _Date_Time_Convert_Set("ldo", "dimanche,lundi,mardi,mercredi,jeudi,vendredi,samedi") _Date_Time_Convert_Set("SDO", 3) ; Each short name is first 3 chars of equivalent long name ; Note as only the short day names are required, they could have been set directly: ; _Date_Time_Convert_Set("sdo", "dim,lun,mar,mer,jeu,ven,sam") $sIn_Date = "20130716 Sun 12:15:45 PM" $sOut_Date = _Date_Time_Convert($sIn_Date, "yyyyMMd ddd hh:mm:ss TT", "ddd, d MMM yy") MsgBox($MB_SYSTEMMODAL, "DTC Conversion", $sIn_Date & @CRLF & $sOut_Date) ; Output month/day strings changed to German _Date_Time_Convert_Set("smo", "Jan.,Feb.,März,Apr.,Mai,Juni,Juli,Aug.,Sept.,Okt.,Nov.,Dez.") _Date_Time_Convert_Set("ldo", "Sonntag,Montag,Dienstag,Mittwoch,Donnerstag,Freitag,Samstag") $sIn_Date = "20130716 Sun 12:15:45 PM" $sOut_Date = _Date_Time_Convert($sIn_Date, "yyyyMMd ddd hh:mm:ss TT", "dddd, d MMM yy") MsgBox($MB_SYSTEMMODAL, "DTC Conversion", $sIn_Date & @CRLF & $sOut_Date) ; All strings reconverted to default English _Date_Time_Convert_Set() ; As shown here $sIn_Date = "20130716 Sun 12:15:45 PM" $sOut_Date = _Date_Time_Convert($sIn_Date, "yyyyMMd ddd hh:mm:ss TT", "ddd, d MMM yy") MsgBox($MB_SYSTEMMODAL, "DTC Conversion", $sIn_Date & @CRLF & $sOut_Date) And here is the UDF and example in zip format: DTC.zip As always, happy for any comments. M23
    1 point
  5. Solely based on the HTML samples that you have supplied, the search text is always immediately preceded by a ">". If that will always be the case, then the following regular expression might work for you. If it can have zero or more spaces after the ">" but before the search text, then you can easily make that modification to the pattern. Func _HTML_ReplaceAllText($sSource, $sSearchText, $sReplaceText) Return StringRegExpReplace( _ $sSource, _ "(?i)(>)\Q" & $sSearchText & "\E", _ "$1" & $sReplaceText _ ) EndFunc https://regex101.com/r/fIGif2/1
    1 point
  6. ISI360

    ISN AutoIt Studio

    It should check and re-install the update_installer.a3x, if it´s missing. I will implement a check for the "ISN_Adme.a3x" file too...
    1 point
×
×
  • Create New...