| View previous topic :: View next topic |
| Author |
Message |
CobraKillerGT
Joined: 01 Dec 2006 Posts: 9 Location: Bedford, VA
|
Posted: Fri Dec 01, 2006 12:37 am Post subject: Preformatted Output |
|
|
Hey,
I am automating a sales report and basically it is multilined, first I gather user input and then perform computations on it and then spit it back to the user.
Currently I had a GUI filled with text boxes and it drew the information into them when the user pushed the button, it's horribly inefficent.
I want to format the output into a preformatted text file which pops up in notepad when it's finished or ....
Place it into an excel file.
Is AHK capable of doing either of these/ _________________ A clutch? Ah, yes. I had one of those... once. |
|
| Back to top |
|
 |
PhiLho
Joined: 27 Dec 2005 Posts: 6721 Location: France (near Paris)
|
Posted: Fri Dec 01, 2006 10:25 am Post subject: |
|
|
Yes.
[EDIT] Duplicate topic with Trying to automate a sales report. Why the double post? _________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2") |
|
| Back to top |
|
 |
CobraKillerGT
Joined: 01 Dec 2006 Posts: 9 Location: Bedford, VA
|
Posted: Fri Dec 01, 2006 7:31 pm Post subject: |
|
|
Sorry the other wasnt exactly on que with this.
I actually have the entire system done now,
Only thing is I want to output it nicely... I.E.
Hourly Accum Last Yr. Difference Labhor Hours $$Per
0 0 0 0 0 0
The 0 = values, they will always be a 2 to 4 digit number.
Anyway I can format it so, they always line up and look nice? As in each row of values prints in under the area it's suppose to? _________________ A clutch? Ah, yes. I had one of those... once. |
|
| Back to top |
|
 |
