AutoHotkey Community

It is currently May 27th, 2012, 10:16 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 106 posts ]  Go to page Previous  1 ... 4, 5, 6, 7, 8
Author Message
 Post subject: Find and Replace Text
PostPosted: March 25th, 2011, 10:33 am 
Offline

Joined: October 28th, 2008, 10:35 am
Posts: 2
Hello, sorry for my English, I'm from Spain.

This is the Find Text Function.

No Loop for single replacement.

Code:
; ******************************PLACE IN feature_demo.ahk********************
^R::
SearchText:="Hello"
ReplaceText:="Morning"
Lenght_String:= % StrLen(SearchText)
cRichEdit(REdit1, "FindText",SearchText,Lenght_String,ReplaceText)
Return
; ***************************************************************************



; *******************************PLACE IN cRichEdit.ahk***********************

Else If _action = FindText
  {   
  VarSetCapacity(FindText,12,0)
  Loop
    {
    ;--------------------------------REDIT TEXT LENGHT---------------------   
    VarSetCapacity(_tmp1, 8, 0)
    NumPut(0, _tmp1, 0)
    NumPut(_tmp2, _tmp1, 4)
    Text_Lengt:= % DllCall("user32.dll\SendMessage", "UInt", _ctrlID, "UInt", 0x45F, "UInt", &_tmp1, "UInt", "0") 
    ;--------------------------------------------------------------------------------
    NumPut(Result,FindText) 
    NumPut(Text_Lengt,FindText,4) 
    NumPut(&opt1,FindText,8)
    Result:=DllCall("SendMessage","UInt",_ctrlID,"UInt",0x438,"UInt",0x5,"UInt",&FindText)
   
    If (Result=-1)
      Break
    ;---------------------------------SELECT RANGE TEXT----------------
    string_start:=Result
    string_end:=Result+opt2
    VarSetCapacity(_tmp1, 8, 0)
    NumPut(string_start, _tmp1, 0, "Int")
    NumPut(string_end, _tmp1, 4, "Int")
    DllCall("user32.dll\SendMessage", "UInt", _ctrlID, "UInt", 0x437, "UInt", "0", "UInt", &_tmp1)
   
   
   
    ;------------------SEND NEW TEXT or COLOUR REPLACE or ... -------------------------
    _tmp2 := true
    DllCall("user32.dll\SendMessage", "UInt", _ctrlID, "UInt", 0xC2, "UInt", _tmp2, "UInt", &opt3)       
    ;------------------------------------------------------------------------------
    Result:=1
    } 
Return
  }

;*****************************************************************************************



Use this for colour replacement.

Code:
    color:="Red"
   
    _cnt1 := Instr(_predef, color . "|")
    If (_cnt1)
      color := SubStr(_predef, (_cnt1 - 7), 6)
    If (SubStr(opt3, 1, 2) = "0x")
      StringTrimLeft, color, color, 2
    color := "0x" . SubStr(color, 5, 2) . SubStr(color, 3, 2) . SubStr(color, 1, 2)

    VarSetCapacity(_tmp1, 60, Chr(0))                                 ; CHARFORMAT struct
    NumPut(60, _tmp1, 0, "Int")                                       ; cbSize
    NumPut(0x40000000, _tmp1, 4)                                    ; dwMask
    NumPut(color, _tmp1, 20)                                          ; crTextColor

  ; ** apply the colour
    DllCall("user32.dll\SendMessage", "UInt", _ctrlID, "UInt", 0x444, "UInt", "1", "UInt", &_tmp1)
   
    ;------------------------------------------------------------------------------
    Result:=Result+opt2


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 106 posts ]  Go to page Previous  1 ... 4, 5, 6, 7, 8

All times are UTC [ DST ]


Who is online

Users browsing this forum: specter333, XX0 and 24 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group