Jump to content

find text using _GUICtrlEdit_create


luis713
 Share

Recommended Posts

I was looking in Autoit's library but couldn't find a way to find a text when using "_GUICtrlEdit_Create", there is a similar function "_GUICtrlEdit_Find" but it doesn't help me because I want to find the text and get the start/end position, the function before calls a window and I need to automate it. I have done this using "_GUICtrlRichEdit" but I have several problems using it, it appears and disappears, so now I'm trying to do it using _GUICtrlEdit

Link to comment
Share on other sites

#include <GuiEdit.au3>
#include <ButtonConstants.au3>
#include <ScrollBarsConstants.au3>

$GUI = GUICreate("Find in Edit")
$Edit = _GUICtrlEdit_Create($GUI, "", 5, 5, 390, 350, BitOR(0x003010C4, $ES_NOHIDESEL))
$Inp = GUICtrlCreateInput("", 5, 365, 345)
_GUICtrlEdit_SetCueBanner(GUICtrlGetHandle($Inp), "String to search")
$Btn = GUICtrlCreateButton("Find", 355, 365, 40, 25, $BS_DEFPUSHBUTTON)
GUISetState()

$Text = "The start value can be greater than the end value." & @CRLF & _
        "The lower of the two values specifies the character position of the first character in the selection." & @CRLF & _
        "The higher value specifies the position of the first character beyond the selection."
_GUICtrlEdit_SetText($Edit, $Text)

Do
  Switch GUIGetMsg()
    Case -3
      Exit
    Case $Btn
      $Line = GUICtrlRead($Inp)
      $Start = StringInStr(_GUICtrlEdit_GetText($Edit), $Line) - 1
      $End = $Start + StringLen($Line)
      _GUICtrlEdit_SetSel($Edit, $Start, $End)
      _GUICtrlEdit_Scroll($Edit, $SB_SCROLLCARET)
  EndSwitch
Until 0

 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...