Sign in to follow this  
Followers 0
yxrkt

Highlight search result in edit.

6 posts in this topic

CODE
$search = InputBox("search", "", "", "")

$contentmyedit = GUICtrlRead($myedit)

$searchresult = StringInStr($contentmyedit,$search)

SETFUCKINGFOCUS($myedit,$searchresult) <-- ?

is there a function or something that highlights the search-result in my edit ?

Share this post


Link to post
Share on other sites



What kind of object is $myedit ?? GUIEdit ??


Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit

Share this post


Link to post
Share on other sites

What kind of object is $myedit ?? GUIEdit ??

sorry forgot..

yep its GUIedit.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

CODE
$search = InputBox("search", "", "", "")

$contentmyedit = GUICtrlRead($myedit)

$searchresult = StringInStr($contentmyedit,$search)

SETFUCKINGFOCUS($myedit,$searchresult) <-- ?

is there a function or something that highlights the search-result in my edit ?

_GUICtrlEditGetSel/_GUICtrlEditSetSel/or _GUICtrlEdit* in general

Some effort on your part to customize it to fit your needs will be in order... or you can search for these on the forum to see how others do it.

Also... _GUICtrlEditFind

Edited by SmOke_N

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Thank you for pointing me to _GuiGtrlEditSetSel.

Here's the code.

$search = InputBox("search", "", "", "")
$contentmyedit = GUICtrlRead($myedit)
$searchresult = StringInStr($contentmyedit,$search)

$searchlenght = StringLen($search)
$searchresult1 = $searchresult - 1
$searchresult2 = $searchresult + $searchlenght - 1
_guictrleditsetsel($myedit,$searchresult1 , $searchresult2)
_GUICtrlEditScroll($myedit, $SB_SCROLLCARET)

Share this post


Link to post
Share on other sites

Thanks yxrt.

I used some of your code in my own version of notepad (i also added a find next function just be replacing the 1 in StringInStr with a variable which is changed everytime you perform the find next function)

Func SearchButton()
    $ReadInputS = GUICtrlRead ( $SearchInput )
    $ReadInputR = GUICtrlRead ( $ReplaceInput )
    $CaseMatch  = GUICtrlRead ( $MatchCase )
    $ReplaceCheck = GUICtrlRead ( $SearchReplaceChkBox )
    If $CaseMatch = 1 Then
        $MatchCase1 = 1
    Else
        $MatchCase1 = 0
    EndIf
    If $ReadInputS = "" Then
    Else
$contentmyedit = GUICtrlRead($Text)
$searchresult = StringInStr($contentmyedit,$ReadInputS,$MatchCase1,1)
If $searchresult = 0 Then
    MsgBox ( 48 , "Error!" , "Reached end of document." )
Else
$searchlenght = StringLen($ReadInputS)
$searchresult1 = $searchresult - 1
$searchresult2 = $searchresult + $searchlenght - 1
_guictrleditsetsel($Text,$searchresult1 , $searchresult2)
_GUICtrlEditScroll($Text, $SB_SCROLLCARET)
If $ReplaceCheck = 1 Then
    _GUICtrlEditReplaceSel ( $Text , TRUE , $ReadInputR )
Else
    GUICtrlSetState ( $SearchReplaceChkBox , $GUI_ENABLE )
    GUICtrlSetState ( $FindNButton , $GUI_ENABLE )
EndIf
    EndIf
    EndIf
EndFunc

Func SearchButtonN();Find next button
    $ReadInputS = GUICtrlRead ( $SearchInput )
    $ReadInputR = GUICtrlRead ( $ReplaceInput )
    $CaseMatch  = GUICtrlRead ( $MatchCase )
    $ReplaceCheck = GUICtrlRead ( $SearchReplaceChkBox )
    If $CaseMatch = 1 Then
        $MatchCase1 = 1
    Else
        $MatchCase1 = 0
    EndIf
    If $ReadInputS = "" Then
    Else
$contentmyedit = GUICtrlRead($Text)
$searchresult = StringInStr($contentmyedit,$ReadInputS,$MatchCase1,$Search)
If $searchresult = 0 Then
    MsgBox ( 48 , "Error!" , "Reached end of document." )
Else
$searchlenght = StringLen($ReadInputS)
$searchresult1 = $searchresult - 1
$searchresult2 = $searchresult + $searchlenght - 1
_guictrleditsetsel($Text,$searchresult1 , $searchresult2)
_GUICtrlEditScroll($Text, $SB_SCROLLCARET)
If $ReplaceCheck = 1 Then
    _GUICtrlEditReplaceSel ( $Text , TRUE , $ReadInputR )
Else
    GUICtrlSetState ( $SearchReplaceChkBox , $GUI_ENABLE )
    GUICtrlSetState ( $FindNButton , $GUI_ENABLE )
EndIf
    EndIf
$Search = $Search+1
EndIf
EndFunc

I have too much time on my hands :D


My scripts:AppLauncherTRAY - Awesome app launcher that runs from the system tray NEW VERSION! | Run Length Encoding - VERY simple compression in pure autoit | Simple Minesweeper Game - Fun little game :)My website

Share this post


Link to post
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
Sign in to follow this  
Followers 0