jennico Posted March 28, 2009 Share Posted March 28, 2009 hmm, it seems that gdi32.dll ('GetDeviceCaps','CreateFont') offers all that is needed without extra dll, doesn't it ? it enables you to print exact positions and "real" fontsizes, moreover, with a DC handle to the monitor you can display the printjob with (almost) exact ("real") dimensions on the screen. this is very very interesting. it just awaits someone to code UDFs for it (GRS has already begun to do it). but - i still don't see how to save a print to file... j. Spoiler I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.Don't forget this IP: 213.251.145.96 Link to comment Share on other sites More sharing options...
martin Posted March 29, 2009 Author Share Posted March 29, 2009 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.You set the line colour with _PrintSetLineCol.You set the font colour with _PrintSetFont which also lets you set the font, the font size and the font style. _PrintText allows you to specify the angle.I assume that if you print to file then you would save it as a bmp or jpg. Then if you want to print it later you just print that image. I don't think it would be complicated, but how would you use it or what would you use it for? 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. Link to comment Share on other sites More sharing options...
Edifice Posted April 15, 2009 Share Posted April 15, 2009 Hello Just wanna say I think this is really great, and I hope these functions will be fully integrated in auto-it (as include). Anyway, I found a small bug - When I press "Cancel" to a print, the printer still prints it? And, I would like to know if there is any kind of documentation of the calls you can make and parametres that they can be called with? Link to comment Share on other sites More sharing options...
martin Posted April 15, 2009 Author Share Posted April 15, 2009 HelloJust wanna say I think this is really great, and I hope these functions will be fully integrated in auto-it (as include).I'm glad you like it.This udf and dll will never be included in the AuoIt package. Many AutoIt printing functions have been developed which use the Windows API. At the moment this udf is possibly easier to use but hopefully that will not always be the case.Anyway, I found a small bug - When I press "Cancel" to a print, the printer still prints it?I need much more information to give a sensible reply .Where are you pressing Cancel? What function did you call which showed the Cancel button and what code have you written to allow for the Cancel button being pressed? Which versions are you using? Can you show any sample code which reproduces the problem?And, I would like to know if there is any kind of documentation of the calls you can make and parametres that they can be called with?The UDF has information for the functions, you just need to read it and then experiment with the functions and ask if you get stuck. 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. Link to comment Share on other sites More sharing options...
Prajoss Posted April 16, 2009 Share Posted April 16, 2009 (edited) Hi Martin, I'm using your UDF for printing. But I have now the following problem: I'm printing an image on a page. The size of the image is variable and depending on the size I'm setting the Page Orientation to landscape oder portrait. But I'd like to know the Page size and the X/Y-Offset of the printer. The problem is, that I can't ask for this information if the _PrintStartPrint($DLL) is not set! Because, if I set _PrintStartPrint($DLL) then I can't change the Page Orientation. Is it possible to use _PrintStartPrint($DLL) and get the information, and then abort this printing job? Because, if I simply write _PrintEndPrint($DLL) then it sends an empty print job (thats ok since it is its function). Can I abort this empty printjob in the script or "load" the printer, so I can get my information? Here is my Code for this part: ;~ _PrintStartPrint($hp) $PageHeight = _PrintGetPageHeight($hp) $PageWidth = _PrintGetPageWidth($hp) $PageXoffset = _PrintGetXOffset($hp) $PageYoffset = _PrintGetYOffset($hp) ;~ _PrintEndPrint($hp) _PrintStartPrint($hp) $PrintImageWid = $ImageWid / ($dpi/2.54) * 100 If $PrintImageWid > 1900 Then If $PrintImageWid > 2770 Then $PrintImageWid = 2770 $PrintImageHt = $ImageHt / ($dpi/2.54) * 100 If $PrintImageHt > 1700 Then $PrintImageHt = 1700 $logo_x = 2500 _PrintPageOrientation($hp,0) Else $PrintImageHt = $ImageHt / ($dpi/2.54) * 100 If $PrintImageHt > 2770 Then $PrintImageHt = 2770 $logo_x = 1650 _PrintPageOrientation($hp,1) EndIf _PrintImage($hp, $CaptureFile, 100, 300, $PrintImageWid, $PrintImageHt) _PrintEndPrint($hp) _printDllClose($hp) I'm sorry for my bad english Thanks Prajoss Edited April 16, 2009 by Prajoss Link to comment Share on other sites More sharing options...
martin Posted April 16, 2009 Author Share Posted April 16, 2009 Hi Martin, I'm using your UDF for printing. But I have now the following problem: I'm printing an image on a page. The size of the image is variable and depending on the size I'm setting the Page Orientation to landscape oder portrait. But I'd like to know the Page size and the X/Y-Offset of the printer. The problem is, that I can't ask for this information if the _PrintStartPrint($DLL) is not set! Because, if I set _PrintStartPrint($DLL) then I can't change the Page Orientation. Is it possible to use _PrintStartPrint($DLL) and get the information, and then abort this printing job? Because, if I simply write _PrintEndPrint($DLL) then it sends an empty print job (thats ok since it is its function). Can I abort this empty printjob in the script or "load" the printer, so I can get my information? Here is my Code for this part: ;~ _PrintStartPrint($hp) $PageHeight = _PrintGetPageHeight($hp) $PageWidth = _PrintGetPageWidth($hp) $PageXoffset = _PrintGetXOffset($hp) $PageYoffset = _PrintGetYOffset($hp) ;~ _PrintEndPrint($hp) _PrintStartPrint($hp) $PrintImageWid = $ImageWid / ($dpi/2.54) * 100 If $PrintImageWid > 1900 Then If $PrintImageWid > 2770 Then $PrintImageWid = 2770 $PrintImageHt = $ImageHt / ($dpi/2.54) * 100 If $PrintImageHt > 1700 Then $PrintImageHt = 1700 $logo_x = 2500 _PrintPageOrientation($hp,0) Else $PrintImageHt = $ImageHt / ($dpi/2.54) * 100 If $PrintImageHt > 2770 Then $PrintImageHt = 2770 $logo_x = 1650 _PrintPageOrientation($hp,1) EndIf _PrintImage($hp, $CaptureFile, 100, 300, $PrintImageWid, $PrintImageHt) _PrintEndPrint($hp) _printDllClose($hp) I'm sorry for my bad english Thanks Prajoss Hi Prajoss, welcome to the AutoIt forums I'm surprised I haven't included an Abort function already. Can you add this to the UDF ;aborts printing ;returns 0 on success ;returns -1 if not already printing ;returns -2 if could not execute the dll call Func _PrintAbort($hDll) $vDllAns = DllCall($hDll, 'int', 'AbortPrint'); If @error = 0 Then Return $vDllAns[0] Else Return -2 EndIf EndFunc ;==>_PrintGetPrinter And try the dll from here. I would be grateful if you could let me know the result. 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. Link to comment Share on other sites More sharing options...
Prajoss Posted April 16, 2009 Share Posted April 16, 2009 (edited) Hi Prajoss, welcome to the AutoIt forums I'm surprised I haven't included an Abort function already. Can you add this to the UDF ;aborts printing ;returns 0 on success ;returns -1 if not already printing ;returns -2 if could not execute the dll call Func _PrintAbort($hDll) $vDllAns = DllCall($hDll, 'int', 'AbortPrint'); If @error = 0 Then Return $vDllAns[0] Else Return -2 EndIf EndFunc;==>_PrintGetPrinter And try the dll from here. I would be grateful if you could let me know the result. Thx for the welcome I've tested it and it works fine! (every return is returned like it should be returned ) Thanks you helped me a lot Edit: EndFunc ;==>_PrintGetPrinter should be EndFunc ;==>_PrintAbort or? Edited April 16, 2009 by Prajoss Link to comment Share on other sites More sharing options...
martin Posted April 16, 2009 Author Share Posted April 16, 2009 Thx for the welcome I've tested it and it works fine! (every return is returned like it should be returned )Thanks you helped me a lotEdit:That's good, I'll make it part of the standard version. should be or? Not sure what that bit means but the rest read fine to me. 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. Link to comment Share on other sites More sharing options...
Prajoss Posted April 16, 2009 Share Posted April 16, 2009 I only wanted to say, that your Comment at the end of the _PrintAbort function does not fit Link to comment Share on other sites More sharing options...
martin Posted April 16, 2009 Author Share Posted April 16, 2009 I only wanted to say, that your Comment at the end of the_PrintAbort function does not fitOh I see, yes you're right. It will be correct in the real version though. 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. Link to comment Share on other sites More sharing options...
Edifice Posted April 16, 2009 Share Posted April 16, 2009 (edited) I'm glad you like it.This udf and dll will never be included in the AuoIt package. Many AutoIt printing functions have been developed which use the Windows API. At the moment this udf is possibly easier to use but hopefully that will not always be the case.I know that these specific files will not be included, I was thinking more of the basic functions within them I need much more information to give a sensible reply .Where are you pressing Cancel? What function did you call which showed the Cancel button and what code have you written to allow for the Cancel button being pressed? Which versions are you using? Can you show any sample code which reproduces the problem?Whenever the "Choose printer" dialog comes up, and you press cancel of or close the window, the printer spits out a page anyway. It seems to me that a sort of GUIregistermessage("Event_Close") or similar was used (sorry for bad code, just an example).The UDF has information for the functions, you just need to read it and then experiment with the functions and ask if you get stuck.I am kinda stuck now. Is there any way to restrict a _PrintLine to a specific width and then insert newlines down the page if it's too wide? - Or some kinda _Printtextbox or something?Edit: Sorry for bad quote - please read very carefully to understand fully Edited April 16, 2009 by Edifice Link to comment Share on other sites More sharing options...
martin Posted April 17, 2009 Author Share Posted April 17, 2009 (edited) I am kinda stuck now. Is there any way to restrict a _PrintLine to a specific width and then insert newlines down the page if it's too wide? - Or some kinda _Printtextbox or something?Edit: Sorry for bad quote - please read very carefully to understand fully I think you mean _PrintText not _PrintLine which draws a straight line.There is no _printTextBox equivalent, but the functions are there to enable you to do it.First there are the functions like _PrintGetPageWidth and _PrintGetPageHeight.Then you can use _PrintGetTextHeight to decide on the vertical line spacing, _PrintGetTexWidth to see how wide the printed text will be and _PrintText to actually print the text. By having a loop and using functions like StringMid you can print any length of text over as many lines as need in a rectangle anywhere on the page.Or, you could put the text in an edit which automatically wraps the text. Read the first line of text using the GuiEdit udf, and see how wide this will be on the printed page using _PrintGetTextWidth. Adjust the width of the edit untill the printed width is what you want and then print all the lines. The edit doesn't need to be visible. Edited April 17, 2009 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. Link to comment Share on other sites More sharing options...
martin Posted May 3, 2009 Author Share Posted May 3, 2009 New function added to print from a Bitmap without needing to use a file. _PrintImageFromDC First post updated with a new link for the download. 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. Link to comment Share on other sites More sharing options...
seesoe Posted May 28, 2009 Share Posted May 28, 2009 can you provide some examples of text wrapping please?I think you mean _PrintText not _PrintLine which draws a straight line.There is no _printTextBox equivalent, but the functions are there to enable you to do it.First there are the functions like _PrintGetPageWidth and _PrintGetPageHeight.Then you can use _PrintGetTextHeight to decide on the vertical line spacing, _PrintGetTexWidth to see how wide the printed text will be and _PrintText to actually print the text. By having a loop and using functions like StringMid you can print any length of text over as many lines as need in a rectangle anywhere on the page.Or, you could put the text in an edit which automatically wraps the text. Read the first line of text using the GuiEdit udf, and see how wide this will be on the printed page using _PrintGetTextWidth. Adjust the width of the edit untill the printed width is what you want and then print all the lines. The edit doesn't need to be visible. Link to comment Share on other sites More sharing options...
martin Posted May 28, 2009 Author Share Posted May 28, 2009 can you provide some examples of text wrapping please?Sorry but I do not have any examples. The suggestions I have already made, which you quoted, are all I have. 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. Link to comment Share on other sites More sharing options...
Edifice Posted July 15, 2009 Share Posted July 15, 2009 Sorry but I do not have any examples. The suggestions I have already made, which you quoted, are all I have.I am currently working on a function (It's just a hobby and I'm working kinda slow.)This is what I have so far:Dim $startpoint = 1Dim $lenght = 83Dim $text = "123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789"Dim $line = "123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123"Dim $var = 0Dim $result = stringcompare($text, $line, 2)Dim $result2 = 1Dim $empty = ""If $result > 0 Then while $result2 > 0 $var = StringMid($text, $startpoint, $lenght) $result2 = Stringcompare($var, $empty, 2) If $result2 > 0 Then MsgBox(0, "Chopping up text into lines", $var) EndIf $startpoint = $startpoint + 83 ;Print $var onto paper ;Move one line down WEndEndIfI would be very glad if you could incorporate it into the rest, otherwise I will just send you an example when I finish it (I'm hoping to be able to progress a bit faster during the next few weeks) Link to comment Share on other sites More sharing options...
martin Posted July 16, 2009 Author Share Posted July 16, 2009 I am currently working on a function (It's just a hobby and I'm working kinda slow.)This is what I have so far:Dim $startpoint = 1Dim $lenght = 83Dim $text = "123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789"Dim $line = "123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123"Dim $var = 0Dim $result = stringcompare($text, $line, 2)Dim $result2 = 1Dim $empty = ""If $result > 0 Then while $result2 > 0 $var = StringMid($text, $startpoint, $lenght) $result2 = Stringcompare($var, $empty, 2) If $result2 > 0 Then MsgBox(0, "Chopping up text into lines", $var) EndIf $startpoint = $startpoint + 83 ;Print $var onto paper ;Move one line down WEndEndIfI would be very glad if you could incorporate it into the rest, otherwise I will just send you an example when I finish it (I'm hoping to be able to progress a bit faster during the next few weeks)I don't see how that will help anyone wanting to wrap text so that it fits into a given width. 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. Link to comment Share on other sites More sharing options...
Yashied Posted July 16, 2009 Share Posted July 16, 2009 martin, from me for nice job. Thanks. My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
martin Posted July 16, 2009 Author Share Posted July 16, 2009 martin, from me for nice job. Thanks.Thanks Yashied. I've learnt a lot from you, so if I've done something which helps you I'm very pleased. 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. Link to comment Share on other sites More sharing options...
martin Posted July 27, 2009 Author Share Posted July 27, 2009 Added functions _PrintGetPaperWidth _PrintGEtPaperHeight for the physical paper size in the printer. (The functions _PrintGetPageWidth and _PrintGetPageHeight only return the printable dimensions.) 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. Link to comment Share on other sites More sharing options...
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