plarmuseau Posted December 1, 2009 Share Posted December 1, 2009 Ok; it took me 2 days to find this solution, although i don't like it. First trick, is i use a website to generate the barcode, since php has alot of 'free source' code generating jpg or bmp graphs... i can easlly use those code or even certain websites to generate those barcode. In this example i generate code 128 on the website barcodesinc 1° I was searching for simply drag en drop the image file to the printerbuffer since in windows one can simply drag and drop an imagefile , i couldn't find the equivalent in Autoit, although i think it should be possible especially, opening the screens is not the problem, rather finding where the screens popup and from where to where you have to move the mouse wile holding down the left key is something i didn't find here on the messageboard, or even pressing the right mousekey on the right x-y coordinates... ? In the same style where the experiments, with filecopy... tot he printer adress Or using the clipboard... that seems todo another type of copy-paste then the drag-drop copy paste function 2° the other solution is using a 'print-template' But here also i got blocked... Although using a simple html file, integrating the JPG in that html, and writing the JPG to the right location near the html-template, and you can invoke an printhtml function... But then you get those nasty borders.... 3° The only solution working for the time being, is open the graph file in mspaint, and do all the keystrokes to get rid of the borders... but this gives a nasty flickering screen..., and this is language sensitive... I could make a function of this one, passing variables, as barcode, height,width,dpi this is a piece of code for the time being 4 ° I know there exists a magnificent barcode128.au3 Code 128 Barcode Generator - Andy M 2008 (andybiochem) using the magnificent toolbox and dll of martin #include <printMGv2.au3> but this toolbox gives errors on my computers ? cite the error: instruction on 0x01c43102 directs to memory 0x01ce0d28: read write (read) on memory error. and e second error error 216 at 01C43102 So of the technical 4 possible solutions, i manage to get one operational on a not completely satisfactory manner... Any suggestions ?? Thanks runtime expandcollapse popupFunc printbarcode( $barcode,$ImageWid,$ImageHt,$dpi,$printerspool,$language) ;~ ---------------- barcode parameters to print barcodelabel ;~ $ImageWid=200 ;~ $ImageHt=75 ;~ $dpi=96 ;~ $startX=10 ;~ $startY=30 ;~ $barcode="1900456523456" ;~ $TempDir ="C:\" ;~ $langage is nl of en $TempDir=@TempDir & '\' $url="http://www.barcodesinc.com/generator/image.php?code="&$barcode&"&style=197&type=C128B&width="&$ImageWid&"&height="&$ImageHT&"&xres=1&font=3" $CaptureFile=$TempDir & "barcode.bmp" $picture= InetGet($url, $CaptureFile) ;~ $printerspool="\\Client2\EPSON TM-L90 Label" ;print to epson label printer in the network ; use mspaint to print... and set borders to 0, so you can print nice on the label run("mspaint.exe "&$capturefile& " " &$printerspool& "") WinActivate("barcode","") Sleep(300) if $language="en" then send("!fu") Sleep(300) send("!p\{TAB}{TAB}{ENTER}") sleep(300) send("!f66") ;\ choose format sleep(100) send("!l0") ; left border sleep(100) send("!r0") ; right border sleep(100) send("!t0"); upper border sleep(100) send("!b0") ; lower border sleep(100) send("!n{TAB}1") send("{ENTER}") sleep(100) send("^p") sleep(100) send("{ENTER}") sleep(100) send("{ALT+F4}") endif if $language="nl" then send("!bg") Sleep(300) send("!p\{TAB}{TAB}{ENTER}") ; choose printer sleep(300) send("!k0") ; left border sleep(100) send("!r0") ; right border sleep(100) send("!e0"); upper border sleep(100) send("!o0") ; lower border sleep(100) send("!n{TAB}1") ; fit to page send("!f") ; change format Send("{UP}") Send("{UP}") Send("{UP}") ;~ send("6") send("{ENTER}") sleep(100) send("^p") sleep(100) send("{ENTER}") sleep(100) send("{ALT+F4}") endif EndFunc Link to comment Share on other sites More sharing options...
martin Posted December 1, 2009 Share Posted December 1, 2009 ... cite the error: instruction on 0x01c43102 directs to memory 0x01ce0d28: read write (read) on memory error.and e second error error 216 at 01C43102Are these errors from printmg.dll?If so can you say when they happen?What version of the dll are you using? 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...
plarmuseau Posted December 1, 2009 Author Share Posted December 1, 2009 Are these errors from printmg.dll?If so can you say when they happen?What version of the dll are you using?Ok, sorted this out, probably found an obsolete dll... but stil, the application does not print correctly the barcode label... on the epsonprinteralthough technically speaking you merely have to copy and paste the graph to the printer... you take the effort to generate the complete graph with your 'script' and dll combination..atleast the screan is not flickering, and you don't need internet to print a barcode (like going from rome to paris through peking) Link to comment Share on other sites More sharing options...
martin Posted December 1, 2009 Share Posted December 1, 2009 but stil, the application does not print correctly the barcode label... on the epsonprinter What is incorrect? Can you give an example of what you try to print, describe what you expect and what you get?although technically speaking you merely have to copy and paste the graph to the printer... you take the effort to generate the complete graph with your 'script' and dll combination..atleast the screan is not flickering, and you don't need internet to print a barcode (like going from rome to paris through peking)??I'm not sure from your post if you are asking for help or just making statements. 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...
plarmuseau Posted December 1, 2009 Author Share Posted December 1, 2009 (edited) What is incorrect? Can you give an example of what you try to print, describe what you expect and what you get???I'm not sure from your post if you are asking for help or just making statements.Simple the label is 60mm x 25mm, so you don't wanto waste labels and white spaces. You need one label,and then a cut.If you use the barcode126.au3 you get 1 white labele, 1 label with the barcode decoded like this 1101001000010011100110110011i presume reading your script its the 'black-white flaggingand you get a third label with a non readable barcode...and you have a wrong border space setting...Has anybode once printed the barcode on a labelprinter ?If you can make the solution more robust, it interests me, off course; Edited December 1, 2009 by plarmuseau Link to comment Share on other sites More sharing options...
bogQ Posted December 1, 2009 Share Posted December 1, 2009 Has anybode once printed the barcode on a labelprinter ?If you can make the solution more robust, it interests me, off course;I did, basicly printer had its language where you predefine the font (printed had its own fonts predefined in it, normal fonts and barcode fonts), margines, row weight and count of the text in its memory file, after that you make another text file with text for printing and send it (copy) to printer port.The other solution that i tryed to use is IDAutomationCode39 , basicly set font in excel or some other program and print it, the only problem i had is that printer did not suport anything beside its language so sending other files to printer did not work TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) There are those that believe that the perfect heist lies in the preparation.Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost. Link to comment Share on other sites More sharing options...
martin Posted December 1, 2009 Share Posted December 1, 2009 Simple the label is 60mm x 25mm, so you don't wanto waste labels and white spaces. You need one label,and then a cut.If you use the barcode126.au3 you get 1 white labele, 1 label with the barcode decoded like this 1101001000010011100110110011i presume reading your script its the 'black-white flaggingand you get a third label with a non readable barcode...and you have a wrong border space setting...Has anybode once printed the barcode on a labelprinter ?If you can make the solution more robust, it interests me, off course;I don't know what barcode126.au3 is, and most of what you have said does not make sense to me. Printing on a label printer is no different to printing on any other printer; you need to find the margins, the paper width and then work out what space you have to print, then maybe scale whatever so that it will fit.Can you post some code which shows the problem you are having? Or a link to some post so taht I can understand? 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...
bogQ Posted December 1, 2009 Share Posted December 1, 2009 "I don't know what barcode126.au3 is"probably he had tupe error, Barcode Generator Code 128 B C from andybiochem TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) There are those that believe that the perfect heist lies in the preparation.Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost. Link to comment Share on other sites More sharing options...
plarmuseau Posted December 1, 2009 Author Share Posted December 1, 2009 "I don't know what barcode126.au3 is" probably he had tupe error, Barcode Generator Code 128 B C from andybiochem Indead made a typo these are all scripts i tried to make it work... trying to print with IEexplore... does the job, but has a border and wast alot of labels #include <misc.au3> #include <GDIPlus.au3> $hImage = _GDIPlus_ImageLoadFromFile($capturefile) problem soffice: large borders, fits to page $oIE=_IECreate( $capturefile ) _IEAction ( $oIE, "print" ) trying to print with a 'formatted html and the jpg embedded... problem remains;.. you can't control themargins... $printfile=$TempDir & "barcode.html" alternative doeing the same, again the same problem... RunWait(@COMSPEC & ' /c rundll32.exe ' & @SystemDir & '\mshtml.dll,PrintHTML "' & $printfile,@TempDir,@SW_HIDE) RunWait(@COMSPEC & ' /c rundll32.exe ' & @SystemDir & '\mshtml.dll,PrintHTML "' & $capturefile,@TempDir,@SW_HIDE) trying to use open office... gives the same problem again... run("soffice.exe -pt ""\\Client2\EPSON TM-L90 Label"" "&$CaptureFile) ControlCommand("Pagina-instelling", "OK", "", "Left", "") Global Const $Barcode = @TempDir & "\barcode.bmp" try to print form clipboard ? ClipPutFile("c:\barcode.png") does noet work copying the image file to networkadress ?? why dono, although windows does it... Filecopy("c:\barcode.png" , "\\Client2\EPSON TM-L90 Label\*",8) print to default printer, and wastes the margins Run("mspaint.exe /p c:\barcode.png") This is my drag and drope experiment, i can't figure out how to do it in windows i can copy a file drag and drop it on the printer shortcut and the label image file gets printed without those margins i can't figure out how to get the right mouse click having the menu of the rightmouse click gives another type of copy then the ctrl-c copy.. Run("explorer.exe c:\") WinExists("C:") Sleep(300) Send("barcode") ControlClick ( "WXP (C:)", "Folderview", 1 , "right", 1 ,100,460) MouseClick("right",100,460) $pos = MouseGetPos() MsgBox(0, "Mouse x,y:", $pos[0] & "," & $pos[1]) $pos = WinGetPos("WXP (C:)") ;get the position on your window MsgBox(0, "Mouse x,y:", $pos[0] & "," & $pos[1]) Send("{UP}{UP}{UP}{UP}{UP}") Send("{ENTER}") ;~ Run(@SystemDir & "\control.exe") ; open controlpanel ;~ WinExists("Control Panel") ;~ WinActivate("Control Panel") ;~ Sleep(300) ;~ Send("P") ; chooses printers and faxes ;~ Sleep(100) ;~ Send("{ENTER}") ; opens printers and faxes ;~ Sleep(100) ;~ Send("E") ; chooses epson printerSleep(300) ;~ Sleep(100) ;~ Send("^v") Link to comment Share on other sites More sharing options...
martin Posted December 1, 2009 Share Posted December 1, 2009 (edited) If you're using Barcode Generator Code 128 B C then it is possible that the example I gave in that thread doesn't do what you want because I made no allowance for the page width and page size. variables at the start of the PrintBarCode function might need to be changed, and th efunction should be improved to take account of the margins and pagewidth at least. Edited December 1, 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...
plarmuseau Posted December 1, 2009 Author Share Posted December 1, 2009 If you're using Barcode Generator Code 128 B C then it is possible that the example I gave in that thread doesn't do what you want because I made no allowance for the page width and page size. variables at the start of the PrintBarCode function might need to be changed, and th efunction should be improved to take account of the margins and pagewidth at least. ok changed the script... and indead i can get it on one ticket now i debugged it: if you set the barspacing to 3 you get a normal aspect barcode but you have to multiply the linewidth with 1.5 to get the lines close enough as to resemble as one line, you can see the error, otherwise the barcode is all printed with seperated lines _PrintSetLineWid($hp,$barSpacing*1.5) expandcollapse popupFunc PrintBarCode($bctext,$bcode);<-------------added by martin Local $hp, $mmssgg Local $barSpacing = 3;0.3 mm - i don't know what is normal Local $barHt = 100;10mm Local $xstart = 10, $ystart = 10;offsets to start of print $hp = _PrintDllStart($mmssgg);this must always be called first If $hp = 0 Then MsgBox(262144,"ERROR","Error from dllstart = " & $mmssgg & @CRLF) Return EndIf _PrintGetPrinter($hp);choose the printer if you don't want the default printer $newselect = _PrintSetPrinter($hp);see also _PrintSelectPrinter ;MsgBox(0, 'reseult from set printer = ', _PrintGetPrinter($hp));choose the printer if you don't want the default printer _PrintPageOrientation($hp, 1);portrait _PrintStartPrint($hp) _PrintSetLineWid($hp,$barSpacing*1.5) _PrintSetLineCol($hp, 0);set line col to black $i = 1 While $i <= StringLen($bcode) If StringMid($bcode, $i, 1) = '1' Then _PrintLine($hp, $xstart + $i * $barSpacing, $ystart, $xstart + $i * $barSpacing, $ystart + $barHt) EndIf $i += 1 WEnd ;quickest way I could think of to neaten up the ragged line ends ;~ _PrintSetLineCol($hp, 0xffffff);set line col to white ;~ _PrintLine($hp, $xstart , $ystart, $xstart + $i * $barSpacing, $ystart) ;~ _PrintLine($hp, $xstart , $ystart + $barHt, $xstart + $i * $barSpacing, $ystart + $barHt) _PrintSetFont($hp, 'Arial', 7, 0, 'bold') _PrintText($hp,$bctext,$xstart,$ystart + $barHt + _PrintGetTextHeight($hp,"{") + 5) _PrintEndPrint($hp) _PrintNewPage($hp);not really needed since only one page used _printDllClose($hp) EndFunc Link to comment Share on other sites More sharing options...
martin Posted December 1, 2009 Share Posted December 1, 2009 ok changed the script... and indead i can get it on one ticket now i debugged it: if you set the barspacing to 3 you get a normal aspect barcode but you have to multiply the linewidth with 1.5 to get the lines close enough as to resemble as one line, you can see the error, otherwise the barcode is all printed with seperated lines _PrintSetLineWid($hp,$barSpacing*1.5) expandcollapse popupFunc PrintBarCode($bctext,$bcode);<-------------added by martin Local $hp, $mmssgg Local $barSpacing = 3;0.3 mm - i don't know what is normal Local $barHt = 100;10mm Local $xstart = 10, $ystart = 10;offsets to start of print $hp = _PrintDllStart($mmssgg);this must always be called first If $hp = 0 Then MsgBox(262144,"ERROR","Error from dllstart = " & $mmssgg & @CRLF) Return EndIf _PrintGetPrinter($hp);choose the printer if you don't want the default printer $newselect = _PrintSetPrinter($hp);see also _PrintSelectPrinter ;MsgBox(0, 'reseult from set printer = ', _PrintGetPrinter($hp));choose the printer if you don't want the default printer _PrintPageOrientation($hp, 1);portrait _PrintStartPrint($hp) _PrintSetLineWid($hp,$barSpacing*1.5) _PrintSetLineCol($hp, 0);set line col to black $i = 1 While $i <= StringLen($bcode) If StringMid($bcode, $i, 1) = '1' Then _PrintLine($hp, $xstart + $i * $barSpacing, $ystart, $xstart + $i * $barSpacing, $ystart + $barHt) EndIf $i += 1 WEnd ;quickest way I could think of to neaten up the ragged line ends ;~ _PrintSetLineCol($hp, 0xffffff);set line col to white ;~ _PrintLine($hp, $xstart , $ystart, $xstart + $i * $barSpacing, $ystart) ;~ _PrintLine($hp, $xstart , $ystart + $barHt, $xstart + $i * $barSpacing, $ystart + $barHt) _PrintSetFont($hp, 'Arial', 7, 0, 'bold') _PrintText($hp,$bctext,$xstart,$ystart + $barHt + _PrintGetTextHeight($hp,"{") + 5) _PrintEndPrint($hp) _PrintNewPage($hp);not really needed since only one page used _printDllClose($hp) EndFunc I'm glad you found a solution, though I don't quite understand why the 1.5 for the line width should be needed. However the width is passed to the dll as an int so probably it is really Int(3*1.5) which is 4. In the dll the dimensions are scaled to pixels and the line width can be less than expected. For example, say your printer has 200 pixels per inch ( always less than the printer's advertisd dpi because many dots are required for one pixel). Then a width of 0.3 mm is 200 *0.3/25.4 = 2.36 pixels which will be rounded to 2, hence the problem. 1.5 * 3 rounds to 4, then 200*0.4/25.4 = 3.14 which rounds down to 3. Maybe that's part of the explanation. 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...
Bert Posted December 1, 2009 Share Posted December 1, 2009 ummm, did you simply try to use a barcode font? I did that a while back for a project. It worked fine and quite simple to do. The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
plarmuseau Posted December 2, 2009 Author Share Posted December 2, 2009 I'm glad you found a solution, though I don't quite understand why the 1.5 for the line width should be needed. However the width is passed to the dll as an int so probably it is really Int(3*1.5) which is 4. In the dll the dimensions are scaled to pixels and the line width can be less than expected. For example, say your printer has 200 pixels per inch ( always less than the printer's advertisd dpi because many dots are required for one pixel). Then a width of 0.3 mm is 200 *0.3/25.4 = 2.36 pixels which will be rounded to 2, hence the problem. 1.5 * 3 rounds to 4, then 200*0.4/25.4 = 3.14 which rounds down to 3. Maybe that's part of the explanation.i think indead its a rounding error Link to comment Share on other sites More sharing options...
plarmuseau Posted December 2, 2009 Author Share Posted December 2, 2009 ummm, did you simply try to use a barcode font? I did that a while back for a project. It worked fine and quite simple to do. Yes indead printing with a font works too... downloadig a code 39 font form IDautomation _PrintSetFont($hp, 'IDAutomationHC39M', 10, 0, '') $Title = "!1200345567890!" _PrintText($hp, $Title, 0, _PrintGetYOffset($hp)) ok i have three working solutions now, this last one is very simple and fast to implement #include 'printMGv2.au3';the print UDF 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 ;choose the printer if you don't want the default printer _PrintSetPrinter($hp);see also _PrinterSelectPrinter _PrintPageOrientation($hp, 1);set landscape printing _PrintStartPrint($hp) _PrintSetFont($hp, 'IDAutomationHC39M', 10, 0, '') $Title = "!1200345567890!" _PrintText($hp, $Title, 0, _PrintGetYOffset($hp)) _PrintEndPrint($hp) _PrintNewPage($hp);Not really needed if no more pages to be printed _printDllClose($hp) 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