AutoHotkey Community

It is currently May 27th, 2012, 4:11 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 9 posts ] 
Author Message
PostPosted: January 27th, 2006, 8:38 pm 
I dont understand how programs print things. Ive written a long form-filling GUI script. I now want to print the text input with boxes/tables. The GUI does will not have these boxes, so i cant take a screenshot or anything like that. How do I go about doing this?

Actually im re-creating a program at work originally written in DOS with FoxPro. This program prints "boxes" but i cant find out how its done...theres no .rtf file or anything in the directory, I was just looking to see how its done with that, but i dont know.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 28th, 2006, 2:55 am 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
Gohslty

Can you explain with more details?

Edit:
Post your Code .. I think I can help. I know how Foxpro handles printing!

PS: I would like to send you a Personal Message, Register to this forum if you can

_________________
URLGet - Internet Explorer based Downloader
StartEx - Portable Shortcut Link


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 30th, 2006, 7:53 pm 
Offline

Joined: January 30th, 2006, 6:53 pm
Posts: 8
Thanks...im registered...@goyyah..i also PM'ed you this...but i thought i should have posted it too...

Here is a basic example of what kind of Gui I have...though my script is actually really long (probably longer than it has to be) but i have everything worked out except for printing it (most important).
Code:
ui, Add, Text, x16 y27 w110 h20,FIRST NAME
   Gui, Add, Edit, x146 y27 w230 h20 vfirstname,
   Gui, Add, Text, x16 y57 w110 h20,MIDDLE NAME
   Gui, Add, Text, x16 y87 w110 h20,LAST NAME
   Gui, Add, Text, x16 y117 w110 h20,STREET ADDRESS
   Gui, Add, Text, x16 y147 w110 h20,CITY
   Gui, Add, Text, x16 y177 w110 h20,STATE
   Gui, Add, Text, x16 y207 w110 h20,ZIP
   Gui, Add, Edit, x146 y57 w230 h20 vmiddlename,
   Gui, Add, Edit, x146 y87 w230 h20 vlastname,
   Gui, Add, Edit, x146 y117 w230 h20 vstreet,
   Gui, Add, Edit, x146 y147 w230 h20 vcity,
   Gui, Add, Edit, x146 y177 w230 h20  vstate,
   Gui, Add, Edit, x146 y207 w230 h20 vzip,
   Gui, Add, Button, x226 y277 w240 h40,PRINT
   Gui, Show, x334 y110 h377 w477, Generated using SmartGUI
   Return

BUTTONPrint:
   ; ????

   return

I want the print button to print the text from the edit fields into a form. But I dont want to print the form first...then print the text on top. I really want to have the form incorporated somehow into my script so Ill end of printing on a blank paper. Here is what my form will look like. This is the way Foxpro prints somehow. Image

If you cant see the image..here is the URL

How can I have my script Print something like this...the way FoxPro does in DOS? Thanks again for your help...appreciate it....


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 30th, 2006, 8:20 pm 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
    Printing an ASCII formatted text file in Windows

    An ASCII formatted text file is nothing but a text file in which various ASCII characters are used for formatting purposes. They can also contain Printer codes (for DOTMATRIX Printers), that control the final output.

    Quote:
    From: http://office.microsoft.com/en-ca/assis ... 61033.aspx

    To insert an ASCII character from the chart below, press and hold down ALT while typing the decimal numeric equivalent. For example, to insert the degree symbol, press and hold down ALT while typing 0176 on the numeric keypad.

    Note: You must use the numeric keypad to type the numbers and not the keyboard. Make sure that the NUM LOCK key is on if your keyboard requires it to type numbers on the numeric keypad.


    An ASCII Table (http://nuwen.net/image/ascii.png, 596x394, 9kb)

    http://nuwen.net/image/ascii.png

    Quote:
    From: http://office.microsoft.com/en-ca/assis ... 61033.aspx

    ASCII non-printing control characters: Numbers 0–31 on the ASCII table are assigned for control characters that are used to control some peripheral devices such as printers. For example, 12 represents the form feed/new page function. This command instructs a printer to skip to the top of the next page.

    Numbers 32–126 are assigned to characters that you would find on your keyboard and appear when you view or print a document. Number 127 represents the DELETE command.

    Extended ASCII characters meet the demand for more characters. Extended ASCII includes the 128 characters found in ASCII (numbers 0–32 appear in a following chart), and adds an additional 128 characters for 256 total. Even with these additional characters, many languages contain symbols that could not be condensed into 256 characters. Because of this, there are variants of ASCII to encompass regional characters and symbols.

    Beyond ASCII
    Another, newer table of characters is called Unicode (Unicode: A character encoding standard developed by the Unicode Consortium. By using more than one byte to represent each character, Unicode enables almost all of the written languages in the world to be represented by using a single character set.). Because Unicode is a much larger table, it can represent 65,536 characters instead of the 128 of ASCII or 256 of extended ASCII. This larger capacity allows most characters of different languages to be included in one character set.

    Quote:

    • Creating a text file in AHK is easy with FileAppend command.
    • Any ASCII character can be inserted by using AHK function Chr().
    • Extentended ASCII characters CHR(128) through CHR(255) will be shown/printed in DOS and DOS based text editors but not in Windows, because it based on unicode.
    • One needs a * Special Monospaced Font * that supports extended ASCII characters, so the ASCII text can be Displayed/Printed properly
    • ASCII.ttf will show/print the ASCII characters as desired
    • Drop the ASCII.ttf in your windows fonts folder, select ASCII as the default font for your editor (like Notepad / Metapad) and the job is done.

      > > Download ASCII.ZIP [21.3kb] containing ASCII.TTF (c) Eistee 2001
    Quote:
    The license is included in the zip but it is in German. So before downloading one may want to read the details found at the website. I have not altered any contents except converting the original ascii.rar to ascii.zip format. I tried to contact the author through Eistee19@gmx.net but my mails are rebounding. The original site looks sick and may go down and so I have uploaded it in autohotkey.net

    The original content is @ http://www.apollosoft.de/ASCII/indexen.htm where Eistee wrote:
    Now I wish you all much fun with this Font and please make it public

    Finally I want to refer to that I see this Font as my property so please don't steal it sure u can give it away for free or host it on your site unchanged of course the same applies for the NFO´s which always should be given out with the Font together. It is strictly forbidden to use this Font without my agreement in commercial products that means if somebody wants to use this Font in his Product u have to contact me first.


    Printing a Text File from AHK:
    Code:
    Run, Notepad.exe /P filename.txt

    My next post contains an working example of creating text file with extended characters. (with boxes that gohstly wanted me to explain)
    Regards, :)

