Jump to content
martin

printing using UDF and a dll

Recommended Posts

I have tried to improve the instructions and I have added a readme to the initial download to explain what to do. If you can try it and let me know if you think it helps, or could be improved, I would be grateful.

At the moment there is no option for a second tray although it is somewhere on my todo list. Some printers have more than 2 trays. because I needs a couple of hours of continual concentration to make this change and other changes I want to make it will have to wait till the end of the year I regret.

Where do you mean that I have used "the activate window function"? I don't know what that is.

I had typed "cryptic" at first, then changed it to "difficult to understand." The verbage itself was hard to understand, but your update is spot on. If anyone else asks how to download the file they really didn't read the first post:)

I was trying to make the focus of the print dialogue (printsetprinter function calls it) active(and have the windows focus), but mistook code I added to your printmgv2.au3 as original code. I tried using winactivate to make that window active, but it seems to pause the script until the box is closed. Occasionally the box opens in the background and flashes the start bar; it's intermittent behavior that I have not been able to discern a pattern from... it also happens on both au3 and exe versions.

Share this post


Link to post
Share on other sites

At the moment there is no option for a second tray although it is somewhere on my todo list. Some printers have more than 2 trays. because I needs a couple of hours of continual concentration to make this change and other changes I want to make it will have to wait till the end of the year I regret.

this is not a big deal, and even if it was there is nothing I can do:p thanks again, I'll check back later this year for updates:)

we use printers capable of up to three trays, plus a bypass tray (also a hard disk and duplex tray, but not really pertinent) so if you need someone to test multiple trays just let me know. I owe you at this point.

Share this post


Link to post
Share on other sites

Very nice, though I'd like to be have an option to be able to bypass the printer dialog and just print.

Kenny


My Contributions _StringMultiReplace PC Builders Console - Secure PDF Creator - Cisco VPN Installer MS DNS Server Backup Script - MS DHCP Backup Script IT Admin Console - Toggle Admin Mode - MyMovies-Add Discs Script - IT Help Desk and System Information Tool - Set On Lid Close Power Option - Streaming Media Server & Website "I believe that when we leave a place, part of it goes with us and part of us remains... Go anywhere, when it is quiet, and just listen.. After a while, you will hear the echoes of all our conversations, every thought and word we've exchanged.... Long after we are gone our voices will linger in these walls for as long as this place remains."

Share this post


Link to post
Share on other sites

Very nice, though I'd like to be have an option to be able to bypass the printer dialog and just print.

Kenny

You can do that already.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

I have a GUI with an edit control. How can I print the content of edit control and if have more text that can be print on one page will be printed automatically?


When the words fail... music speaks

Share this post


Link to post
Share on other sites

But ***???

It's meant to be 276 bytes with a shortcut in it!! Use the shortcut as a .. shortcut and it will download the files.

I'm fairly sure this question has been answered a few times in this thread already. Can you make sure you have read the quote from the first post

Hi martin ( I have a brother called that) :D

Thanks for sharing, I'll check it out eventually! :o

In case you haven't seen the method I use for my downloads, you may want to check it out here, it is a little less messy than your method and achieves the same aim. Why I use that method is in a discussion here, which link is also mentioned on the link texts at TheSaint's Toolbox. :)


Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Share this post


Link to post
Share on other sites

I have a GUI with an edit control. How can I print the content of edit control and if have more text that can be print on one page will be printed automatically?

This is an example Script using my GDI UDFs: http://www.autoitscript.com/forum/index.ph...st&p=621217

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Share this post


Link to post
Share on other sites

how can i make this print something without having the select printer box come up and user has to press ok?

Share this post


Link to post
Share on other sites

how can i make this print something without having the select printer box come up and user has to press ok?

It depends what you are doing that makes the printer dialog appear. You can set the printer to use with

_PrintSelectPrinter

and no dialog will be shown.

If you are using

_PrintSetPrinter

then that is why you get a dialog because that function is to let someone choose the printer.

If the printer to be used is the default then you don't need call either function.

Edited by martin

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

When using your UDF i Get an error on $vDllAns not being a Array:

G:\Autoit\AutoIt3\Include\printMGv2.au3 (437) : ==> Subscript used with non-Array variable.:

Return $vDllAns[0]

Return $vDllAns^ ERROR

I am using compiler version 3.3.0.0 Maybe there are some changes?

Running:(3.3.0.0):G:\Autoit\AutoIt3\autoit3.exe "G:\Autoit\AutoIt3\Projects\Print Test.au3"

Source is your example from the first post.

Share this post


Link to post
Share on other sites

When using your UDF i Get an error on $vDllAns not being a Array:

G:\Autoit\AutoIt3\Include\printMGv2.au3 (437) : ==> Subscript used with non-Array variable.:

Return $vDllAns[0]

Return $vDllAns^ ERROR

I am using compiler version 3.3.0.0 Maybe there are some changes?

Running:(3.3.0.0):G:\Autoit\AutoIt3\autoit3.exe "G:\Autoit\AutoIt3\Projects\Print Test.au3"

Source is your example from the first post.

I tested by downloading the udf and running the example and it worked fine.

Have you got the printMG.dll in your script folder?


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

Oh, damn. How a stupid mistake can one make :D

The DLL was in the include directory, so that was the problem..

So sorry for this...

Thanks for the fast reply :o

Share this post


Link to post
Share on other sites

is there any way to save the print to a file ? or maybe log the subsequent commands into an ini ? something like a protocoll. just for reproducting purposes.

