Jump to content

QR Code


rossati
 Share

Recommended Posts

Hello

This is a sample for create a QR Code using the library Quricol - QR code generator library of Serhiy Perevoznyk.

First we must download a package from http://users.telenet.be/ws36637/download/quricol.zip , this file contains sources and documentation for use on Pascal-Delphi system.

We need only quricol32.dll (in \quricol\Binaries directory) which must be copied in an accessible directory.

I have inferred use and parameters by examining the file \Quricol.Barcode\NativeMethods.cs.

The script can create a QR Code in BMP and PNG format or on the screen.

I apologize, but I am not be able to insert the QR code in clipboard.

In the compressed file there is:

- quricol32.dll

- ProvaQR.au3 the script test

- formhandler.au3

- functions.au3

These last two scripts are needed for the test, in particular formhandler.au3 is a new version of a form generator, not yet inserted in the repository because is yet in test.

Best regards

John Rossati

AutoitQRCode.zip

Link to comment
Share on other sites

  • 4 months later...
  • Moderators

TripleBook,

I just tested and they both download fine for me. Anyway it looks as if you only need the final zip. :)

M23

P.S. Welcome to the AutoIt forum, by the way. :)

Edited by Melba23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

@all

Modified the version so it goes to Clipboard and file as well.

( Credits go to UEZ )

; =======================================================================================
; Title .........: QR Generator
; Description ...: Generate QR code in some formats
; Requirement(s).: Autoit 3.3.6.1
; Author(s) .....: Giovanni Rossati (El Condor)
; Version........: 0.1.1
; Date...........: 5 jui 2012
; =======================================================================================
#include <Constants.au3>
#Include <Array.au3>
#include <WindowsConstants.au3>
#include "formhandler.au3"
#include "functions.au3"
#include <GUIConstantsEx.au3>
#include <GDIPlus.au3>
#include <Clipboard.au3>
#include <Date.au3>

;Global $hWnd
$hWnd = GUICreate("QR Code generator", 400, 300, 250, 200)
$flMenu = GUICtrlCreateMenu("&File")
$fineItem = GUICtrlCreateMenuItem("End", $flMenu)
$helpMenu = GUICtrlCreateMenu("?")
$infoItem = GUICtrlCreateMenuItem("&Info", $helpMenu)
$records = "Prodotto,,20,CMTM,GIACCHE UOMO,GIACCHE UOMO|GIACCHE DONNA;" _
& "Magazzino,,15,CMTM,CUMIANA,CUMIANA|BAIA MARE;" _
& "Peso,,5,NM,2;" _
& "Data,Data reg.,10,TM," & _DateTimeFormat(_NowCalc(), 2) & ";" _
& "OutputType,Tipo di output,30,R,XML,XML|JSON;"
GUISetState()

$aReturn = formHandler("QR Data",$records,$hWnd)

createQR($aReturn)
While 1
$msg = GUIGetMsg()
Switch $msg
Case $infoItem
    MsgBox(0, "Credits", "Condor Informatique - Turin" _
     & @CRLF & "Generatore codice QR" _
     & @CRLF & "Version 0.1.1 7 juin 2012" _
     & @CRLF & "Program developped with AutoIt3")
Case $GUI_EVENT_CLOSE,$fineItem
    MsgBox(0,"QR Code generator","See you later alligator",2)
    ExitLoop
EndSwitch
WEnd



Func createQR($a)
$templXML = '<?xml version="1.0" encoding="UTF-8"?><Sermig Application="MASO">' _
    & '<Scatola Prodotto="&Prodotto" Magazzino="&Magazzino" Peso="&Peso" Data="&Data" />' _
    & '</Sermig>'
$templJSON = '{"Sermig": { "Application" : "MASO",' _
    & '"Prodotto": "&Prodotto","Magazzino": "&Magazzino","Peso": &Peso,"Data"} }'
