|
发表于 2009-10-2 21:13:35
|
显示全部楼层
前几天网吧也要打印开机小票,,于是写了下面这个
#Region ;**** 参数创建于 AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_icon=1.ico
#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_UseAnsi=y
#AutoIt3Wrapper_Res_Comment=小票打印工具
#AutoIt3Wrapper_Res_Description=小票打印工具--阿宝
#AutoIt3Wrapper_Res_Fileversion=1.0
#AutoIt3Wrapper_Res_LegalCopyright=阿宝
#AutoIt3Wrapper_Run_Obfuscator=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <GUIConstants.au3>
#include <ACN_String.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("小票打印 程序制作:阿宝", 255, 188, 315, 235)
$Label1 = GUICtrlCreateLabel("输入押金:", 16, 64, 55, 17)
$Label2 = GUICtrlCreateLabel("输入机号:", 16, 103, 55, 17)
$Input1 = GUICtrlCreateInput("", 80, 96, 153, 21,$ES_NUMBER)
GUICtrlSetColor(-1, 0x0000FF)
$Label3 = GUICtrlCreateLabel("网吧名称:", 16, 24, 55, 17)
$Button1 = GUICtrlCreateButton("打 印", 80, 144, 65, 25, 0)
$Button2 = GUICtrlCreateButton("退 出", 169, 143, 65, 25, 0)
$Input2 = GUICtrlCreateInput("10", 80, 56, 153, 21)
GUICtrlSetColor(-1, 0x0000FF)
$Input3 = GUICtrlCreateInput(" XX网络会所", 81, 19, 153, 21)
GUICtrlSetColor(-1, 0xFF0000)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
HotKeySet ( "{Enter}" , "okk" )
While 1
$msg= GUIGetMsg()
Select
Case $msg=$Button2 or $msg=$GUI_EVENT_CLOSE
Exit
Case $msg=$Button1
$time=@MON &"/"& @MDAY & "/"&@HOUR & ":"&@MIN
$file = FileOpen("pr.txt", 2)
If $file = -1 Then
MsgBox(0, "错误", "pr.txt句柄无法打开")
Exit
EndIf
$wbnm=GUICtrlRead($Input3)
$yj=GUICtrlRead($Input2)
$jh=GUICtrlRead($Input1)
if $jh=="" Then
MsgBox(16,"错误","机号不能为空",3)
exit
endif
FileWrite($file, $wbnm & @CRLF& @CRLF)
FileWrite($file, "机号:" &$jh& @CRLF)
FileWrite($file, "押金:"&$yj& "元"& @CRLF)
FileWrite($file, $time)
FileClose($file)
ShellExecute("pr.txt", "", @ScriptDir, "print")
exit
EndSelect
WEnd
exit
Func okk()
ControlClick ( $Form1, "", $Button1)
EndFunc |
|