Jump to content

Need way to print text right justified


 Share

Recommended Posts

qwert - I hope I didn't get you to unnecessarily install the beta - sorry, my bad - UDF's are indeed included in the latest release. It's getting the shortcut to the right help file that contains the help, that can be a small challenge. :D

But if you already installed the beta, then after making your shortcut to the beta help file, do this to ensure you are using the release version:

Start button > All Programs > AutoIt v3 > Beta > Toggle AU3 Beta

(be sure you are using the release version here, because you might have to click on it a second time to toggle it back)

Start button > All Programs > AutoIt v3 > SciTe > Switch-Definitions > 3.2.10.0 release

If DaleHolm's method won't work because you are attached to proportional fonts or whatever, here are some references:

How to read a RichEdit control

AutoItPad - examples of using rich edit controls

In the example in the help file under:

AutoIt > Function Reference > GUI Reference > GUI Control Creation > GUICtrlCreateEdit

there is a "RichEditExample()" function.

How to convert a file from .rtf to .doc

Edited by Squirrely1

Das Häschen benutzt Radar

Link to comment
Share on other sites

qwert - I hope I didn't get you to unnecessarily install the beta

No -- I'm afraid I don't move that fast on these sorts of things.

I do appreciate you following up with the information on RTF. I consider it to be worthwhile to learn about since I can probably put it to use for some other projects.

Thanks for your help.

Link to comment
Share on other sites

  • 1 month later...

I have an text entry control defined as follows:

GUICtrlCreateEdit("Test Field", 10, 10, 200, 160, $ES_WANTRETURN + $ES_MULTILINE + $ES_RIGHT)

Every thing works fine and user entries are displayed as expected. Occasionally, however, I need to print the field. Right now, I'm simply writing the field to a text file and printing that file -- but it loses its right justification and prints left justified.

Is there any feature to either 1) directly print the right justified edit field or 2) specify the justification when writing the text file? Building a blank-padded text file is the only technique I can think of, but that is difficult to do with proportional fonts. Hopefully, this has been "invented" -- but I've not been able to locate a solution.

Thanks for any assistance.

The easiest way I have found is to use padding with spaces, then open notepad and using Send commands set the Font to Courier New

and then copy & paste in your right justified text columns. I have done this with a amortization schedule. You can automate the printing

process using Notepad or let the user use File/Print or Control-P.

Here are two functions I made to simplify text alignment and column width. Using these, you can build a string with right justified columns

to copy and paste into notepad using autoit commands.

Func RSet ($Str, $Width)

Return _StringRepeat(" ", $Width - StringLen($Str)) & $Str

EndFunc

Func LSet($Str, $Width)

Return $Str & _StringRepeat(" ", $Width - StringLen($Str))

EndFunc

Here's the commands I use to select Courier New font and copy and paste your text into Notepad.

If you try to use the Send command instead of Copy & Paste, it is really slow!

Run("Notepad.exe")

WinWaitActive("Untitled - Notepad")

Send("!FO")

Send("Courier New")

Send("{TAB}{TAB}{TAB}{TAB}")

Send("{ENTER}")

_ClipBoard_SetData ($Txt2Prnt) ;Copy to Clipboard

Send("^v") ;Control V (Paste)

Hope this helps.

TopRock

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...