_________________
URLGet - Internet Explorer based Downloader
StartEx - Portable Shortcut Link


Last edited by SKAN on March 27th, 2006, 11:11 am, edited 34 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 31st, 2006, 7:34 am 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
    Creating an ASCII formatted Text File from AHK

    ScreenShot of an ASCII text (sudoku.gif, 300x300, 5kb)
    Image
    An ASCII text created from AHK

    Method 1: sudoku.txt (shown in the screenshot) was created by sample1.ahk . I have purposefully coded it in such a way that I write each an every character individually. It can easily be simplified to a few lines of code. The main highlight is that sample1.ahk can be read on editors not installed with with ASCII font. Do not be discouraged by seeing this code. See: Method 2

    Method 2: The Foxpro method of creating ASCII file. sample2.ahk . This will be the easier method but the Code will be less readable!. This is how I output text to a DOTMATRIX or a text file. Be sure to install the ASCII font and set it as default font for notepad/other editor prior to opening this file. Else most of the text will look like garbage

    The next post elaborates various functions that will supplement the AHK's FileAppend command

    Thanks for reading this patiently.......

_________________
URLGet - Internet Explorer based Downloader
StartEx - Portable Shortcut Link


Last edited by SKAN on February 22nd, 2006, 8:34 pm, edited 6 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 31st, 2006, 3:32 pm 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
    Functions Supplementing FileAppend

    SetWidth() : SetWidth increases a String's length by adding spaces to it and aligns it Left/Center/Right. ( Requires Space() )
    Code:
    SetWidth(Str,Width,AlignText)
    {
    If (AlignText!=0 and AlignText!=1 and AlignText!=2)
       AlignText=0
    if AlignText=0         
       {
        RetStr= % (Str)Space(Width)
        StringLeft,RetStr,RetStr,%Width%
       }
    If AlignText=1         
       {
        Spaces:=(Width-(StrLen(Str)))
        RetStr= % Space(Round(Spaces/2))(Str)Space(Spaces-(Round(Spaces/2)))
       }
    if AlignText=2         
       {
        RetStr= % Space(Width)(Str)
        StringRight,RetStr,RetStr,%Width%
       }
    Return RetStr
    }

    Quote:
    SetWidth() supplements AHK's FileAppend() in creating well formatted Text Files. Try windir.ahk, which is a demo script that lists "Windows folder contents" (in a tabular format) to windir.txt

    NumStr()
    Code:
    NumStr(Value,Width,Dec,PadB4="")
    {
    SetFormat, float, .%Dec%
    Value+=0
          Loop,
            {
              if (StrLen(Value) < Width AND PadB4!="")
                 Value = % PadB4 Value
              else
                 break
             }
    Return Value
    }

    Quote:
    Use NumStr() to format a float . You may also use NumStr() to pad leading characters (any character!) to a numeric string.

    Examples: Number=21.3263
    NumStr(Number,10,2,"_") returns "_____21.33"
    NumStr(Number,10,0,"0") returns "0000000021"
    NumStr(Number,10,2) returns "21.33"
    FileAppend, % "ItemCode" NumStr(Number,5,0,0) , Temp.txt outputs "ItemCode00021" to temp.txt

    Try the Demo DiskStat.ahk or view its output DiskStat.txt. This demo uses NumStr() and SetWidth()

    Replicate()
    Code:
    Replicate(chr,x)
    {
    Loop,%x%
    String=%String%%chr%
    return string
    }

    Quote:
    Example: This creates a horizontal ruling 80 characters wide
    FileAppend, % replicate(chr(196),80), filename.txt

    Space()
    Code:
    Space(Width)
    {
    Loop,%Width%
    Space=% Space Chr(32)
    Return Space
    }

    Quote:
    This is simpler:
    FileAppend,% "Hello" Space(3) "World",filename.txt
    rather than
    FileAppend,Hello%A_Space%%A_Space%%A_Space%World",filename.txt

    SubStr() : AHK's StringMid as a Function
    Code:
    Substr(String,SPos,Chars)
    {
    StringMid,String,String,%SPos%,%Chars%
    Return String
    }

    String Case : Convert a string to UPPER / lower / Proper (Sentence) case.
    Code:
    UPPER(String)
    {
    StringUpper,String,String
    Return String
    }

    Code:
    LOWER(String)
    {
    StringLower,String,String
    Return String
    }

    Code:
    PROPER(String)
    {
    StringLower,String,String,T
    Return String
    }

    Date Functions : These functions manipulate AHK's FormatTime ... FormatTime() would suffice all needs & other date functions are Superfluous & available with Foxpro
    Code:
    FormatTime(TimeString,Format)
    {
    FormatTime, FormattedTime , TimeString, %Format%
    return Formattedtime
    }

    Code:
    CDOW(DATETIME)
    {
    FormatTime,CDOW,DATETIME,dddd
    Return CDOW
    }

    Code:
    CMONTH(DATETIME)
    {
    FormatTime,CMONTH,DATETIME,MMMM
    Return CMONTH
    }

    Code:
    DATE(DATETIME)
    {
    FormatTime,Date,DATETIME,dd-MM-yyyy
    Return Date
    }

    Code:
    TIME(DATETIME)
    {
    FormatTime,Time,DATETIME,hh:mm:ss tt
    Return Time
    }

    Code:
    TIME24(DATETIME)
    {
    FormatTime,Time,DATETIME,HH:mm:ss
    Return Time
    }

    Code:
    DOW(DATETIME)
    {
    FormatTime,DOW,DATETIME,WDay
    Return DOW
    }



