4 posts in this topic
I use a monospace font for editing AutoIt scripts in SciTE (currently, CourierNew 9pt). Regardless of what font size I set in the configuration, when I start SciTE to resume editing the script text is one size smaller than I specified. When I type Ctrl+<numpad-slash> the text changes to the desired size. The same is true of the output pane, and I have to reset the size for both areas every time I start SciTE.
IIRC, I've made few other changes to the configuration (e.g., changed the search highlight color and disabled Tidy), so this behavior seems odd. About SciTE says it's version 3.6.0 (Aug. 4, 2015).
Any idea how to fix this?
Hello all! I have had some issues reading text from different types of windows, occasionally, specifically with controlgettext.
**Before I begin, I know there are better ways to do what I attempt in the example below. That's not the point of this post. The point is my issues with controlgettext.
I am about to cite an example with an application you may be familiar with called SpeedFan (v4.52). My problem is not specific to speedfan, it is simply the most recent and easily reproducible example I can think of.
So, the goal of the script below is to get a string of text containing the current fan RPMs from the highlighted control in the screenshot below (see "speedfan_control_details.png").
Now, here's a simple script for grabbing the window handle and reading the text from that control:
$wintitle = "SpeedFan 4.52" $controlID = "197934" ;will be reformatted as "[ID:######]" $hwnd = wingethandle($wintitle) if @error<>0 then msgbox(0, "WinGetHandle", "FAILURE. @error="&@error) Exit EndIf $text = ControlGetText($hwnd, "", "[ID:"&$controlID&"]") if @error=1 then msgbox(0, "ControlGetText", "FAILURE. @error="&@error) ;failure returns "" and @error=1 Exit EndIf msgbox (0, "ControlGetText", "SUCCESS. @error="&@error &@CRLF& "$text="&$text) ;success returns string and @error=0 You'll see that the ControlGetText operation runs without error, however it does not capture any text from the control. If you explore the other controls in this one window, you'll find mixed results across the board. Neither the temps nor voltages can be read, while the log field and some other elements can be read. Even when you read the text from the whole window, those elements are not included in the visible nor hidden texts.
I have run into this issue many times in the past- inconsistencies in the ability of autoit to interact with certain controls. What is it which makes this text different than any other readable texts? Is there an alternate method of reading the text in the window/control which could work? Any and all info to help me solve this mystery and satisfy my curiosity would be greatly appreciated.
Thanks -Rob C
PS: Running Autoit v220.127.116.11 on Win7 Ultimate x64
So with me working in my Virtual Machines in full screen, I often have my Host OS playing music. Now the issue I had was trying to control the Host OS without having to minimise the Guest OS.
So I thought of this small program. I call it the Volume Control. It resides in the bottom right hand corner of your screen just above the system clock.
I'm still working on getting the volume buttons to increase/decrease when you hold down the button.
Currently, you will need to tap on the volume buttons numerous times to decrease/increase the volume.
Any other improvements let me know.
The source code, icon and compiled program are already in the zip.
I have created a bit of code to enable a script to find named controls on a userform, even though the MS CLASS description changes between machines.
e.g. The CLASS "WindowsForms10.EDIT.app.0.24b689f_r14_ad1" for a text box on one PC is different on another.
The below code, (a cut-down version of the code from jdelaney original post) loops through all the controls and finds the first one with the desired string in the control class name - in this case "EDIT". This name is then usable for setting the text using ControlSetText.
#include <array.au3> WinActivate("Edit Part Rule") $TheClassName = GetAllWindowsControls(WinGetHandle("Edit Part Rule"), "EDIT") ;Sleep(500) ControlSetText("Edit Part Rule", "", "[CLASS:" & $TheClassName & "; INSTANCE:3]", $CmdLine) ControlSetText("Edit Part Rule", "", "[CLASS:" & $TheClassName & "; INSTANCE:4]", $CmdLine) Func GetAllWindowsControls($hCallersWindow, $sStringIncludes) ; Get all list of controls $sClassList = WinGetClassList($hCallersWindow) ; Create array $aClassList = StringSplit($sClassList, @CRLF, 2) ; Sort array _ArraySort($aClassList) _ArrayDelete($aClassList, 0) ; Loop For $i = 0 To UBound($aClassList) - 1 If StringInStr($aClassList[$i], $sStringIncludes) Then Return $aClassList[$i] EndIf Next EndFunc ;==>GetAllWindowsControls If anyone has any suggestions to improve it, or a better way to achieve the same thing, please let me know.
why some fonts do not appear? in other programs like paint.net the font preview work. Thx
#include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <Misc.au3> #include <file.au3> #include <array.au3> #include <WindowsConstants.au3> #include <GuiEdit.au3> #include<ComboConstants.au3> #include <GUIComboBox.au3> $Form1 = GUICreate("Form1", 300, 200, -1, -1) $iPic = GUICtrlCreatePic("", 0, 0, 300, 60) $hPic = GUICtrlGetHandle($iPic) $Combo1 = GUICtrlCreateCombo("Select Font", 25, 64, 250, 25, BitOR($GUI_SS_DEFAULT_COMBO,$CBS_DROPDOWNLIST)) $s_FontList = _FileListToArray(@WindowsDir & "\Fonts\","*.ttf") $NFontList = UBound($s_FontList)-1 For $ff = 1 to $NFontList GUICtrlSetData($Combo1, StringTrimRight($s_FontList[$ff],4)) Next Global $hGraphic GUISetState(@SW_SHOW) _GDIPlus_Startup() $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hPic) _GDIPlus_GraphicsClear($hGraphic, 0xFFF0F0F0) GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE ; Clean up resources _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() Exit Case $Combo1 EndSwitch WEnd Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg Local $hWndFrom, $iIDFrom, $iCode, $hWndCombo If Not IsHWnd($combo1) Then $hWndCombo = GUICtrlGetHandle($Combo1) $hWndFrom = $ilParam $iIDFrom = BitAND($iwParam, 0xFFFF) ; Low Word $iCode = BitShift($iwParam, 16) ; Hi Word Switch $hWndFrom Case $combo1, $hWndCombo Switch $iCode ; no return value Case $CBN_SELCHANGE ; Sent when the user changes the current selection in the list box of a combo box _DebugPrint("$CBN_SELCHANGE" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _ "-->IDFrom:" & @TAB & $iIDFrom & @LF & _ "-->Code:" & @TAB & $iCode) $sFont = GUICtrlRead($Combo1) $sFontname = _WinAPI_GetFontResourceInfo(@WindowsDir & "\Fonts\" & $sFont & ".ttf") _GDIPlus_GraphicsClear($hGraphic, 0xFFF0F0F0) _GDIPlus_GraphicsDrawString($hGraphic, $sFontname, 10, 10, $sFontname, 10) EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND Func _DebugPrint($s_text, $line = @ScriptLineNumber) ConsoleWrite( _ "!===========================================================" & @LF & _ "+======================================================" & @LF & _ "-->Line(" & StringFormat("%04d", $line) & "):" & @TAB & $s_text & @LF & _ "+======================================================" & @LF) EndFunc ;==>_DebugPrint