Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

cRichEdit - Standard RichEdit control for AutoHotkey scripts


  • Please log in to reply
110 replies to this topic
soggos
  • Members
  • 129 posts
  • Last active: Nov 30 2012 10:35 AM
  • Joined: 27 Mar 2008
:) Hello World,
:arrow: cRichEdit - is very great, it's wonderfull Great Great Thank's

once I have added this REDIT to my window I seem to be having difficulty resizing it.

How can you resize or move it once added to the window without destroying and recreating the window?





:!: me too !, i have tested with :
GuiControl , Move, ahk_id %REdit1%, X50 Y50 W400 H200	
; OR
GuiControl , Move, RichEdit20A,		X50 Y50 W400 H200	
; OR
GuiControl , Move, REdit1, 			X50 Y50 W400 H200	
; OR
ControlMove , ahk_id %REdit1% , 50, 50, 400, 200,  ,

; OR>	DESTROY AND REMAKE BUT NO NO!
If (REdit1) 
	{
  cRichEdit(ahk_id %REdit1%, "Destroy")
  
If A_OSVersion = WIN_95
  cGUI("1:Add:" . REparent1, REdit1, 50, 50, 400, 200, "RICHEDIT")
Else
  cGUI("1:Add:" . REparent1, REdit1, 50, 50, 400, 200, "RichEdit20A")
}

; don't Run!
But don't run!
:?: ¿ AnyBody have a solution ?
with ahk, all is different!...

_dmitry
  • Guests
  • Last active:
  • Joined: --
Hello, soggos! It's your mistake:
ControlMove , ahk_id %REdit1% , 50, 50, 400, 200,  ,
That's right:
ControlMove,, 50, 50, 400, 200, ahk_id %REdit1%


soggos
  • Members
  • 129 posts
  • Last active: Nov 30 2012 10:35 AM
  • Joined: 27 Mar 2008
:oops: Arf...
:D it's run now correctly !great thank's mister _dmitry

with ahk, all is different!...

fatboy
  • Guests
  • Last active:
  • Joined: --
thanks for the great script.

I've just seen this article.
http://www.delphidabbler.com/tips/57
It's about setrtf code to the richedit control.
I looked at your code-it was great- I was able to find getrtf funcion, but not setrtf function, and I'm pretty sure it's out of my league to make one.

So corrupt, please consider add the function.

Thanks

Drugwash
  • Members
  • 1078 posts
  • Last active: May 24 2016 04:20 PM
  • Joined: 07 Sep 2008
Would've been better if it was C/C++ code, IMHO, but this one should do fine for whoever is into Delphi. Let's hope there will be an update - I personally am quite interested in manipulating rich text, especially the Unicode part.

Possemaster
  • Members
  • 21 posts
  • Last active: Jan 13 2014 03:59 PM
  • Joined: 18 Nov 2009
I have a Richtextfield in a AHK script, i open a rtf file into it... Works great.

But when i press GO in the GUI i want it to copy that RichText field into the clipboard with the fromatting.

And when i go to my external software with a richtext field i pres ctrl +v to paste it in.

If i use GetRTF it copies the rtf source code, and if i use GETTEXT it copies plain text.

And if i open the rtf file in wordpad and copy and paste into my external software it works OK.

How do i copy richtext into clipboard like windows.

Joy2DWorld
  • Members
  • 562 posts
  • Last active: Jun 30 2014 07:48 PM
  • Joined: 04 Dec 2006
search and find the setclipboard function [in these forums] and save the RTF to the clipboard as rtf...
Joyce Jamce

samhnky
  • Members
  • 75 posts
  • Last active: Oct 18 2010 02:14 AM
  • Joined: 29 Sep 2009
This script/function is going way over my head :oops: Can someone give me an example code.

I'm working on a script that script that creates an email. The script copies data from Remedy and pastes it along with ready made text into the email. Presently I have to use send commands to turn the bold format on and off in Outlook as I paste the various parts of the email into it. I think this script might be able to allow me to simply paste the complete text in with one paste command and the propper places in the email already be bold... (like copying text from a webpage or from another word doc, into an email) Would it be possible to get some example code on how one would use this code with regular text and variables and only bold the variables, and then combine the bold variables and plain text into the clipboard...

Thanks in advance,
Sam

rapidfox.rs
  • Members
  • 9 posts
  • Last active: Feb 05 2010 04:43 AM
  • Joined: 20 Oct 2009
really helpful release man - thanks

#include!
  • Guests
  • Last active:
  • Joined: --

Is it possible to Highlight special words?

Example:

Var = 20 Minutes
cRichEdit(REdit1, "Highlight", Var, Red)
MsgBox, Highlighted!
Sleep 10000
cRichEdit(REdit1, "HighlightRemove", Var)
MsgBox, Removed!
Sleep 5000
cRichEdit(REdit1, "Highlight", Var, Red)
Var2 = Another Highlight
cRichEdit(REdit1, "Highlight", Var2, Green)

So that its shown as:
It's [color=red]20 Minutes[/color] past 18 o'clock.
This Line is [color=green]Another Highlight[/color] in the text.


I have been wondering the same - anyone? :O

majkinetor
  • Moderators
  • 4512 posts
  • Last active: May 20 2019 07:41 AM
  • Joined: 24 May 2006
I think this module can't, but you could check RichEdit modules in Forms framework.


With FindText API you position cursor (or selection) on word you wont.

Then use SetCharFormat and its BackColor argument. When you find the word, you can select it and use WORD mode or SELECTION mode to color that word.

Then iterate to do so for each word you wont.
Also, if the scenario isn't dynamic, you can issue RTF data directly into the control. You can do that with corupts module also.

I might create sample that highlights search phrase for entire document when I find time.

You can also do that while control is scrolling so that words you supply are highlighted all the time (better to use HiEdit for that). Its not trivial programming tho.
Posted Image

#include
  • Guests
  • Last active:
  • Joined: --

I think this module can't, but you could check RichEdit modules in Forms framework.


With FindText API you position cursor (or selection) on word you wont.

Then use SetCharFormat and its BackColor argument. When you find the word, you can select it and use WORD mode or SELECTION mode to color that word.

Then iterate to do so for each word you wont.
Also, if the scenario isn't dynamic, you can issue RTF data directly into the control. You can do that with corupts module also.

I might create sample that highlights search phrase for entire document when I find time.

You can also do that while control is scrolling so that words you supply are highlighted all the time (better to use HiEdit for that). Its not trivial programming tho.


Can't that highlighting be automatic for known words - just like in editors =)

dadepp
  • Members
  • 27 posts
  • Last active: Feb 28 2012 08:33 PM
  • Joined: 12 Jun 2008

Can't that highlighting be automatic for known words - just like in editors =)

Well since I ventured down that road a while ago, maybe this is what you are looking for:
Problem with COM: Adapting a VB example to AHK
This works with any RichEdit, and works without needing to select a word to highlight it. I needed this for an error-log-console, and then I tried to implement syntax highlighting, like in editors: But even if the file is small, it takes way too long, since the keywords are numerous, and you have to check every word inside the richedit if it matches.
The next problem is, what to do if you change something (type a letter, which might complete a word to be matched, or move carret with mouse).
Better leave this to compiled dlls, like HiEdit or scite.

majkinetor
  • Moderators
  • 4512 posts
  • Last active: May 20 2019 07:41 AM
  • Joined: 24 May 2006
dadepp is right.

Your request is not easy to accomplish with acceptable speed even in compiled languages.

I recall some editor authors had to abandon RichEdit because it was very hard to achieve generally usable performance.
Posted Image

Notice
  • Guests
  • Last active:
  • Joined: --
I think that you forgot something here.
I was messing with this and it was missing a character, so I changed 1 small thing, only one of the variables _tmpSize was _tmpSize + 1, so I put the other as + 1 and it retrieved all of the text.

Else If _action = GetText
  { 
    VarSetCapacity(_tmp3, 20, 0)
    If (opt1)
      _tmp2 = 1200
    Else 
      _tmp2 = 1252
    VarSetCapacity(_tmp1, 8, 0)
    NumPut(0, _tmp1, 0)
    NumPut(_tmp2, _tmp1, 4)
    _tmpSize := DllCall("user32.dll\SendMessage", "UInt", _ctrlID, "UInt", 0x45F, "UInt", &_tmp1, "UInt", "0")
    If (_tmpSize) {
      NumPut([color=red]_tmpSize[/color], _tmp3, 0, "Int")   
      NumPut(_tmp2, _tmp3, 8, "Int")    
      VarSetCapacity(_tmp4, _tmpSize + 1, 0)
      DllCall("user32.dll\SendMessage", "UInt", _ctrlID, "UInt", 0x45E, "UInt", &_tmp3, "UInt", &_tmp4)
      VarSetCapacity(_tmp4, -1)
    }
  Return _tmp4
  }

NumPut([color=red]_tmpSize + 1[/color], _tmp3, 0, "Int")    
      NumPut(_tmp2, _tmp3, 8, "Int")    
      VarSetCapacity(_tmp4, _tmpSize + 1, 0)
cRichEdit.ahk
Version 0.09 beta
April 19, 2008