MattHiggs Posted June 18, 2017 Share Posted June 18, 2017 (edited) I wanted to know if it was possible to highlight a range of text in an input, similar to the functionality of _GUICtrlEdit_SetSel if I could use it on an input control. Edited June 19, 2017 by MattHiggs Link to comment Share on other sites More sharing options...
InunoTaishou Posted June 19, 2017 Share Posted June 19, 2017 An input control is an edit control, you can use SetSel on it expandcollapse popup#include <GUIConstantsEx.au3> #include <GuiEdit.au3> #include <GuiStatusBar.au3> #include <WindowsConstants.au3> Example() Func Example() Local $hStatusBar, $idEdit, $hGUI Local $sWow64 = "" If @AutoItX64 Then $sWow64 = "\Wow6432Node" Local $sFile = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt", "InstallDir") & "\include\_ReadMe_.txt" Local $aPartRightSide[3] = [190, 378, -1], $aSel ; Create GUI $hGUI = GUICreate("Edit Set Sel", 400, 300) $idEdit = GUICtrlCreateInput("", 2, 2, 394, 20) $hStatusBar = _GUICtrlStatusBar_Create($hGUI, $aPartRightSide) _GUICtrlStatusBar_SetIcon($hStatusBar, 2, 97, "shell32.dll") GUISetState(@SW_SHOW) ; Set Margins _GUICtrlEdit_SetMargins($idEdit, BitOR($EC_LEFTMARGIN, $EC_RIGHTMARGIN), 10, 10) ; Set Text _GUICtrlEdit_SetText($idEdit, FileRead($sFile)) ; Set Sel _GUICtrlEdit_SetSel($idEdit, 15, 20) ; Get Sel $aSel = _GUICtrlEdit_GetSel($idEdit) _GUICtrlStatusBar_SetText($hStatusBar, "Start: " & $aSel[0]) _GUICtrlStatusBar_SetText($hStatusBar, "End: " & $aSel[1], 1) ; Loop until the user exits. Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>Example MattHiggs 1 Link to comment Share on other sites More sharing options...
MattHiggs Posted June 19, 2017 Author Share Posted June 19, 2017 19 hours ago, InunoTaishou said: An input control is an edit control, you can use SetSel on it expandcollapse popup#include <GUIConstantsEx.au3> #include <GuiEdit.au3> #include <GuiStatusBar.au3> #include <WindowsConstants.au3> Example() Func Example() Local $hStatusBar, $idEdit, $hGUI Local $sWow64 = "" If @AutoItX64 Then $sWow64 = "\Wow6432Node" Local $sFile = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt", "InstallDir") & "\include\_ReadMe_.txt" Local $aPartRightSide[3] = [190, 378, -1], $aSel ; Create GUI $hGUI = GUICreate("Edit Set Sel", 400, 300) $idEdit = GUICtrlCreateInput("", 2, 2, 394, 20) $hStatusBar = _GUICtrlStatusBar_Create($hGUI, $aPartRightSide) _GUICtrlStatusBar_SetIcon($hStatusBar, 2, 97, "shell32.dll") GUISetState(@SW_SHOW) ; Set Margins _GUICtrlEdit_SetMargins($idEdit, BitOR($EC_LEFTMARGIN, $EC_RIGHTMARGIN), 10, 10) ; Set Text _GUICtrlEdit_SetText($idEdit, FileRead($sFile)) ; Set Sel _GUICtrlEdit_SetSel($idEdit, 15, 20) ; Get Sel $aSel = _GUICtrlEdit_GetSel($idEdit) _GUICtrlStatusBar_SetText($hStatusBar, "Start: " & $aSel[0]) _GUICtrlStatusBar_SetText($hStatusBar, "End: " & $aSel[1], 1) ; Loop until the user exits. Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>Example THank you for your reply. I had a feeling that was the case. I was trying to resolve a problem I was having with a script and thought that it was related to the subject of this post, but it wasn't. Anyway, thanks for feedback. Link to comment Share on other sites More sharing options...
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