thx for your efforts on this.

j.

Edited by jennico

Spoiler

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP: 213.251.145.96

 

Share this post


Link to post
Share on other sites

is there any way to save the print to a file ? or maybe log the subsequent commands into an ini ? something like a protocoll. just for reproducting purposes.

thx for your efforts on this.

j.

I think I would need to create a new function in my dll. Something like PrintToFile(RectAReaToPrint,FileToWriteTo).

If you haven't already started using my udf then it might be worth looking at GRS's printing functions and Prog@ndy's udf because with those you get acces to the printer DC and so you can use GDIPlus functions to copy and save to file.

If you still would like a function added I can do it but it won't be for maybe a week.

EDIT:

I'm not clear what you mean by "log the subsequent commands into an ini". All the options chosen to do with the udf functions could be saved using code in your AutoIt script in such a way that it could be repeated, but that is independant of my udf.

Edited by martin

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

what would i use to determine if a print job was printed successfully? like if print success then ok() else fail() endif

also can you example or explain setting up page width and margins, im kind of having a difficult time on those.

thanks

cheers

seesoe

Share this post


Link to post
Share on other sites

what would i use to determine if a print job was printed successfully? like if print success then ok() else fail() endif

also can you example or explain setting up page width and margins, im kind of having a difficult time on those.

thanks

cheers

seesoe

The margins can be a bit confusing but it isn't really complicated when you understand.

The printer has a printable area which is Printwidth X PrintHeight. These values can be obtained from the functions _PrintGetPageWidth and _PrintGetPageHeight.

When you print or draw the coordinates you give are in tenths of a millimetre relative to the top left of the printable area. So if you draw a line from 0,0 to PageWidth,PageHeight it will be across the full printable area, but on the page that comes out of the printer it will be from

Xoffset,Yoffset

to

Xoffset + PageWidth,Yoffset + PageHeight

Usually the printable area is not in the middle of the sheet.

If you want a different margin on your finished page then you have to adjust where you print. If you want a 20mm margin down the left side, then you must start your output at Max(Xoffset, 200 - Xoffset) because all dimensions and coordinates are in tenths of a millimetre.

If you work in inches then I advise that you don't try to convert everything to inches; instead convert your dimensions to mm.

#include 'printMGv2.au3'
 Global $hp
 Local $mmssgg,$marginx,$marginy
 $hp = _PrintDllStart($mmssgg);this must always be called first
 if $hp = 0 then
     consolewrite("Error from dllstart = " & $mmssgg & @CRLF)
     Exit
 endif
 MsgBox(0,'version of dll',_PrintVersion($hp,1))
 MsgBox(0,'result from set printer = ',_PrintGetPrinter($hp));choose the printer if you don't want the default printer
 $newselect = _PrintSetPrinter($hp)
 MsgBox(0,'result from set printer = ',_PrintGetPrinter($hp));check we have set the printer we chose
 _PrintPageOrientation($hp,1);portrait
 _PrintSetDocTitle($hp,"This is a test page for seesoe")
 _PrintStartPrint($hp)
 $pght = _PrintGetpageheight($hp)
 $pgx = _PrintGetYOffset($hp)
 $pgwd = _PrintGetpageWidth($hp)
 $pgy = _PrintGetXOffset($hp)
 ConsoleWrite("width = " & _PrintGetpageWidth($hp) & ', Height = ' &  _PrintGetpageheight($hp) & @CRLF)
 _PrintSetLineCol($hp,0xff00FF)
 $linewid = 5;0.5 mm
 $linewidhalf = $linewid/2
 _PrintSetLIneWid($hp,$linewid)
 _PrintLine($hp,$linewidhalf,0,$linewidhalf,$pght)
 _PrintLine($hp,0,$pght - $linewidhalf,$pgwd,$pght - $linewidhalf)
 _PrintSetLineCol($hp,0x00FFFF)
 _PrintLine($hp,$pgwd - $linewidhalf,0, $pgwd - $linewidhalf,$pght)
 _PrintLine($hp,0, $linewidhalf, $pgwd,$linewidhalf)
 $Text = "top left"
 _PrintSetFont($hp,"Arial",24,0,"underline")
 _PrintGetTextHeight($hp,$Text)
 _PrintText($hp,$Text,$linewidhalf,$linewidhalf)
 
 $Text = "bottom right"
 _PrintSetFont($hp,"Times New Roman",12,0,"bold")
 $tht = _PrintGetTextHeight($hp,$Text)
 $twd = _PrintGetTextWidth($hp,$Text)
 _PrintText($hp,$Text,$pgwd - $linewid - $twd,$pght - $linewid - $tht)
 _PrintEndPrint($hp)
 _printDllClose($hp)

There is no easy way to check that the printing was successfull. The best might be to set the printer using _PrintSelectPrinter and check the return which is -1 if it failed. You can also use _PrintGetPrinter to see if the current printer is set to what you think it should be.

Edited by martin

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

hi martin,

if you could make a printtofile function, that would be nice. though i admit it might be complicated (needs to be .rtf format, i guess ?). but i definitely think this should be featured.

my idea with the protocoll was just loudly thinking how this could be managed by normal means, if you do not make a printtofile command. but this is not what i meant primarily.

another question: how can i set a color to the text ? i can colorate a line, but not the text ?

thanx j.


Spoiler

I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.OixB7.jpgDon't forget this IP: 213.251.145.96

 

Share this post


Link to post
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

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...