-
Recently Browsing 0 members
No registered users viewing this page.
-
Similar Content
-
By argumentum
This was born in a help topic but then I thought I'd be a good UDF to have.
The difference between _ChooseFont() and this _ChooseFontEx() , is that it adds:
The use of keyword "Default", as default value.
Hide parts of the font choosing GUI
Uses the proper default color if no color is declared (default)
I tested this UDF to work with AutoIt from v3.2.12.1 and the current v3.3.16.1, so it should work in every version.
This also copied the Dll calls from other UDFs to this one, to give it independence from otherwise needed additional includes.
The Example:
#include <_ChooseFontEx.au3> #include <Array.au3> ; for the example Example() Func Example() Local $hParent = GUICreate("Test GUI", 300, 300, @DesktopWidth / 3) For $i = 1 To 7 GUICtrlCreateLabel("label " & $i, 10, $i * 25) Next GUISetState() Sleep(1000) ; used "Arial" as it is found from WinXP to Win11 Local $aFont = _ChooseFont("Arial", 8, 0, 0, False, False, False, $hParent) _ArrayDisplay($aFont, "Example original") $aFont = _ChooseFontEx("Arial", 8, Default, Default, Default, Default, Default, $hParent) _ArrayDisplay($aFont, "Example # 1") $aFont = _ChooseFontEx("Arial", 8, Default, 600, Default, Default, Default, $hParent, 63, "Please choose a font:") _ArrayDisplay($aFont, "Example # 2") Sleep(1000) EndFunc ;==>Example The UDF:
#include-once ; if you're gonna use it as UDF #include <Misc.au3> ; for _ChooseFont() Global $__ChooseFontEx_Hook_WH_CBT = 5, $__ChooseFontEx_Hook_hProc = 0, $__ChooseFontEx_Hook_hHook = 0, _ $__ChooseFontEx_Hook_iHideThese = 3, $__ChooseFontEx_Hook_sNewWinTitle = "", $__ChooseFontEx_Hook_wParamKept = 0 ; #FUNCTION# ==================================================================================================================== ; Name...........: _ChooseFontEx ; Description ...: Creates a Font dialog box that enables the user to choose attributes for a logical font. ; Syntax.........: _ChooseFont([$sFontName = "Courier New"[, $iPointSize = 10[, $iColorRef = 0[, $iFontWeight = 0[, $iItalic = False[, $iUnderline = False[, $iStrikethru = False[, $hWndOwner = 0[, $iHideThese = 7[, $sNewWinTitle = ""]]]]]]]]]]) ; Parameters ....: $sFontName - Default font name ; $iPointSize - Pointsize of font ; $iColorRef - COLORREF rgbColors ; $iFontWeight - Font Weight ; $iItalic - Italic ; $iUnderline - Underline ; $iStrikethru - Optional: Strikethru ; $hWndOwnder - Handle to the window that owns the dialog box ; $iHideThese - Bitwise: Default is 3 ( SysLink and Script ) ; 1: hide SysLink ; 2: hide Script ; 4: hide Color ( if 4 and 8 , also the GroupBox "Effects" will be hidden ) ; 8: hide underline & strikeout ; 16: hide "Font style" ; 32: hide "Font size" ; $sNewWinTitle - Change the WinTitle ; Return values .: Success - Array in the following format: ; |[0] - contains the number of elements ; |[1] - attributes = BitOr of italic:2, undeline:4, strikeout:8 ; |[2] - fontname ; |[3] - font size = point size ; |[4] - font weight = = 0-1000 ; |[5] - COLORREF rgbColors ; |[6] - Hex BGR Color ; |[7] - Hex RGB Color ; Failure - -1 ; Author ........: argumentum ; https://www.autoitscript.com/forum/topic/209809-_choosefontex/ ; Modified.......: ; Remarks .......: Default keyword friendly. Dark Mode friendly. ; Related .......: _ChooseFont() ; Link ..........; ; Example .......; Yes ; =============================================================================================================================== Func _ChooseFontEx($sFontName = "Courier New", $iPointSize = 10, $iFontColorRef = Default, $iFontWeight = 0, _ $bItalic = False, $bUnderline = False, $bStrikethru = False, $hWndOwner = 0, $iHideThese = 3, $sNewWinTitle = "") Local $aRet, $iErr, $iExt, $COLOR_BTNTEXT = 18 If $iPointSize = Default Then $iPointSize = 10 ; Default as a parameter is not in the Misc.au3 UDF. Added here for convenience. If $iFontColorRef = Default Then $iFontColorRef = 0 $aRet = DllCall("user32.dll", "INT", "GetSysColor", "int", $COLOR_BTNTEXT) ; I use a dark theme, so 0x000000 is not my default. If Not @error Then $iFontColorRef = $aRet[0] EndIf If $iFontWeight = Default Then $iFontWeight = 0 If $bItalic = Default Then $bItalic = False If $bUnderline = Default Then $bUnderline = False If $bStrikethru = Default Then $bStrikethru = False If $hWndOwner = Default Then $hWndOwner = 0 If $iHideThese = Default Then $iHideThese = 3 ; hide SysLink + hide Script If $sNewWinTitle = Default Then $sNewWinTitle = "" __ChooseFontEx_Hook("StartIt", $iHideThese, $sNewWinTitle) ; logic moved to this func to keep hook variables as local $aRet = _ChooseFont($sFontName, $iPointSize, $iFontColorRef, $iFontWeight, $bItalic, $bUnderline, $bStrikethru, $hWndOwner) $iErr = @error $iExt = @extended __ChooseFontEx_Hook("EndIt", "", "") Return SetError($iErr, $iExt, $aRet) EndFunc ;==>_ChooseFontEx ; #FUNCTION# ==================================================================================================================== ; Name...........: __ChooseFontEx_Hook ; Description ...: Helper function for _ChooseFontEx() ; Remarks .......: For Internal Use Only ; =============================================================================================================================== Func __ChooseFontEx_Hook($nCode, $wParam, $lParam) ; Tested in XP, 10 and 11 ;Local Static $__ChooseFontEx_Hook_WH_CBT = 5, $__ChooseFontEx_Hook_hProc = 0, _ ; moved to "Global" to make it 3.2.12.1 compatible ; $__ChooseFontEx_Hook_hHook = 0, $__ChooseFontEx_Hook_iHideThese = 3, $__ChooseFontEx_Hook_sNewWinTitle = "", $__ChooseFontEx_Hook_wParamKept = 0 Local $aRet Switch $nCode Case "StartIt" $__ChooseFontEx_Hook_sNewWinTitle = $lParam If $wParam < 0 Or $wParam > 63 Or $wParam = Default Then $__ChooseFontEx_Hook_iHideThese = 3 Else $__ChooseFontEx_Hook_iHideThese = Int($wParam) EndIf $__ChooseFontEx_Hook_hProc = DllCallbackRegister("__ChooseFontEx_Hook", "int", "int;int;int") Local $hThreadId = DllCall("kernel32.dll", "dword", "GetCurrentThreadId") If Not @error Then $aRet = DllCall("user32.dll", "handle", "SetWindowsHookEx", "int", $__ChooseFontEx_Hook_WH_CBT, _ "ptr", DllCallbackGetPtr($__ChooseFontEx_Hook_hProc), "handle", 0, "dword", $hThreadId[0]) If Not @error Then $__ChooseFontEx_Hook_hHook = $aRet[0] EndIf Return Case "EndIt" DllCall("user32.dll", "bool", "UnhookWindowsHookEx", "handle", $__ChooseFontEx_Hook_hHook) ;If @error Then ConsoleWrite('! @error ' & @ScriptLineNumber & @CRLF) DllCallbackFree($__ChooseFontEx_Hook_hProc) $__ChooseFontEx_Hook_hHook = 0 $__ChooseFontEx_Hook_hProc = 0 Return EndSwitch ; $nCode = 3 ( 1st control created in the canvas is the window, hance "wParamKept = $wParam" ) If $nCode = 3 And $__ChooseFontEx_Hook_wParamKept = 0 Then $__ChooseFontEx_Hook_wParamKept = $wParam If $nCode = 9 And $__ChooseFontEx_Hook_wParamKept = 1 Then $__ChooseFontEx_Hook_wParamKept = 0 If $nCode = 5 And $__ChooseFontEx_Hook_wParamKept = $wParam Then $__ChooseFontEx_Hook_wParamKept = 1 Local $hWnd = HWnd($wParam) If BitAND($__ChooseFontEx_Hook_iHideThese, 1) Then ControlHide($hWnd, "", "SysLink1") ; <A>Show more fonts</A> If BitAND($__ChooseFontEx_Hook_iHideThese, 2) Then ControlHide($hWnd, "", "Static7") ; Script: ControlHide($hWnd, "", "ComboBox5") ; Script comboBox EndIf If BitAND($__ChooseFontEx_Hook_iHideThese, 4) Then ControlHide($hWnd, "", "Static4") ; Color: ControlHide($hWnd, "", "ComboBox4") ; Color comboBox EndIf If BitAND($__ChooseFontEx_Hook_iHideThese, 8) Then ControlHide($hWnd, "", "Button2") ; Strikeout: ControlHide($hWnd, "", "Button3") ; Underline: EndIf If BitAND($__ChooseFontEx_Hook_iHideThese, 16) Then ; Font style: ControlHide($hWnd, "", "Static2") ControlHide($hWnd, "", "ComboBox2") EndIf If BitAND($__ChooseFontEx_Hook_iHideThese, 32) Then ; Size: ControlHide($hWnd, "", "Static3") ControlHide($hWnd, "", "ComboBox3") EndIf If BitAND($__ChooseFontEx_Hook_iHideThese, 4) And BitAND($__ChooseFontEx_Hook_iHideThese, 8) Then ControlHide($hWnd, "", "Button1") ; Effects: If $__ChooseFontEx_Hook_sNewWinTitle <> "" Then WinSetTitle($hWnd, "", $__ChooseFontEx_Hook_sNewWinTitle) EndIf $aRet = DllCall("user32.dll", "lresult", "CallNextHookEx", "handle", $__ChooseFontEx_Hook_hHook, "int", $nCode, "wparam", $wParam, "lparam", $lParam) If Not @error Then Return $aRet[0] Return 0 EndFunc ;==>__ChooseFontEx_Hook #cs #include <Array.au3> ; for the example Example() Func Example() Local $hParent = GUICreate("Test GUI", 300, 300, @DesktopWidth / 3) For $i = 1 To 7 GUICtrlCreateLabel("label " & $i, 10, $i * 25) Next GUISetState() Sleep(1000) Local $aFont = _ChooseFontEx("Segoe UI", 8, Default, Default, Default, Default, Default, $hParent) _ArrayDisplay($aFont, "Example # 1") $aFont = _ChooseFontEx("Segoe UI", 8, Default, 600, Default, Default, Default, $hParent, 63, "Please choose a font:") _ArrayDisplay($aFont, "Example # 2") Sleep(1000) EndFunc ;==>Example #ce Talking to myself: I don't know if start annoying the MVPs into modifying the default ChooseFont() to include these features in it is well worth it. It should be but I don't wanna push the code uphill ...hmmm. They may just do it if they see this expansion as favorable. At least the default color should be implemented. idk.
If you're using this thing, please do leave a like, as to get an idea if is really useful or just not that useful. Thank you.
-
By BlueSkyMemory
While Scite doesn't support high dpi, I open it in compatibility settings. But it brings another problem:My au3 app automatically enables high dpi, causing gui disorder.
I've tried #AutoIt3Wrapper_Res_HiDpi=N but it doesn't work. I'd appreciate it if you could offer some help. Thanks.
-
By mLipok
In the display settings, in the advanced settings on the General tab is more or less the setting: The translation from GOOGLE: "If the resolution makes items are too small to achieve visual comfort, you can to offset this effect increase the resolution dpi. To change only the font size, click Cancel and go to the Appearance tab." EDIT: Here there is a possibility to choose: Default size 96 dpi Big size 120 dpi When I Change this option to 120 dpi, this causes display problems with elements such as Button. The problem is manifested by the fact that the text does not fit within the limits set by the size of the button. Of course, if you set 96 dpi, the text looks normal. Does anyone know a solution to this problem. I note that the solution like this: GUICtrlSetResizing(-1, $GUI_DOCKALL) unfortunately does not help.
mLipok -
By paw
I use SetSoundDevice to control my audio devices but the UI was either
blurry like this:
or unusable like this:
so I made this horrible thing to add scaling to the GUI:
#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Change2CUI=y #AutoIt3Wrapper_Res_HiDpi=y #AutoIt3Wrapper_AU3Check_Parameters=-w 3 -w 4 -w 5 #AutoIt3Wrapper_Run_Au3Stripper=y #Au3Stripper_Parameters=/sf /sv /rm #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <File.au3> ;~ _convertGUI("") If $CmdLine[0] <> 0 Then _convertGUI($CmdLine[1]) Func _convertGUI($sFilePath) If $sFilePath <> "" Then Local $aArray = FileReadToArray($sFilePath) Else ;TEST DATA Local $aArray[6] = ['$H_Res_Language = GUICtrlCreateProgress(5, 120, 210 + 25, 480, 20, BitOR($GUI_SS_DEFAULT_COMBO, $CBS_SIMPLE)) ; $CBS_DROPDOWNLIST)', _ 'Local $h_Ok = GUICtrlCreateButton("Ok", 72, 224, 81, 33, 0)', _ 'GUICreate($Warning_TiTle, 700, 310, -1, -1, $WS_SIZEBOX + $WS_SYSMENU + $WS_MINIMIZEBOX)', _ 'GUICtrlCreateLabel("Output type: ", 30, 130, 65, 20) ;, $SS_RIGHT)', _ '$H_FieldNameEdit = GUICtrlCreateEdit($INP_FieldNameEdit, 100,260+25, 500, 150 - 25) ;comment', 'Local $H_CANCEL = GUICtrlCreateGraphic("Cancel", 224, 224, 97, 33, 0)'] EndIf Local $hTimer = TimerInit(), $iGUIElementCount = 0, $sResult = "", $sFileName = "", $sDrive = "", $sDir = "", $sExtension = "" If @Compiled Then _PathSplit($sFilePath, $sDrive, $sDir, $sFileName, $sExtension) $sFileName = StringRegExpReplace($sFilePath, "^.*\\", "") EndIf For $i = 0 To (UBound($aArray) - 1) If StringRegExp($aArray[$i], "GUICtrlCreate|GUICreate") Then $sResult = _splitComma($aArray[$i]) If Not @error Then $aArray[$i] = $sResult $iGUIElementCount += 1 EndIf Next ConsoleWrite("t = " & TimerDiff($hTimer) & " GUI elements = " & $iGUIElementCount & " lines = " & (UBound($aArray) - 1) & @CRLF) If $sFileName <> "" Then Local $hFile = FileOpen("edited." & $sFileName, 2) _FileWriteFromArray("edited." & $sFileName, $aArray) FileClose($hFile) EndIf Exit EndFunc ;==>_convertGUI Func _splitComma($sString) Local $sSplitResult = "", $sTrimmedR = "", $sTrimmedL = "" Local $aSplit = StringSplit($sString, ',') If Not @error Then $sTrimmedR = "" $sTrimmedL = "" For $j = 1 To $aSplit[0] If StringRegExp($aSplit[1], "(?:.GUICtrlCreateGraphic|GUICtrlCreateProgress|GUICtrlCreateSlider|GUICtrlCreateTab|GUICtrlCreateTreeView)") Then If $j = 1 Then While StringLeft($aSplit[$j], 1) <> '(' $sTrimmedL &= StringLeft($aSplit[$j], 1) $aSplit[$j] = StringTrimLeft($aSplit[$j], 1) WEnd $aSplit[$j] = StringTrimLeft($aSplit[$j], 1) EndIf EndIf If $j = $aSplit[0] Then While StringRight($aSplit[$j], 1) <> ')' $sTrimmedR &= StringRight($aSplit[$j], 1) $aSplit[$j] = StringTrimRight($aSplit[$j], 1) WEnd $aSplit[$j] = StringTrimRight($aSplit[$j], 1) EndIf If StringRegExp($aSplit[$j], "[0-9]") And $aSplit[$j] <> -1 And $aSplit[$j] <> 0 And $aSplit[$j] <> 1 And Not StringInStr($aSplit[$j], ')') Then If StringRegExp($aSplit[$j], "\-|\+") Then ;put parenthesis around + or - $aSplit[$j] = '(' & $aSplit[$j] & ")*$g_DPI" Else $aSplit[$j] = $aSplit[$j] & "*$g_DPI" EndIf EndIf If $j < $aSplit[0] Then $sSplitResult &= $aSplit[$j] & ',' ElseIf $j = $aSplit[0] Then $sSplitResult &= $aSplit[$j] & ')' Else $sSplitResult &= $aSplit[$j] EndIf Next If $sTrimmedR <> "" Then $sSplitResult &= StringReverse($sTrimmedR) If $sTrimmedL <> "" Then $sSplitResult = $sTrimmedL & '(' & $sSplitResult Else SetError(1) Return EndIf ConsoleWrite($sSplitResult & @CRLF) Return $sSplitResult EndFunc ;==>_splitComma
And now it looks good:
but it doesn't work on everything, for example the "GUICtrlCreateLabel("Output type: ", 30, 130, 65, 20) ;, $SS_RIGHT)" (from the autoit3wrapper gui)
because the comment contains a parenthesis and it would break completely if there were variables as parameters..
Is there some kind of parser around that I could use instead or maybe someone who has already done something like this?
-
By TheDcoder
Hello, it has been a long time since I have posted here
I am working on an AutoIt project where I need to enable to user to interactively choose any point or coordinate on the screen... something like a big overlay where the user can click anywhere on the screen to select that point. @UEZ's screenshot tool may have something similar to what I need:
I just checked the source code for the tool and I see that the Mark_Area function has a part in selecting the area to screenshot, I tried to figure out how it works but it is simply too complex and long...
So I was wondering if there were any examples of interactively selecting points on a screen? Maybe an UDF that I can just use in my script to make the whole thing a matter of adding few lines
Thank you for the replies in advance!
-
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now