FireFox Posted March 28, 2013 Posted March 28, 2013 (edited) I really hope you are wrong Nop, I have listed the DLL functions like I said, and there is nothing to change the paper size.So how do "they" do it?They have included the functions you are looking for in their library, simple as that.Check if there is a newer version of the DLL.Br, FireFox. Edited March 28, 2013 by FireFox
martin Posted March 31, 2013 Author Posted March 31, 2013 I am not spending any time on AutoIt at the moment. I'll have a look to see if I can add setting the page size but if I can't do it within about an hour on Monday then it won't be done for some time. 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.
jorgev Posted September 5, 2013 Posted September 5, 2013 Hello Martin, Tx for your work on the dll. I just have a little problem with the _PrintSetFont function. Some colors like black or gray are fine. But if i try to use for instance red(FF0000) i get some kind of blue. Im using 32bit autoit on 64bit W7 Local $red = 0xFF0000 _PrintSetFont($hp,'Courier New', 12, $red,'bold') Do you have an idea what could be wrong?
Moderators Melba23 Posted September 5, 2013 Moderators Posted September 5, 2013 jorgev,At a guess the UDF uses BGR and not RGB - try it this way:Local $red = 0x0000FFDoes that fix it? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
Moderators Melba23 Posted September 5, 2013 Moderators Posted September 5, 2013 jorgev,Glad I could help. You might find this post useful. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
ShadowElf Posted November 11, 2013 Posted November 11, 2013 number of copy can be sent to the printer? #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 $newselect = _PrintSelectPrinter($hp, "AAXXCCC") ; $newselect = _PrintSelectNUMBER OF COPY ($hp, "30") ?????????????? _PrintPageOrientation($hp,1);landscape _PrintSetDocTitle($hp,"This is a test page for PDFcreator No. 01") _PrintStartPrint($hp) _PrintImage($hp,"test-0.jpg",1,1,400,400) _PrintEndPrint($hp) _PrintNewPage($hp); _printDllClose($hp) I like IT: php, mysql, codeingiter, css, jquery and AUTOIT
rodent1 Posted November 11, 2013 Posted November 11, 2013 The number of copies is passed as an optional 2nd parameter to _PrintStartPrint() So you just replace the line _PrintStartPrint($hp) with Local $NumberOfCopies = 72 ; set the number of copies you need to print _PrintStartPrint($hp, $NumberOfCopies)
vinyking Posted December 13, 2013 Posted December 13, 2013 Quick one is it possible to Print a website to PDF and saved in a predetermined folder using autoit. I know i sound kinda like sooooooo newbeeeee well I am when it comes to Aitoit. Regards,
martin Posted December 14, 2013 Author Posted December 14, 2013 (edited) You can use the _IE... udf to save the html to a file. Not the thread here to deal with that. You can use this print udf to set the default printer to a pdf printer. Then you could use james3ng's function to print the webpage ;james3mg function Func _PrintHTML($p_file);james3mg print function If FileExists($p_file) Then RunWait(@COMSPEC&' /c rundll32.exe ' & @SystemDir & '\mshtml.dll,PrintHTML "' & $p_file & '"',@TempDir,@SW_HIDE) EndFunc Also, have a look at Taietels' udf to create pdfs EDIT: Added following You can set the default printer using these function rather than use my UDF and the dll which is overkill for just doing this. expandcollapse popup;don't know where these functions came from or who wrote them Func PrinterSetAsDefault($PrinterName) Local $result, $strComputer, $colEvents,$objWMIService $CurrentPrinter = GetDefaultPrinter() If $currentPrinter = $PrinterName Then Return $result = 0 $strComputer = "." $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\cimv2") $colEvents = $objWMIService.ExecQuery _ (StringFormat('Select * From Win32_Printer')); Where DeviceID = "%s"', $PrinterName));TRUE For $objPrinter in $colEvents If $objPrinter.DeviceID = $PrinterName Then $objPrinter.SetDefaultPrinter() $result = 1 EndIf Next Return $result EndFunc Func GetDefaultPrinter() Local $result, $strComputer, $colEvents $result = '' $strComputer = "." $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\cimv2") $colEvents = $objWMIService.ExecQuery _ ("Select * From Win32_Printer Where Default = TRUE");TRUE For $objPrinter in $colEvents $result = $objPrinter.DeviceID Next Return $result EndFunc Edited December 15, 2013 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.
vinyking Posted December 18, 2013 Posted December 18, 2013 You can use the _IE... udf to save the html to a file. Not the thread here to deal with that. You can use this print udf to set the default printer to a pdf printer. Then you could use james3ng's function to print the webpage ;james3mg function Func _PrintHTML($p_file);james3mg print function If FileExists($p_file) Then RunWait(@COMSPEC&' /c rundll32.exe ' & @SystemDir & '\mshtml.dll,PrintHTML "' & $p_file & '"',@TempDir,@SW_HIDE) EndFunc Also, have a look at Taietels' udf to create pdfs EDIT: Added following You can set the default printer using these function rather than use my UDF and the dll which is overkill for just doing this. expandcollapse popup;don't know where these functions came from or who wrote them Func PrinterSetAsDefault($PrinterName) Local $result, $strComputer, $colEvents,$objWMIService $CurrentPrinter = GetDefaultPrinter() If $currentPrinter = $PrinterName Then Return $result = 0 $strComputer = "." $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\cimv2") $colEvents = $objWMIService.ExecQuery _ (StringFormat('Select * From Win32_Printer')); Where DeviceID = "%s"', $PrinterName));TRUE For $objPrinter in $colEvents If $objPrinter.DeviceID = $PrinterName Then $objPrinter.SetDefaultPrinter() $result = 1 EndIf Next Return $result EndFunc Func GetDefaultPrinter() Local $result, $strComputer, $colEvents $result = '' $strComputer = "." $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\cimv2") $colEvents = $objWMIService.ExecQuery _ ("Select * From Win32_Printer Where Default = TRUE");TRUE For $objPrinter in $colEvents $result = $objPrinter.DeviceID Next Return $result EndFunc @ Martin. Thank you for the direction. I have been away from scripting for a couple of days. I tried the codes and they it works. (here is my codes) expandcollapse popup;james3mg function Local $PrinterName = "PDFCreator" Local $p_file = "file path\Portfolio.htm" PrinterSetAsDefault($PrinterName) _PrintHTML($p_file) Func _PrintHTML($p_file);james3mg print function If FileExists($p_file) Then RunWait(@COMSPEC&' /c rundll32.exe ' & @SystemDir & '\mshtml.dll,PrintHTML "' & $p_file & '"',@TempDir,@SW_HIDE) EndFunc ;don't know where these functions came from or who wrote them ; setting the default printer Func PrinterSetAsDefault($PrinterName) Local $result, $strComputer, $colEvents,$objWMIService $CurrentPrinter = GetDefaultPrinter() If $currentPrinter = $PrinterName Then Return $result = 0 $strComputer = "." $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\cimv2") $colEvents = $objWMIService.ExecQuery _ (StringFormat('Select * From Win32_Printer')); Where DeviceID = "%s"', $PrinterName));TRUE For $objPrinter in $colEvents If $objPrinter.DeviceID = $PrinterName Then $objPrinter.SetDefaultPrinter() $result = 1 EndIf Next Return $result EndFunc Func GetDefaultPrinter() Local $result, $strComputer, $colEvents $result = '' $strComputer = "." $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\cimv2") $colEvents = $objWMIService.ExecQuery _ ("Select * From Win32_Printer Where Default = TRUE");TRUE For $objPrinter in $colEvents $result = $objPrinter.DeviceID Next Return $result EndFunc Once again thanks.
MikahS Posted September 9, 2014 Posted September 9, 2014 (edited) Hello Martin, I will say, very amazing job here. I am just starting to use this and I'm not sure if it's my sheer ignorance with this UDF or something that's missing, but I'm getting an error when trying to use this UDF: "C:\Program Files (x86)\AutoIt3\Include\printMGv2.au3" (216) : ==> Variable used without being declared.: $vDllAns = DllCall($hDll, 'int', 'SetPrinter') ^ ERROR My code is: #include <printMGv2.au3> Local $hp, $mmssgg $hp = _PrintDLLStart($mmssgg) HotKeySet("{F2}", "Print") HotKeySet("{ESC}", "Quit") While 1 WEnd Func Print() If $hp = 0 Then MsgBox(0, "", "Error from dllstart = " & $mmssgg & @CRLF) Return EndIf _PrintSetPrinter($hp) EndFunc Func Quit() _PrintDLLClose($hp) Exit EndFunc Edited September 9, 2014 by MikahS Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ
MikahS Posted September 12, 2014 Posted September 12, 2014 (edited) I had: Opt("MustDeclareVars", 1) in my original script, and that is what fixed it by taking it out. The above script works. Edited September 12, 2014 by MikahS Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ
hunte922 Posted October 19, 2014 Posted October 19, 2014 I'm using this for a receipt printer, and it cuts off prints exceeding ~2000 pixels in height. Is there any way I can remove this restriction?
Lelikkeo Posted April 19, 2015 Posted April 19, 2015 Hello! Sorry for my English!I need help!)))faced with the problem, when you use the function to print to the pdf printer?do=embed' frameborder='0' data-embedContent>.. [nofollow] can't set the sheet size is A3, A2, A1, A0 (default A4).I really need your help on registration paper format
jandings Posted July 3, 2017 Posted July 3, 2017 (edited) Just want to update from a user's side: This dll & udf is still working in 2017 using Win 10 current releases and it still seems to me the best option for complex printing tasks handled by AutoIt. NONETHELESS there are a few caveats: 1) Since Martin never had time to implement a "set page size" function, this REALLY calls for some additional work for anyone not working with A4 paper sizes! I use this DLL extensively to work with label printers and I can only tell you all the drivers I have used (TMC, Zebra, Novexx, Avery) all had problems with the paper size. It drives you nuts unless you know what to do: Don't use the function to programmatically chose the printer. It will often chose a completely wrong paper size, even if you set everything in the printer defaults (of printer and driver and everywhere). So the quite strange way to overcome this is to use the alternative function and call up the printer selection window. I then wrote a small compiled AutoIt script that is called BEFORE the printer selection function and waits for the printer dialog to open. It then fills out all the necessary values for label sizes, printer head temperature, etc. and closes the windows again. So the user only sees a few windows (printer properties) quickly popping up and closing again. I am afraid (and quite sure!) this is the only way to get Martin's dll to work with label paper sizes in modern Windows versions. For me it now works very reliably. 2) I have found that if you rename your printer, the function to programmatically set the printer sometimes doesn't work. It is a very weird behavior that I can't completely explain, but it drives you nuts if you think you have chosen the correct printer, but actually you have not. A work around here is also the way I have described in 1). 3) YOU NEED TO HAVE A STANDARD PRINTER SET. I came across a Windows Installation where one user has no standard printer set (Win10) and the DLL crashes when selecting a printer (both ways). Just define a standard printer and the crash is gone. Good luck! Jandings Edited July 10, 2017 by jandings juzis28 1
Skeletor Posted July 13, 2017 Posted July 13, 2017 Thanks for sharing this. I've tested the example and it still works. All is left is to test more. If you have this, do a test and lets see what issues we receiving. Kind RegardsSkeletor "Coffee: my defense against going postal." Microsoft Office Splash Screen | Basic Notepad Program (Beginner) | Transparent Splash Screen | Full Screen UI
x_bennY Posted October 24, 2017 Posted October 24, 2017 On 03/07/2017 at 11:47 AM, jandings said: Just want to update from a user's side: This dll & udf is still working in 2017 using Win 10 current releases and it still seems to me the best option for complex printing tasks handled by AutoIt. NONETHELESS there are a few caveats: 1) Since Martin never had time to implement a "set page size" function, this REALLY calls for some additional work for anyone not working with A4 paper sizes! I use this DLL extensively to work with label printers and I can only tell you all the drivers I have used (TMC, Zebra, Novexx, Avery) all had problems with the paper size. It drives you nuts unless you know what to do: Don't use the function to programmatically chose the printer. It will often chose a completely wrong paper size, even if you set everything in the printer defaults (of printer and driver and everywhere). So the quite strange way to overcome this is to use the alternative function and call up the printer selection window. I then wrote a small compiled AutoIt script that is called BEFORE the printer selection function and waits for the printer dialog to open. It then fills out all the necessary values for label sizes, printer head temperature, etc. and closes the windows again. So the user only sees a few windows (printer properties) quickly popping up and closing again. I am afraid (and quite sure!) this is the only way to get Martin's dll to work with label paper sizes in modern Windows versions. For me it now works very reliably. 2) I have found that if you rename your printer, the function to programmatically set the printer sometimes doesn't work. It is a very weird behavior that I can't completely explain, but it drives you nuts if you think you have chosen the correct printer, but actually you have not. A work around here is also the way I have described in 1). 3) YOU NEED TO HAVE A STANDARD PRINTER SET. I came across a Windows Installation where one user has no standard printer set (Win10) and the DLL crashes when selecting a printer (both ways). Just define a standard printer and the crash is gone. Good luck! Jandings Could you post your script? I'm on a project and i'm having this same problem!
juzis28 Posted November 8, 2017 Posted November 8, 2017 (edited) +1, i also need to overcome page size. Whatever printing defaults i set on printer properties, printing with printMG.dll always uses A4 size. Using auto-select printer: _PrintSelectPrinter($hp, $printer) No way to get it working properly. If i change _PrintSelectPrinter to $newselect = _PrintSetPrinter($hp) .. and from there manually changing page size in printer properties - everything works, then pagesize is correct. Edited November 11, 2017 by juzis28
CocCoc Posted December 18, 2017 Posted December 18, 2017 This is the best option UDF for me, when i have a complex printing tasks. Unfortunately, the UDF does not support Unicode Encoding. All text is converted to ANSI before printing. Hope to see an update of dll and this UDF, supporting multi-encoding in the future. Thanks!
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now