哈哈,想不到小弟的一贴子,整出这么多风波了。曲折一下,其它就可以实现此功能了。
中间还是有用到P版的一段代码.....未来得及整理了。
#NoTrayIcon
#Region ;**** 参数创建于 ACNWrapper_GUI ****
#AutoIt3Wrapper_icon=UDF\ICO.ico
#AutoIt3Wrapper_outfile=打印工具.exe
#AutoIt3Wrapper_UseUpx=n
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
#include<array.au3>
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <String.au3>
#AutoIt3Wrapper_Run_Debug_Mode=Y
#Region ---Au3Recorder generated code Start ---
Opt("WinWaitDelay", 100)
Opt("WinDetectHiddenText", 1)
Opt("MouseCoordMode", 0)
Global $var, $win, $hwd, $main, $quit, $num, $config, $gi, $close = 0, $cp, $box, $start, $leirong, $_bit, $bit, $a, $b, $c
Global $end
Global $nb = ''
Global $Paused = 0
$config = @ScriptDir & "\config.ini"
$tite = IniRead($config, "Config", "标题", "")
$var = WinList($tite)
For $i = 1 To $var[0][0]
$win &= $var[$i][0]
Next
#EndRegion ### END Koda GUI section ###
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
$main = GUICreate("打印辅助工具", 430, 210, -1, -1)
GUICtrlCreateGroup("条码打印项", 4, 4, 420, 80)
GUICtrlCreateLabel("窗口标题:", 16, 23, 60, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlCreateLabel("重复次数:", 16, 55, 60, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$num = GUICtrlCreateInput("100", 80, 52, 249, 21)
$print = GUICtrlCreateButton("打 印", 340, 38, 75, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlCreateGroup("自动增量", 4, 89, 420, 80)
GUICtrlCreateLabel("条码起始:", 16,110, 60, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$start = GUICtrlCreateInput("自动捕捉剪切板的内容", 80, 110, 249, 21)
$leirong = ClipGet()
If $leirong <> '' And StringLen($leirong) < 20 Then GUICtrlSetData($start, $leirong)
GUICtrlCreateLabel("后几位:", 220, 143, 60, 25)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$bit = GUICtrlCreateCombo("", 290, 140, 40, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "2|3|4|5|6|7|8", "4")
$ten = GUICtrlCreateRadio("十进制", 16, 140, 80, 21)
GUICtrlSetState(-1, $GUI_CHECKED)
$hx = GUICtrlCreateRadio("十六进制", 130, 140, 80, 21)
$cp = GUICtrlCreateButton("复 制", 340, 123, 73, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$box = GUICtrlCreateCombo($win, 80, 19, 249, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{ESC}", "Terminate")
HotKeySet("{NUMPADDIV}", "addnb")
HotKeySet("{NUMPADMULT}", "subnb")
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
$close = 1
Exit
Case $ten
GUICtrlSetState($hx, $GUI_UNCHECKED)
Case $hx
GUICtrlSetState($ten, $GUI_UNCHECKED)
Case $print
$gi = GUICtrlRead($num)
If $gi >= 1 And $gi <> "" And GUICtrlRead($box) <> "" Then
Do
print($win)
$gi -= 1
ToolTip("当前打印数量为" & $gi & @CRLF & "如需暂停打印,请按Pause键" & @CRLF & "如需退出打印,请按ESC键!")
Until $gi = 0
_WinWaitActivate("辅助工具", "")
Else
MsgBox(16 + 262144, "警告", "重复次数不能为空或者零,或者没有找到窗口!")
EndIf
Case $cp
$nb = GUICtrlRead($start) ;要加减的字符(全部)
$_bit = GUICtrlRead($bit) ;位数
$a = StringRight($nb, $_bit) ;要加减运算的字符
$b = StringTrimRight($nb, $_bit) ;左边的字符
EndSwitch
WEnd
Func Addnb()
If GUICtrlRead($ten) = $GUI_CHECKED Then
_WinWaitActivate("BarTender Enterprise", "")
MouseClick("left")
MouseClick("left")
_WinWaitActivate("修改所选条形码对象", "")
Send(GUICtrlRead($start))
Send("{ENTER}")
$a += 1
Switch $_bit - StringLen($a)
Case 0
$c = $a
Case 1
$c = "0" & $a
Case 2
$c = "00" & $a
Case 3
$c = "000" & $a
Case 4
$c = "0000" & $a
Case 5
$c = "00000" & $a
Case 6
$c = "000000" & $a
Case 7
$c = "0000000" & $a
Case 8
$c = "00000000" & $a
EndSwitch
GUICtrlSetData($start, $b & $c)
Else ;十六进制加
_WinWaitActivate("BarTender Enterprise", "")
MouseClick("left")
MouseClick("left")
_WinWaitActivate("修改所选条形码对象", "")
Send(GUICtrlRead($start))
Send("{ENTER}")
$a = Dec($a)
$a = Hex($a + 0x01, $_bit)
GUICtrlSetData($start, $b & $a)
EndIf
EndFunc ;==>Addnb
Func subnb()
If GUICtrlRead($ten) = $GUI_CHECKED Then
$a -= 1
Switch $_bit - StringLen($a)
Case 0
$c = $a
Case 1
$c = "0" & $a
Case 2
$c = "00" & $a
Case 3
$c = "000" & $a
Case 4
$c = "0000" & $a
Case 5
$c = "00000" & $a
Case 6
$c = "000000" & $a
Case 7
$c = "0000000" & $a
Case 8
$c = "00000000" & $a
EndSwitch
GUICtrlSetData($start, $b & $c)
_WinWaitActivate("BarTender Enterprise", "")
MouseClick("left")
MouseClick("left")
_WinWaitActivate("修改所选条形码对象", "")
Send(GUICtrlRead($start))
Send("{ENTER}")
Else ;十六进制减
$a = Dec($a)
$a = Hex($a - 0x01, $_bit)
GUICtrlSetData($start, $b & $a)
_WinWaitActivate("BarTender Enterprise", "")
MouseClick("left")
MouseClick("left")
_WinWaitActivate("修改所选条形码对象", "")
Send(GUICtrlRead($start))
Send("{ENTER}")
EndIf
EndFunc ;==>subnb
Func _tentohex($iNumber)
Dim $sBits = "0123456789ABCDEF"
Dim $iNumBits = 16, $sResult = ""
; 10进制1024转8进制。
While $iNumber > 0
$sResult = StringMid($sBits, Mod($iNumber, $iNumBits) + 1, 1) & $sResult
$iNumber = Int($iNumber / $iNumBits)
WEnd
Return $sResult
EndFunc ;==>_tentohex
Func print($windows)
_WinWaitActivate($windows, "")
Send("{F6}")
_WinWaitActivate("Print", "")
Send("{ENTER}")
_WinWaitActivate($windows, "")
Send("{ALT}E")
Send("{ENTER}")
Send("{F6}")
_WinWaitActivate("Print", "")
Send("{ENTER}")
_WinWaitActivate($windows, "")
If $close = 1 Then Exit
EndFunc ;==>print
Func _WinWaitActivate($title, $text, $timeout = 0)
WinWait($title, $text, $timeout)
If Not WinActive($title, $text) Then WinActivate($title, $text)
WinWaitActive($title, $text, $timeout)
EndFunc ;==>_WinWaitActivate
Func IsVisible($handle)
If BitAND(WinGetState($handle), 2) Then
Return 1
Else
Return 0
EndIf
EndFunc ;==>IsVisible
Func Terminate()
Exit 0
EndFunc ;==>Terminate
Func TogglePause()
$Paused = Not $Paused
While $Paused
Sleep(100)
WEnd
EndFunc ;==>TogglePause
|