20200704 2206
01 Command line 프로그램 사용 1
source = "https://ian-hamlin.github.io/qrgen/"
1/ 내려받기
2/ 실행파일 "qrgen.exe"을 원하는 곳에 두고
3/ 실행해보기 Getting Started
C:\Program Files (x86)\QRCodeGui>qrgen.exe test.csv
(note) test.csv파일은 다음과 같이 생긴 텍스트 파일이다.
아가,갈아남아아앙 |
⇒ "아가"는 출력파일 이름으로 사용되어 QR로 생성되지 않고, 생성되는 것은 "갈아남아아앙"이다.
4/ 옵션
-f --포맷
-a -- 크기(scale), PNG 양식에만 적용되며, 1~255 사이(기본값은 8)
5/ (용례, usage) 좀더 사용해보기
* 입력파일 ; 내용,★우리는민족중흥의 역사적 사명 *123 no way!
* 명령문; ~>qrgen.exe test.csv -f png -a 12
* 결과; "내용.png"파일로 실행파일과 같은 경로에 생성된다.
02 Command line 프로그램 사용 2
source = "https://fukuchi.org/works/qrencode/index.html.en"
역시 한글 QR은 실패
1/ windows 실행파일 받기 : "https://code.google.com/archive/p/qrencode-win32/downloads"
2/ cmd에서 실행하기
qrcode.exe -o test.png -s 5 -l H http://fukuchi.org/works/qrencode/index.en.html
3/ 옵션에 대한 설명
다음과 같이 치면 옵션에 대한 설명이 나온다.
qrcode.exe --help
03 Autohotkey 코드만으로 생성하기
source = "https://www.autohotkey.com/boards/viewtopic.php?f=6&t=5538"
(결론) 한글 QR은 실패
1/ Library
BARCODER.ahk
GDIP_All.ahk
main과 같은 경로에 둔다.
2/ 코드
#SingleInstance, Force
SetBatchLines, -1
START:
/*
inputbox, PixelSize,, Type in a positive integer for the size or click Cancel to Exit.`nA bigger number results in a bigger QR Code.
if (ErrorLevel=1)
ExitApp
if PixelSize is not integer
{
Msgbox, 0x10, Error, size must an integer - try again
Goto START
}
if (PixelSize<0)
{
Msgbox, 0x10, Error, size must be positive - try again
Goto START
}
inputbox, Test,, Type in a message and a corresponding QR Code image will be generated and saved in the scripts directory.`nOr click Cancel to Exit.
*/
MsgBox,waiting
Test:=clipboard
PixelSize:=12
if (ErrorLevel=1)
ExitApp
MATRIX_TO_PRINT := BARCODER_GENERATE_QR_CODE(test,3)
if (MATRIX_TO_PRINT = 1)
{
Msgbox, 0x10, Error, The input message is blank. Please input a message to succesfully generate a QR Code image.
Goto START
}
If MATRIX_TO_PRINT between 1 and 7
{
Msgbox, 0x10, Error, ERROR CODE: %MATRIX_TO_PRINT% `n`nERROR CODE TABLE:`n`n1 - Input message is blank.`n2 - The Choosen Code Mode cannot encode all the characters in the input message.`n3 - Choosen Code Mode does not correspond to one of the currently indexed code modes (Automatic, numeric, alphanumeric or byte).`n4 - The choosen forced QR Matrix version (size) cannot encode the entire input message using the choosen ECL Code_Mode. Try forcing a higher version or choosing automated version selection (parameter value 0).`n5 - The input message is exceeding the QR Code standards maximum length for the choosen ECL and Code Mode.`n6 - Choosen Error Correction Level does not correspond to one of the standard ECLs (L, M, Q and H).`n7 - Forced version does not correspond to one of the QR Code standards versions.
Goto START
}
; Start gdi+
If !pToken := Gdip_Startup()
{
MsgBox, 48, gdiplus error!, Gdiplus failed to start. Please ensure you have gdiplus on your system
ExitApp
}
pBitmap := Gdip_CreateBitmap((MATRIX_TO_PRINT.MaxIndex() + 8) * PixelSize, (MATRIX_TO_PRINT.MaxIndex() + 8) * PixelSize) ; Adding 8 pixels to the width and height here as a "quiet zone" for the image. This serves to improve the printed code readability. QR Code specs require the quiet zones to surround the whole image and to be at least 4 modules wide (4 on each side = 8 total width added to the image). Don't forget to increase this number accordingly if you plan to change the pixel size of each module.
G := Gdip_GraphicsFromImage(pBitmap)
Gdip_SetSmoothingMode(pBitmap, 3)
pBrush := Gdip_BrushCreateSolid(0xFFFFFFFF)
Gdip_FillRectangle(G, pBrush, 0, 0, (MATRIX_TO_PRINT.MaxIndex() + 8) * PixelSize, (MATRIX_TO_PRINT.MaxIndex() + 8) * PixelSize) ; Same as above.
Gdip_DeleteBrush(pBrush)
Loop % MATRIX_TO_PRINT.MaxIndex() ; Acess the Rows of the Matrix
{
CURRENT_ROW := A_Index
Loop % MATRIX_TO_PRINT[1].MaxIndex() ; Access the modules (Columns of the Rows).
{
CURRENT_COLUMN := A_Index
If (MATRIX_TO_PRINT[CURRENT_ROW, A_Index] = 1)
{
;Gdip_SetPixel(pBitmap, A_Index + 3, CURRENT_ROW + 3, 0xFF000000) ; Adding 3 to the current column and row to skip the quiet zones.
Loop %PixelSize%
{
CURRENT_REDIMENSION_ROW := A_Index
Loop %PixelSize%
{
Gdip_SetPixel(pBitmap, (CURRENT_COLUMN * PixelSize) + (3*PixelSize) - 1 + A_Index, (CURRENT_ROW * PixelSize) + (3*PixelSize) - 1 + CURRENT_REDIMENSION_ROW, 0xFF000000)
}
}
}
If (MATRIX_TO_PRINT[CURRENT_ROW, A_Index] = 0) ; White pixels need some more attention too when doing multi pixelwide images.
{
Loop %PixelSize%
{
CURRENT_REDIMENSION_ROW := A_Index
Loop %PixelSize%
{
Gdip_SetPixel(pBitmap, (CURRENT_COLUMN * PixelSize) + (3*PixelSize) - 1 + A_Index, (CURRENT_ROW * PixelSize) + (3*PixelSize) -1 + CURRENT_REDIMENSION_ROW, 0xFFFFFFFF)
}
}
}
}
}
StringReplace, FILE_NAME_TO_USE, test, `" ; We can't use all the characters that byte mode can encode in the name of the file. So we are replacing them here (if they exist).
FILE_PATH_AND_NAME := A_ScriptDir . "\" . SubStr(RegExReplace(FILE_NAME_TO_USE, "[\t\r\n\\\/\`:\`?\`*\`|\`>\`<]"), 1) ; Same as above.
If (StrLen(FILE_PATH_AND_NAME)>252)
FILE_PATH_AND_NAME:=SubStr(FILE_PATH_AND_NAME,1,252)
FILE_PATH_AND_NAME:=FILE_PATH_AND_NAME . ".png"
IfExist,%FILE_PATH_AND_NAME%
{
MsgBox,4144,Error,%FILE_PATH_AND_NAME%`nalready exists - try again
Goto START
}
Gdip_SaveBitmapToFile(pBitmap, FILE_PATH_AND_NAME)
Gdip_DisposeImage(pBitmap)
Gdip_DeleteGraphics(G)
Gdip_Shutdown(pToken)
MsgBox,4096,Success,Created QR Code in file`n%FILE_PATH_AND_NAME%
Goto START
Return
#Include %A_ScriptDir%/BARCODER.ahk
#Include %A_ScriptDir%/GDIP_All.ahk
^ESC::ExitApp
'[PA] 업무자동화 > [AH]Autohotkey' 카테고리의 다른 글
AH IE load 완료 확인 (0) | 2020.07.06 |
---|---|
AH 엑셀 QR코드 생성 (0) | 2020.07.04 |
AH #persistent의 이해 (0) | 2020.07.03 |
AH QR or Bar code read (0) | 2020.07.03 |
UV 특정그림에서 떨어진 곳 클릭 (0) | 2020.07.01 |