Function Reference


_GUICtrlEdit_Find

Initiates a find dialog

#include <GuiEdit.au3>
_GUICtrlEdit_Find ( $hWnd [, $bReplace = False] )

Parameters

$hWnd Control ID/Handle to the control
$bReplace [optional] Replace Option:
    True - Show option
    False - Hide option

Return Value

None.

Remarks

If you use text from the edit control and that text gets replaced the function will no longer function correctly.

Example

Example 1

; using AutoIt Function

#include <GUIConstantsEx.au3>
#include <GuiEdit.au3>
#include <WindowsConstants.au3>

Example_Internal()

Func Example_Internal()
        Local $s_Text = "this is a test" & @CRLF & _
                        "this is only a test" & @CRLF & _
                        "this testing should work for you as well as it does for me"
        Local $idButton1, $idButton2, $iMsg, $idEdit

        GUICreate('Find And Replace Example with AutoIt ' & FileGetVersion(@AutoItExe), 622, 448, 192, 125)
        $idEdit = GUICtrlCreateEdit($s_Text, 64, 24, 505, 233, _
                        BitOR($ES_AUTOVSCROLL, $WS_VSCROLL, $ES_MULTILINE, $WS_HSCROLL, $ES_NOHIDESEL))
        $idButton1 = GUICtrlCreateButton("Find", 176, 288, 121, 33, 0)
        $idButton2 = GUICtrlCreateButton("Find And Replace", 368, 288, 121, 33, 0)
        GUISetState(@SW_SHOW)

        While 1
                $iMsg = GUIGetMsg()
                Select
                        Case $iMsg = $GUI_EVENT_CLOSE
                                ExitLoop
                        Case $iMsg = $idButton1
                                _GUICtrlEdit_Find($idEdit)
                        Case $iMsg = $idButton2
                                _GUICtrlEdit_Find($idEdit, True)
                        Case Else
                                ;;;;;;;
                EndSelect
        WEnd
        GUIDelete()
EndFunc   ;==>Example_Internal

Example 2

; using Standard UDF

#include <GUIConstantsEx.au3>
#include <GuiEdit.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example_External()

Func Example_External()
        Local $s_Text = 'Find And Replace Example with AutoIt ' & FileGetVersion(@AutoItExe) & @CRLF & _
                        "this is a test" & @CRLF & _
                        "this is only a test" & @CRLF & _
                        "this testing should work for you as well as it does for me"
        Local $hTitle, $hHandle
        Local $sTitle = "[CLASS:Notepad]"

        Run("notepad.exe", "", @SW_MAXIMIZE)
        ;Wait for the window "Untitled" to exist
        WinWait($sTitle)

        ; Get the handle of a notepad window
        $hTitle = WinGetHandle($sTitle)
        If @error Then
                MsgBox($MB_SYSTEMMODAL, "Error", "Could not find the correct window")
        Else
                $hHandle = ControlGetHandle($hTitle, "", "Edit1")
                If @error Then
                        MsgBox($MB_SYSTEMMODAL, "Error", "Could not find the correct control")
                Else
                        ; Send some text directly to this window's edit control
                        ControlSend($hTitle, "", "Edit1", $s_Text)
                        _GUICtrlEdit_Find($hHandle, True)
                EndIf
        EndIf
EndFunc   ;==>Example_External