JSLover
Joined: 20 Dec 2004 Posts: 542 Location: LooseChange911.com... the WTC attacks were done by the US Gov't... the official story is a lie...
|
Posted: Fri Dec 01, 2006 8:19 pm Post subject: |
|
|
| CobraKillerGT wrote: | | Anyway I can format it so, they always line up and look nice? |
...in a text file?...perhaps it's possible...but if the goal is Excel/Open Office Spreadsheet (freeware!)...then you could use CSV (comma separated values) or TSV (tab separated values)...I have no code to work with so...
NOTE...the forum will eat the real tabs...so click quote & copy the code from the textarea... | Code: | file=%A_Temp%\ahk-spreadsheet-import.tsv
;//ssprog=excel.exe
ssprog=wksss.exe
columns=
(LTrim
Hourly Accum Last Yr. Difference Labor Hours $$Per
)
;//get data into data var somehow...
data=
(LTrim
0 0 0 0 0 0 0 0
)
FileDelete, %file%
FileAppend, %columns%`n%data%, %file%
Run, %ssprog% %file% |
...once in excel...save as anything you want...even in .xlr format...(excel's format, not .tsv)... _________________
Home • Click image! • Blog |
|
| Back to top |
|
 |
CobraKillerGT
Joined: 01 Dec 2006 Posts: 9 Location: Bedford, VA
|
Posted: Sat Dec 02, 2006 9:03 am Post subject: |
|
|
| Code: | ;7 o' clock
hd_7 := hourly_7-lhourly_7
acs_7 := hourly_6+hourly_7
ad_7 := acs_7-laccum_7
Msgbox 7 o' clock
Msgbox Hourly Sales - %hourly_7%
Msgbox Accum Sales - %acs_7%
Msgbox Last Yr. Hourly Sales - %lhourly_7%
Msgbox Last Yr. Accum sales - %lhourly_7%
if (hourly_7 < lhourly_7)
Msgbox +/- Hourly Sales: -%hd_7%
else
Msgbox +/- Hourly Sales: +%hd_7%
if (acs_7 < laccum_7)
Msgbox +/- Accum Sales: -%ad_7%
else
Msgbox +/- Accum Sales: +%ad_7%
Msgbox Labor Hours - %labor_7%
Msgbox $Per Man Hours - %dollar_7%
;8 o' clock
hd_8 := hourly_8-lhourly_8
acs_8 := hourly_7+hourly_8
ad_8 := acs_8-laccum_8
Msgbox 8 o' clock
Msgbox Hourly Sales - %hourly_8%
Msgbox Accum Sales - %acs_8%
Msgbox Last Yr. Hourly Sales - %lhourly_8%
Msgbox Last Yr. Accum sales - %lhourly_8%
if (hourly_8 < lhourly_8)
Msgbox +/- Hourly Sales: -%hd_8%
else
Msgbox +/- Hourly Sales: +%hd_8%
if (acs_8 < laccum_8)
Msgbox +/- Accum Sales: -%ad_8%
else
Msgbox +/- Accum Sales: +%ad_8%
Msgbox Labor Hours - %labor_8%
Msgbox $Per Man Hours - %dollar_8%
;9 o' clock
hd_9 := hourly_9-lhourly_9
acs_9 := hourly_8+hourly_9
ad_9 := acs_9-laccum_9
Msgbox 9 o' clock
Msgbox Hourly Sales - %hourly_9%
Msgbox Accum Sales - %acs_9%
Msgbox Last Yr. Hourly Sales - %lhourly_9%
Msgbox Last Yr. Accum sales - %lhourly_9%
if (hourly_9 < lhourly_9)
Msgbox +/- Hourly Sales: -%hd_9%
else
Msgbox +/- Hourly Sales: +%hd_9%
if (acs_9 < laccum_9)
Msgbox +/- Accum Sales: -%ad_9%
else
Msgbox +/- Accum Sales: +%ad_9%
Msgbox Labor Hours - %labor_9%
Msgbox $Per Man Hours - %dollar_9%
;10p o' clock
hd_10p := hourly_10p-lhourly_10p
acs_10p := hourly_9+hourly_10p
ad_10p := acs_10p-laccum_10p
Msgbox 10p o' clock
Msgbox Hourly Sales - %hourly_10p%
Msgbox Accum Sales - %acs_10p%
Msgbox Last Yr. Hourly Sales - %lhourly_10p%
Msgbox Last Yr. Accum sales - %lhourly_10p%
if (hourly_10p < lhourly_10p)
Msgbox +/- Hourly Sales: -%hd_10p%
else
Msgbox +/- Hourly Sales: +%hd_10p%
if (acs_10p < laccum_10p)
Msgbox +/- Accum Sales: -%ad_10p%
else
Msgbox +/- Accum Sales: +%ad_10p%
Msgbox Labor Hours - %labor_10p%
Msgbox $Per Man Hours - %dollar_10p%
|
That's mostly what is happening at the end now, ignore the rest and the inefficeny of some of the code, i fixed it... but too lazy to post newer right now.
Anyway, the output consists of...
Hourly Sales, Accum Sales, Last Year Hourly, Last Year Accum, Hourly Diff, Accum Diff, Labor Hours, $Per Man Hour.
I'd want it to post it out into a text file nice and spaced, see now it crams it all together using fileappend. spacing it never worksi t just gets ugly.
I need it to automatically line up %labor_hours% under the labor hours colum for example.
Is there a way to do this? _________________ A clutch? Ah, yes. I had one of those... once. |
|
| Back to top |
|
 |
JSLover
Joined: 20 Dec 2004 Posts: 542 Location: LooseChange911.com... the WTC attacks were done by the US Gov't... the official story is a lie...
|
Posted: Sat Dec 02, 2006 9:19 am Post subject: |
|
|
| CobraKillerGT wrote: | | I'd want it to post it out into a text file nice and spaced... |
...before you said you wanted a text file...OR...put it into excel...my method gets to excel...the text file it writes might look like crap, but excel treats the tabs as different columns...then you can print with excel or whatever...is the real goal a text file all lined up?...or printed?...or excel? Once in excel you might be able to copy/paste or Save As to a format that is a lined up text file...I'm trying to avoid doing the lined up text file, cuz I imagine it being hard...expecially if you really want excel or some other goal...(paper {printed all lined up})...
| CobraKillerGT wrote: | | ...see now... |
...no I don't see, I've only had parts of code in 2 topics to go with...perhaps you could post the whole script...as a link...get an AutoHotkey.net account...if you don't have one...
| toralf wrote: | ...so many input boxes...
...
Your script might even pop up notepad with a pre-formated text file the user has only to edit and save. |
...toralf's "pre-formated text file" idea was about replacing all the InputBox's...which is still a good idea, but doesn't need the stuff lined up...like the final output...
...aha!...see...print...excel can print... _________________
Home • Click image! • Blog |
|
| Back to top |
|
 |
CobraKillerGT
Joined: 01 Dec 2006 Posts: 9 Location: Bedford, VA
|
Posted: Sun Dec 03, 2006 12:14 am Post subject: |
|
|
Yea, well... Excel seemed like a good idea except for the fact that...for that to work the program would have to launch excel with all the input preloaded.
It is going to be used by a few people who sadly couldnt locate and open a file if required.
So... yeah.
A text file would def. be best but ... excel could work. Only, I couldnt test it because I don't have excel home. _________________ A clutch? Ah, yes. I had one of those... once. |
|
| Back to top |
|
 |
ScottEdge
Joined: 14 Aug 2005 Posts: 57 Location: Connecticut,USA
|
Posted: Sun Dec 03, 2006 1:27 am Post subject: |
|
|
You could always just file append the information as an html table and then open it in explorer or firefox to print.
Its easy to make a table if you don't know how here is a site that builds tables for you. From the code they provie you should be able to make it dynamic if needed.
http://www.athropolis.com/help/tablemaker.htm
| Code: | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=windows-1250">
<meta name="generator" content="PSPad editor, www.pspad.com">
<title></title>
</head>
<body>
<TABLE ALIGN=left BORDER=2>
<tr>
<th>Column 1</th>
<th>Column 2</th>
<th>Column 3</th>
<th>Column 4</th>
</tr>
<TR>
<TD>1</TD>
<TD>2</TD>
<TD>3</TD>
<TD>4</TD>
</TR>
<TR>
<TD>2</TD>
<TD>4</TD>
<TD>6</TD>
<TD>8</TD>
</TR>
<TR>
<TD>3</TD>
<TD>6</TD>
<TD>9</TD>
<TD>12</TD>
</TR>
<TR>
<TD>4</TD>
<TD>8</TD>
<TD>12</TD>
<TD>16</TD>
</TR>
</TABLE>
</body>
</html>
|
|
|
| Back to top |
|
 |
CobraKillerGT
Joined: 01 Dec 2006 Posts: 9 Location: Bedford, VA
|
Posted: Sun Dec 03, 2006 6:16 am Post subject: |
|
|
Hmm... HTML, a good idea actually, one of the best I have heard yet. In theory, couldn't i use it to easily line up colums under text headers.
Yes I could. Only issue is ... I am not sure how exactly I'd do it dynamically, I guess just have the code append the HTML code to the text file ... hmm...
Not familiar with tables and lining things up via html though, but this is an awesome finally rational point to start from. _________________ A clutch? Ah, yes. I had one of those... once. |
|
| Back to top |
|
 |
ScottEdge
Joined: 14 Aug 2005 Posts: 57 Location: Connecticut,USA
|
Posted: Sun Dec 03, 2006 7:19 am Post subject: |
|
|
| if you give me a sample of how you are appending your data I could possibly give you an example. |
|
| Back to top |
|
 |
ScottEdge
Joined: 14 Aug 2005 Posts: 57 Location: Connecticut,USA
|
Posted: Sun Dec 03, 2006 7:42 am Post subject: |
|
|
| CobraKillerGT wrote: | I guess just have the code append the HTML code to the text file ... hmm...
Not familiar with tables and lining things up via html though, but this is an awesome finally rational point to start from. |
This is what you want to do. Tables are simple in HTML. First file append the table definition and the headers that you want in the table
| Code: |
FileAppend,
(
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=windows-1250">
<meta name="generator" content="PSPad editor, www.pspad.com">
<title></title>
</head>
<body>
<TABLE ALIGN=left BORDER=2>
<tr>
<th>Hourly</th>
<th>Accum</th>
<th>Yr.</th>
<th>Difference </th>
<th>Labor</th>
<th>Hours</th>
<th>$$Per </th>
</tr>
),C:\Test.html
|
then every line you file append start it with <tr> and end it with </tr> seperate the data into columns by using <td></td>
| Code: |
FileAppend,
(
<TR>
<TD>00</TD><TD>00</TD><TD>00</TD><TD>00</TD><TD>00</TD><TD>00</TD><TD>00</TD>
</TR>
<TR>
<TD>01</TD><TD>01</TD><TD>01</TD><TD>01</TD><TD>01</TD><TD>01</TD><TD>01</TD>
</TR>
),C:\Test.html
|
Then file append the footer information of the html and table.
| Code: |
FileAppend,
(
</TABLE>
</body>
</html>
),C:\Test.html
|
If you want the information editable you could always put input boxes in the tables and people could change the valies if needed.
| Code: |
FileAppend,
(
<TR>
<TD><input type="text" maxlength="2" size="1" value='00'></TD>
<TD><input type="text" maxlength="2" size="1" value='00'></TD>
<TD><input type="text" maxlength="2" size="1" value='00'></TD>
<TD><input type="text" maxlength="2" size="1" value='00'></TD>
<TD><input type="text" maxlength="2" size="1" value='00'></TD>
<TD><input type="text" maxlength="2" size="1" value='00'></TD>
<TD><input type="text" maxlength="2" size="1" value='00'></TD>
</TR>
),C:\Test.html
|
you will have to change the maxlength and size to fit your needs. |
|
| Back to top |
|
 |
engunneer
Joined: 30 Aug 2005 Posts: 6772 Location: Pacific Northwest, US
|
Posted: Sun Dec 03, 2006 5:49 pm Post subject: |
|
|
Also, opening your newly created excel file is easy. Something like the following untested code should work as the last thing after the FileAppends are completed
| Code: |
Run, open, %YourFilenameVariable%
|
or
| Code: |
Run, open, excel.exe %YourFilenameVariable%
|
If you just wanted to print, use
| Code: |
Run, print, %YourFilenameVariable%
|
The "Run verbs" are very powerful  _________________
Unless otherwise noted, all code is untested.
Common Answers: 1.(Loops, Viruses, etc.) 2. Search 3.RTFM |
|
| Back to top |
|
 |
JSLover
Joined: 20 Dec 2004 Posts: 542 Location: LooseChange911.com... the WTC attacks were done by the US Gov't... the official story is a lie...
|
Posted: Sun Dec 03, 2006 8:19 pm Post subject: |
|
|
| CobraKillerGT wrote: | | Yea, well... Excel seemed like a good idea except for the fact that...for that to work the program would have to launch excel with all the input preloaded. |
...dude...my example above runs the ssprog var...ssprog means spreadsheet prog(ram)...commented out is excel.exe, not commented out is wksss.exe or the Microsoft Works (not Word) Spreadsheet program...
| engunneer wrote: | | Also, opening your newly created excel file is easy. |
...yes it is easy, which I demo'd in my code no one saw...
| CobraKillerGT wrote: | | Only, I couldnt test it because I don't have excel home. |
- I don't have Excel either (well I do, it was pre-installed, but when I run it it wants a product key to unlock, so I can't use it...)
- Use Microsoft Works
- Use Open Office...like I already suggested...
...my example script above DOES what you want...you put the columns in the columns var...you get the data from the user & put it in the data var...then the script dumps that into a .tsv file & runs WHATEVER spreadsheet program you set in ssprog...once there your users can Save, Print, whatever...
What I wanted from you is a LINK to your complete current script...that writes the data to a file in the bad way you don't like...then I can apply my above script in a more real-world way...I just have no code to work with...also do you want to keep the thousand InputBox's...or use a Gui...or use toralfs text document idea (which might be different than you are thinking)...so PLEASE...get an AutoHotkey.net account & upload all versions of your script you have...so I can look it over... _________________
Home • Click image! • Blog |
|
| Back to top |
|
 |
CobraKillerGT
Joined: 01 Dec 2006 Posts: 9 Location: Bedford, VA
|
Posted: Mon Dec 04, 2006 5:25 am Post subject: |
|
|
Here is the code: http://autohotkey.net/~CobraKillerGT/SalesandLabor.ahk
Now basically... I'd like to make it as efficent as possible. The whole ... input boxes are getting on my nervers but all I knew and no question it needs to output to an excel compat. file.
If you find time please just take a look and thanks _________________ A clutch? Ah, yes. I had one of those... once. |
|
| Back to top |
|
 |
|