$tmpl = $templXML
if TakeData($a,"OutputType") = "JSON" Then $tmpl = $templJSON
For $i = 0 To UBound($a)-1
$tmpl = StringReplace($tmpl,"&" & $a[$i][0], $a[$i][1])
Next
DllCall("quricol32.dll","none", "GenerateBMP","str", @ScriptDir & "\GDIPlus_Image.bmp", "str", $tmpl,"int",4,"int",2)
DllCall("quricol32.dll","none", "GeneratePNG","str", @ScriptDir & "\GDIPlus_Image.png", "str", $tmpl,"int",4,"int",2)
_GDIPlus_Startup()
$return = DllCall("quricol32.dll","HANDLE", "GetHBitmap", "str", $tmpl,"int",4,"int",2)
$hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($return[0])
$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hWnd)
_GDIPlus_GraphicsDrawImage($hGraphic,$hBitmap, 100, 100)

_GDIPlus_ImageSaveToFile($hGraphic, @ScriptDir & "\GDIPlus_Image.bmp") ; Save bitmap to file


If Not _ClipBoard_Open($hWnd) Then _WinAPI_ShowError("_ClipBoard_Open failed")

If Not _ClipBoard_Empty() Then _WinAPI_ShowError("_ClipBoard_Empty failed")

$hBitmap2 = _WinAPI_CopyImage(_GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap), 0, 0, 0, $LR_COPYDELETEORG + $LR_COPYRETURNORG)
$iResult = _ClipBoard_SetDataEx($hBitmap2, $CF_BITMAP )

ConsoleWrite("$hBitmap2: " & $hBitmap2 & @CRLF & "$iresult: " & $iResult & @CRLF)

ConsoleWrite( @CRLF)

ShowData($hWnd)

_ClipBoard_Close()

;_ClipBoard_SetDataEx($return[0],$CF_BITMAP) it seems not working
; Clean up resources
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_BitmapDispose($hBitmap)
;_GDIPlus_ImageDispose($hImage)
_WinAPI_DeleteObject($return[0])
_GDIPlus_Shutdown() ; Shut down GDI+ library
Return
EndFunc


Func _WinAPI_CopyImage($hImage, $iType = 0, $xDesired = 0, $yDesired = 0, $iFlags = 0); from _WinAPIEx by Yashied
Local $Ret = DllCall('user32.dll', 'ptr', 'CopyImage', 'ptr', $hImage, 'int', $iType, 'int', $xDesired, 'int', $yDesired, 'int', $iFlags)
If (@error) Or (Not $Ret[0]) Then Return SetError(1, 0, 0)
Return $Ret[0]
EndFunc ;==>_WinAPI_CopyImage


; Show clipboard statistics
Func ShowData($hGUI)
ConsoleWrite("GUI handle ............: " & $hGUI & @CRLF)
ConsoleWrite("Clipboard owner .......: " & _ClipBoard_GetOwner()& @CRLF)
ConsoleWrite("Clipboard open window .: " & _ClipBoard_GetOpenWindow()& @CRLF)
ConsoleWrite("Clipboard sequence ....: " & _ClipBoard_GetSequenceNumber()& @CRLF)
EndFunc ;==>ShowData

Enjoy !!

Rgds

ptrex

Link to comment
Share on other sites

  • 3 weeks later...
  • 2 months later...

This is a nice project, and good to see developer of QR library not having abandoned the project, like so many other devs have.

F.ex ErrorCorrection was added recently. Before this was hardcoded.

QR codes are very complex, so there are a number of options not apparently covered by this library.

  • Changing code page
  • Changing encoding format (Default / GS1 / Industrial)
  • Enforcing symbol size, 1..40 (21x21 .. 177x177). This is auto.
  • Mask pattern 0..7
  • Compaction for multibyte (kanji / chinese)
  • Structured Append code

Some of above can be done using the Mode Indicator bits (4) at start, but there does not seem to be a way to set them ?

For those that are technically interested there are good links at a different related project: http://qrcodenet.codeplex.com/

Yes, I do work with barcodes every day.

I am just a hobby programmer, and nothing great to publish right now.

Link to comment
Share on other sites

  • 3 weeks later...

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...