youknowwho4eva Posted November 10, 2008 Share Posted November 10, 2008 (edited) I know, I don't believe it either. I actually created something that someone other then myself might find useful. It's a barcode creator. I created this to help me with my next project. A barcode reader. For those of you that know about barcodes, it does not calculate the check digit for you but I plan to do that next. expandcollapse popup#include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <array.au3> Global $bar[1000000] Global $checkofcheck[10000000] GUICreate("Barcode Maker",420,200) GUISetBkColor(0xffffff) $code = GUICtrlCreateInput("",110,140,140,20) $check = GUICtrlCreateInput("",295,140,15,20) GUICtrlSetState($check,@SW_DISABLE) $go = GUICtrlCreateButton("Go", 155,165,50,25) GUICtrlCreateLabel("Check Digit", 275,165) GUICtrlCreateLabel("Auto Populates", 265,180) For $b = 3 To 405 step +3 $bar[$b] = GUICtrlCreateGraphic(24 + $b,25,6,100) GUICtrlSetBkColor(-1,0xffffff) GUICtrlSetColor(-1,0xffffff) Next GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $gui_event_close Exit Case $msg = $go For $b = 3 To 405 step +3 GUICtrlSetBkColor($bar[$b],0xffffff) GUICtrlSetColor($bar[$b],0xffffff) Next $tempcode = GUICtrlRead($code) $temparray = StringSplit($tempcode,"") For $t = 1 to $temparray[0] step +2 If $t = 1 Then $oddsum = $temparray[$t] Else $oddsum = $temparray[$t] + $oddsum EndIf Next $multiplysum = $oddsum * 3 For $t = 2 to $temparray[0] step +2 If $t = 2 Then $evensum = $temparray[$t] Else $evensum = $temparray[$t] + $evensum EndIf Next $sumofsums = $multiplysum + $evensum For $m = 0 to 9 $checkofcheck[$m] = ($sumofsums + $m) / 10 If stringisint($checkofcheck[$m]) = 1 then $checkdigit = $m ExitLoop EndIf Next GUICtrlSetData($check,$checkdigit) $barcode = GUICtrlRead($code) & $checkdigit $array = StringSplit($barcode,"") guictrlsetbkcolor($bar[3],0) GUICtrlSetColor($bar[3],0) guictrlsetbkcolor($bar[9],0) GUICtrlSetColor($bar[9],0) For $n = 1 to ($array[0] / 2) If $n = 1 Then $one = 12 Else $one = 12 + (21 * ($n-1)) EndIf $two = $one + 3 $three = $one + 6 $four = $one + 9 $five = $one + 12 $six = $one + 15 $seven = $one + 18 If $array[$n] = "1" Then Call("one") If $array[$n] = "2" Then Call("two") If $array[$n] = "3" Then Call("three") If $array[$n] = "4" Then Call("four") If $array[$n] = "5" Then Call("five") If $array[$n] = "6" Then Call("six") If $array[$n] = "7" Then Call("seven") If $array[$n] = "8" Then Call("eight") If $array[$n] = "9" Then Call("nine") If $array[$n] = "0" Then Call("zero") Next $r = 12 + (21 * ($n-1)) guictrlsetbkcolor($bar[$r + 3],0) GUICtrlSetColor($bar[$r + 3],0) guictrlsetbkcolor($bar[$r + 9],0) GUICtrlSetColor($bar[$r + 9],0) For $n = ($array[0] / 2) + 1 to $array[0] $one = 27 + (21 * ($n-1)) $two = $one + 3 $three = $one + 6 $four = $one + 9 $five = $one + 12 $six = $one + 15 $seven = $one + 18 If $array[$n] = "1" Then Call("onei") If $array[$n] = "2" Then Call("twoi") If $array[$n] = "3" Then Call("threei") If $array[$n] = "4" Then Call("fouri") If $array[$n] = "5" Then Call("fivei") If $array[$n] = "6" Then Call("sixi") If $array[$n] = "7" Then Call("seveni") If $array[$n] = "8" Then Call("eighti") If $array[$n] = "9" Then Call("ninei") If $array[$n] = "0" Then Call("zeroi") Next $r = 27 + (21 * ($n-1)) guictrlsetbkcolor($bar[$r],0) GUICtrlSetColor($bar[$r],0) guictrlsetbkcolor($bar[$r + 6],0) GUICtrlSetColor($bar[$r + 6],0) EndSelect WEnd Func one() guictrlsetbkcolor($bar[$three],0) GUICtrlSetColor($bar[$three],0) guictrlsetbkcolor($bar[$four],0) GUICtrlSetColor($bar[$four],0) guictrlsetbkcolor($bar[$seven],0) GUICtrlSetColor($bar[$seven],0) EndFunc Func two() guictrlsetbkcolor($bar[$three],0) GUICtrlSetColor($bar[$three],0) guictrlsetbkcolor($bar[$six],0) GUICtrlSetColor($bar[$six],0) guictrlsetbkcolor($bar[$seven],0) GUICtrlSetColor($bar[$seven],0) EndFunc Func three() guictrlsetbkcolor($bar[$two],0) GUICtrlSetColor($bar[$two],0) guictrlsetbkcolor($bar[$three],0) GUICtrlSetColor($bar[$three],0) guictrlsetbkcolor($bar[$four],0) GUICtrlSetColor($bar[$four],0) guictrlsetbkcolor($bar[$five],0) GUICtrlSetColor($bar[$five],0) guictrlsetbkcolor($bar[$seven],0) GUICtrlSetColor($bar[$seven],0) EndFunc Func four() guictrlsetbkcolor($bar[$two],0) GUICtrlSetColor($bar[$two],0) guictrlsetbkcolor($bar[$six],0) GUICtrlSetColor($bar[$six],0) guictrlsetbkcolor($bar[$seven],0) GUICtrlSetColor($bar[$seven],0) EndFunc Func five() guictrlsetbkcolor($bar[$two],0) GUICtrlSetColor($bar[$two],0) guictrlsetbkcolor($bar[$three],0) GUICtrlSetColor($bar[$three],0) guictrlsetbkcolor($bar[$seven],0) GUICtrlSetColor($bar[$seven],0) EndFunc Func six() guictrlsetbkcolor($bar[$two],0) GUICtrlSetColor($bar[$two],0) guictrlsetbkcolor($bar[$four],0) GUICtrlSetColor($bar[$four],0) guictrlsetbkcolor($bar[$five],0) GUICtrlSetColor($bar[$five],0) guictrlsetbkcolor($bar[$six],0) GUICtrlSetColor($bar[$six],0) guictrlsetbkcolor($bar[$seven],0) GUICtrlSetColor($bar[$seven],0) EndFunc Func seven() guictrlsetbkcolor($bar[$two],0) GUICtrlSetColor($bar[$two],0) guictrlsetbkcolor($bar[$three],0) GUICtrlSetColor($bar[$three],0) guictrlsetbkcolor($bar[$four],0) GUICtrlSetColor($bar[$four],0) guictrlsetbkcolor($bar[$six],0) GUICtrlSetColor($bar[$six],0) guictrlsetbkcolor($bar[$seven],0) GUICtrlSetColor($bar[$seven],0) EndFunc Func eight() guictrlsetbkcolor($bar[$two],0) GUICtrlSetColor($bar[$two],0) guictrlsetbkcolor($bar[$three],0) GUICtrlSetColor($bar[$three],0) guictrlsetbkcolor($bar[$five],0) GUICtrlSetColor($bar[$five],0) guictrlsetbkcolor($bar[$six],0) GUICtrlSetColor($bar[$six],0) guictrlsetbkcolor($bar[$seven],0) GUICtrlSetColor($bar[$seven],0) EndFunc Func nine() guictrlsetbkcolor($bar[$four],0) GUICtrlSetColor($bar[$four],0) guictrlsetbkcolor($bar[$six],0) GUICtrlSetColor($bar[$six],0) guictrlsetbkcolor($bar[$seven],0) GUICtrlSetColor($bar[$seven],0) EndFunc Func zero() guictrlsetbkcolor($bar[$four],0) GUICtrlSetColor($bar[$four],0) guictrlsetbkcolor($bar[$five],0) GUICtrlSetColor($bar[$five],0) guictrlsetbkcolor($bar[$seven],0) GUICtrlSetColor($bar[$seven],0) EndFunc Func onei() guictrlsetbkcolor($bar[$one],0) GUICtrlSetColor($bar[$one],0) guictrlsetbkcolor($bar[$two],0) GUICtrlSetColor($bar[$two],0) guictrlsetbkcolor($bar[$five],0) GUICtrlSetColor($bar[$five],0) guictrlsetbkcolor($bar[$six],0) GUICtrlSetColor($bar[$six],0) EndFunc Func twoi() guictrlsetbkcolor($bar[$one],0) GUICtrlSetColor($bar[$one],0) guictrlsetbkcolor($bar[$two],0) GUICtrlSetColor($bar[$two],0) guictrlsetbkcolor($bar[$four],0) GUICtrlSetColor($bar[$four],0) guictrlsetbkcolor($bar[$five],0) GUICtrlSetColor($bar[$five],0) EndFunc Func threei() guictrlsetbkcolor($bar[$one],0) GUICtrlSetColor($bar[$one],0) guictrlsetbkcolor($bar[$six],0) GUICtrlSetColor($bar[$six],0) EndFunc Func fouri() guictrlsetbkcolor($bar[$one],0) GUICtrlSetColor($bar[$one],0) guictrlsetbkcolor($bar[$three],0) GUICtrlSetColor($bar[$three],0) guictrlsetbkcolor($bar[$four],0) GUICtrlSetColor($bar[$four],0) guictrlsetbkcolor($bar[$five],0) GUICtrlSetColor($bar[$five],0) EndFunc Func fivei() guictrlsetbkcolor($bar[$one],0) GUICtrlSetColor($bar[$one],0) guictrlsetbkcolor($bar[$four],0) GUICtrlSetColor($bar[$four],0) guictrlsetbkcolor($bar[$five],0) GUICtrlSetColor($bar[$five],0) guictrlsetbkcolor($bar[$six],0) GUICtrlSetColor($bar[$six],0) EndFunc Func sixi() guictrlsetbkcolor($bar[$one],0) GUICtrlSetColor($bar[$one],0) guictrlsetbkcolor($bar[$three],0) GUICtrlSetColor($bar[$three],0) EndFunc Func seveni() guictrlsetbkcolor($bar[$one],0) GUICtrlSetColor($bar[$one],0) guictrlsetbkcolor($bar[$five],0) GUICtrlSetColor($bar[$five],0) EndFunc Func eighti() guictrlsetbkcolor($bar[$one],0) GUICtrlSetColor($bar[$one],0) guictrlsetbkcolor($bar[$four],0) GUICtrlSetColor($bar[$four],0) EndFunc Func ninei() guictrlsetbkcolor($bar[$one],0) GUICtrlSetColor($bar[$one],0) guictrlsetbkcolor($bar[$two],0) GUICtrlSetColor($bar[$two],0) guictrlsetbkcolor($bar[$three],0) GUICtrlSetColor($bar[$three],0) guictrlsetbkcolor($bar[$five],0) GUICtrlSetColor($bar[$five],0) EndFunc Func zeroi() guictrlsetbkcolor($bar[$one],0) GUICtrlSetColor($bar[$one],0) guictrlsetbkcolor($bar[$two],0) GUICtrlSetColor($bar[$two],0) guictrlsetbkcolor($bar[$three],0) GUICtrlSetColor($bar[$three],0) guictrlsetbkcolor($bar[$six],0) GUICtrlSetColor($bar[$six],0) EndFunc Edited November 11, 2008 by youknowwho4eva Giggity Link to comment Share on other sites More sharing options...
Marlo Posted November 10, 2008 Share Posted November 10, 2008 this is pretty impressive good work Click here for the best AutoIt help possible.Currently Working on: Autoit RAT Link to comment Share on other sites More sharing options...
TehWhale Posted November 10, 2008 Share Posted November 10, 2008 Really nice! Link to comment Share on other sites More sharing options...
youknowwho4eva Posted November 10, 2008 Author Share Posted November 10, 2008 Thank you much. When I'm done the scanner you'll be able to check if my barcode is right :-P. Giggity Link to comment Share on other sites More sharing options...
DexterMorgan Posted November 10, 2008 Share Posted November 10, 2008 good job code Link to comment Share on other sites More sharing options...
gseller Posted November 11, 2008 Share Posted November 11, 2008 Nice!! I don't have much use for barcodes but very nice scripting.. Link to comment Share on other sites More sharing options...
ptrex Posted November 11, 2008 Share Posted November 11, 2008 @youknowwho4evaWhich type of Barcode did you create ?Here is an EAN13 checksum calculator that might inspire you.Barcode in AU3regards,ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
youknowwho4eva Posted November 11, 2008 Author Share Posted November 11, 2008 (edited) I'm not sure exactly what you mean... But this is the site I used to make the code. http://electronics.howstuffworks.com/upc3.htm. Next I'm going to use the first page to auto calculate the check digit. All I know is this is the barcode we use here at work.Edit: I just looked at yours, It appears the difference is that the one I looked up multiply the sum of the odds by 3 Edited November 11, 2008 by youknowwho4eva Giggity Link to comment Share on other sites More sharing options...
ptrex Posted November 11, 2008 Share Posted November 11, 2008 @youknowwho4evaAs it seems you created a UPC barcode. Best is to mention this in you thread header.Because there are +20 different types of barcodes around : Barcode Typesregards,ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
youknowwho4eva Posted November 11, 2008 Author Share Posted November 11, 2008 Thanks ptrex, I added it in the description. Giggity Link to comment Share on other sites More sharing options...
TheSaint Posted November 11, 2008 Share Posted November 11, 2008 I dream of one day being able to purchase a cheap hand-held scanner, that I can use for scanning the barcodes from Books, CD's, DVD's, etc. Where all the required detail is stored on a master database somewhere, for easy retrieval. OH WELL .... I'll keep on dreaming .... 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) Link to comment Share on other sites More sharing options...
youknowwho4eva Posted November 11, 2008 Author Share Posted November 11, 2008 Added (unless your fast soon to add) new with check sum calculator. Yes I know its not as pretty as it was, but that check digit stuff is weirdest of all. @thesaint my plan is to have a scanner that you should be able to scan your code with a desktop scanner and read it as long as its a upc. Also if someone wants to, I'd like to have a print button for this that would just print the bar code. But that's way on the back burner, so if someone has some free time and is willing too, please by all means add a print function Giggity Link to comment Share on other sites More sharing options...
TheSaint Posted November 11, 2008 Share Posted November 11, 2008 @thesaint my plan is to have a scanner that you should be able to scan your code with a desktop scanner and read it as long as its a upc.Using a desktop scanner might seem alright at first glance (and at least that would be a start), but think about it.Setting up your scanner for each item - both the time & fuss element would drive you crazy if you had any sizeable collections. It would probably be less fuss to put CD's & DVD's in your drive and query FreeDB, etc. And maybe less painful to type in all the ISBN numbers for books. Etc. AND I'VE FOUND THEM PAINFUL ENOUGH!A little hand-held scanner with the right program and the all important on-line database, would make it heeps faster.I think I'll go back to dreaming again .... zzzz 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) Link to comment Share on other sites More sharing options...
youknowwho4eva Posted November 11, 2008 Author Share Posted November 11, 2008 lol yes for that application, the reason I need a desktop one is we are emailed upc's and we need to verify them. Instead of printing and scanning it would be a lot easier for us to swipe our mouse. Giggity Link to comment Share on other sites More sharing options...
serdem Posted November 12, 2008 Share Posted November 12, 2008 Good job!, thank you for sharing. For better performance I recommend you to use only one GUICtrlCreateGraphic command and modify it by multiple GUICtrlSetGraphic commands for black and white bars. Here is a sample code. It is not a real barcode, just look and feel. #include <GUIConstantsEx.au3> #include <StaticConstants.au3> $GUI = GUICreate("My Draw") $areaWidth = 350 $areaHeight = 50 $margin = 8 $height = 35 $ypos = ($areaHeight - $height) / 2 $area = GUICtrlCreateGraphic(20, 10, $areaWidth, $areaHeight) GUICtrlSetBkColor(-1, 0xFFFFFF) GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0x000000, 0x000000) $xpos = $margin While ($xpos + $margin ) < $areaWidth $black = Random(1,5,1) $white = Random(1,3,1) GUICtrlSetGraphic(-1, $GUI_GR_RECT, $xpos, $ypos, $black, $height) $xpos += $black + $white WEnd GUISetState() Do $msg = GUIGetMsg() Until $msg = $GUI_EVENT_CLOSE Link to comment Share on other sites More sharing options...
youknowwho4eva Posted November 12, 2008 Author Share Posted November 12, 2008 Thanks, I'll have to take a look at then when I get the scanner to work a lot better. Giggity 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