Thanks for reading this patiently.......

Edit: 2006/02/03 - Added code for function "Replicate()"
Edit: 2006/02/05 - Added code for function "Space()"
Edit: 2006/02/06 - Added code for function "SetWidth()" / Download the demo windir.ahk or view sample output windir.txt
Edit: 2006/02/12 - Added code for function "SubStr()"
Edit: 2006/02/18 - Added code for FormatTime() and other Superfluous date functions
Edit: 2006/02/19 - Added code for Upper() Lower() Proper()
Edit: 2006/02/20 - Added code for function "NumStr()" / Download the demo DiskStat.ahk or view sample output DiskStat.txt

_________________
URLGet - Internet Explorer based Downloader
StartEx - Portable Shortcut Link


Last edited by SKAN on February 20th, 2006, 4:27 pm, edited 5 times in total.

Report this post
Top
 Profile  
Reply with quote  
PostPosted: February 1st, 2006, 7:10 pm 
Offline

Joined: January 30th, 2006, 6:53 pm
Posts: 8
Goyyah, thank you so much...i spent a while creating a file and it looks like its going to work out...I cannot thank you enough for your help...i have been trying to figure out how to do this for a while....i appreciate it...thanks especially for sharing the skanc.ttf font.





Quote:
Hope this is of help to you...If it is, please change the forum topic (print w boxes?) to a more relevant one


When i tried registering the first time, i accidentally hit the under 13 yrs of age link and had to pick another name...so i dont think i can edit my forum topic to "* Printing an ASCII formatted text file in Windows * ." Or can I?

@ goyyah. I really think this will be useful to people in this community...maybe we could your post your part in the scripts or utilities section?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 2nd, 2006, 4:54 am 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
Dear Gohslty...

Quote:
Goyyah, thank you so much...

Welcome :)
Quote:
so i dont think i can edit my forum topic to "* Printing an ASCII formatted text file in Windows * ." Or can I?

Never mind, one can find this page by searching..

PM me for any further help :)

Edit: Gohslty... Thanks for changing the forum Topic :)

_________________
URLGet - Internet Explorer based Downloader
StartEx - Portable Shortcut Link


Last edited by SKAN on February 20th, 2006, 11:14 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject: old Dos tricks
PostPosted: August 5th, 2009, 10:13 pm 
SKAN wrote:
Printing a Text File from AHK:
Code:
Run, Notepad.exe /P filename.txt



A quick test from DOS showed that this would work without the Font installed:
Code:
copy sudoku.txt prn

(didn't try in AHK yet, but:
Code:
Run,CMD /c Copy Sudoku.txt PRN

should work also under XP, Vista, and Win 7)

This MAY be printer dependent, though :( as I'm not sure how many printers still support direct DOS printing.


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], Google [Bot], rbrtryn, Yahoo [Bot] and 64 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