|
本帖最后由 nmgwddj 于 2009-10-16 00:39 编辑
我们这边安装的收费软件是长春同联计费系统
如果有60个机器就要60个卡 每次上机的时候都要拿卡去刷卡器刷一下。(会员自己拿着卡上机)很麻烦。于是我就做了一个免刷卡的工具 具体是这样的。
用户上机的时候回出现此对话框
于是我做了个工具 是这样的
一个机器对应一个按钮 按钮的命令是这样写的
WinWait("用户上机")
WinActivate("用户上机")
Send("@0078571023")
Send("{enter}")
这样的话 也可以用。但是如果编辑成EXE文件的话 去给别的网吧使用 就还得去改源码里的卡号,每个网吧的卡号是不一样的。 (我是做网吧维护的 不是想做坏事 呵呵!)
有一天我看见一个巨巨猫论坛一个人写的刷卡工具 好像是用VB写的。在一个文本文档里 把网吧所有的卡号全部刷到文档里 程序是时时监控“用户上机”这个窗口的。每当出现这个窗口 他就读取文档里边的卡号 自动刷卡。而且不重复。如果把所有卡号都刷满后 其中@0078571023 这个卡号下机了 它自动判断文档里的卡号是否被使用 再新上机器的时候 就用@0078571023这个卡号上机。不重复。
我想问下他是怎么做到的。是否需要读取数据库??下边是数据库文件 请高手帮忙看下!
下面是一个曾经写过的代码 我还是看不明白什么意思。特别是这个 “False Then”命令
#NoTrayIcon
#Region ;**** 参数创建于 AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=ico.ico
#AutoIt3Wrapper_Compression=4
#AutoIt3Wrapper_Res_Comment=同联助手 V1.0 Build 08022101
#AutoIt3Wrapper_Res_Description=同联助手 V1.0 Build 08022101
#AutoIt3Wrapper_Res_Fileversion=1.0.0.0
#AutoIt3Wrapper_Res_LegalCopyright=Code By Binsys QQ:123077083 http://www.binsys.cn
#AutoIt3Wrapper_Au3Check_Stop_OnWarning=y
#AutoIt3Wrapper_Run_Tidy=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <Constants.au3>
#include <String.au3>
#include <GUIConstantsEx.au3>
Opt("TrayOnEventMode", 1)
Opt("GUIOnEventMode", 1)
Opt("TrayMenuMode", 1)
$Start = TrayCreateItem("开始")
TrayItemSetOnEvent(-1, "StartEvent")
$Pause = TrayCreateItem("暂停")
TrayItemSetOnEvent(-1, "PauseEvent")
;$Set = TrayCreateItem("注册")
;TrayItemSetOnEvent(-1, "SetEvent")
$About = TrayCreateItem("关于")
TrayItemSetOnEvent(-1, "AboutEvent")
$Exit = TrayCreateItem("退出")
TrayItemSetOnEvent(-1, "ExitEvent")
Dim $Runing
Dim $file = "tlhlperconfig.ini"
Dim $TongLianPath
Dim $CardListCount
Dim $CardID[1]
Dim $AutoStart = "1"
Dim $Verison = "同联助手 V1.0 Build 08022101"
RegKey()
If Init() = False Then
MsgBox(0, "错误-" & $Verison, "初始化错误,请检查配置文件tlhlperconfig.ini的正确性!!!")
Exit
Else
If $AutoStart = "1" Then
TraySetState()
TrayItemSetState($Start, $TRAY_DISABLE)
TrayItemSetState($Pause, $TRAY_ENABLE)
$Runing = True
Else
TraySetState()
TrayItemSetState($Start, $TRAY_ENABLE)
TrayItemSetState($Pause, $TRAY_DISABLE)
$Runing = False
EndIf
EndIf
While 1
Main()
WEnd
Func Init()
If Not FileExists($file) Then
$file = @ScriptDir & "\tlhlperconfig.ini"
If Not FileExists($file) Then
$file = @WorkingDir & "\tlhlperconfig.ini"
EndIf
If Not FileExists($file) Then
Return False
EndIf
Else
$TongLianPath = IniRead(@ScriptDir & "\" & "tlhlperconfig.ini", "Setting", "TongLianPath", "0")
If $TongLianPath = "" Then
Return False
EndIf
$AutoStart = IniRead(@ScriptDir & "\" & "tlhlperconfig.ini", "Setting", "AutoStart", "0")
If $AutoStart = "" Then
Return False
EndIf
$CardListFilePath = IniRead(@ScriptDir & "\" & "tlhlperconfig.ini", "Setting", "CardListFilePath", "0")
If $CardListFilePath = "" Then
Return False
EndIf
$CardListCount = IniRead(@ScriptDir & "\" & "tlhlperconfig.ini", "Setting", "CardListCount", "0")
If $CardListCount = "" Then
Return False
Else
$CardListCount = Number($CardListCount)
EndIf
If Not FileExists(@ScriptDir & "\" & $CardListFilePath) Then
Return False
Else
$CardListFile = FileOpen($CardListFilePath, 0)
; Check if file opened for reading OK
If $CardListFile = -1 Then
Return False
EndIf
ReDim $CardID[$CardListCount]
Dim $i = 0
For $i = 0 To $CardListCount - 1
$CardID[$i] = FileReadLine($CardListFile)
If @error = -1 Then ExitLoop
Next
FileClose($CardListFile)
EndIf
Return True
EndIf
EndFunc ;==>Init
Func Main()
If $Runing = False Then Return
WinWait("用户上机", "")
If $Runing = False Then Return
WinActive("用户上机", "")
If $Runing = False Then Return
If ControlGetText("用户上机", "", "TEdit5") = "" Then
$FreeCardID = GetFreeCardID()
;Send($FreeCardID)
;ControlFocus("用户上机", "", "TEdit5")
ControlSend("用户上机", "", "TEdit5", $FreeCardID)
Send("{Enter down}")
Send("{Enter up}")
Sleep(20)
Send("{Enter down}")
Send("{Enter up}")
;$ok = InputBox("输入","请输入上机金额:","","")
ControlFocus("用户上机", "", "TEdit6")
;Sleep(1000)
;Send("1")
;ControlFocus("用户上机", "", "TMaskEdit2")
;Send("1")
;ControlFocus("用户上机", "", "TEdit6")
;ControlClick("用户上机", "上机", "TBitBtn2")
EndIf
EndFunc ;==>Main
Func GetFreeCardID()
$MDB = $TongLianPath & "\data\data.mdb"
$Conn = ObjCreate("ADODB.Connection")
$Conn.Open("Driver={Microsoft Access Driver (*.mdb)};Password=áíùaidf/emfid#dfDS~;Dbq=" & $MDB)
$RS_PCStatus = ObjCreate("ADODB.Recordset")
$RS_PCStatus.Open("Select * FROM PCStatus where PCStatus = 1", $Conn, 1, 3)
$TempCardID = $CardID[Random(0, $CardListCount - 1, 1)]
$GetFreeCardID = False
While ($GetFreeCardID = False)
$TempCardID = $CardID[Random(0, $CardListCount - 1, 1)]
$Flag = False
While (Not $RS_PCStatus.eof And Not $RS_PCStatus.bof)
If $RS_PCStatus.Fields(14).value = $TempCardID Then $Flag = True
$RS_PCStatus.movenext
WEnd
If $Flag = False Then $GetFreeCardID = True
WEnd
$RS_PCStatus.close
$Conn.close
Return $TempCardID
EndFunc ;==>GetFreeCardID
Func StartEvent()
TrayItemSetState($Start, $TRAY_DISABLE)
TrayItemSetState($Pause, $TRAY_ENABLE)
$Runing = True
EndFunc ;==>StartEvent
Func PauseEvent()
TrayItemSetState($Pause, $TRAY_DISABLE)
TrayItemSetState($Start, $TRAY_ENABLE)
$Runing = False
EndFunc ;==>PauseEvent
Func SetEvent()
RegKey()
EndFunc ;==>SetEvent
Func AboutEvent()
MsgBox(64, "关于", $Verison & @CRLF & @CRLF & @CRLF & "Code By Binsys QQ:123077083" & @CRLF & @CRLF & @CRLF & "www.binsys.cn")
EndFunc ;==>AboutEvent
Func ExitEvent()
Exit
EndFunc ;==>ExitEvent
Dim $Edit2
Dim $Edit1
Func RegKey()
;GUICtrlSetData($Edit1, _GetMAC(@IPAddress1) & "/" & _StringEncrypt(1, _GetMAC(@IPAddress1), _GetMAC(@IPAddress1), "2"))
If (_GetMAC(@IPAddress1) <> "00E37C271D7B") Then
MsgBox(64, "!同联助手 V1.0 Build 08022101-错误", "此拷贝为 天博星网吧专用!!!需要请联系 123077083")
;E()
Exit
Else
EndIf
EndFunc ;==>RegKey
Func Button1Click()
If (verifykey(GUICtrlRead($Edit2)) = True) Then
MsgBox(64, "ok", "regok")
Else
MsgBox(64, "ok", "rego err")
EndIf
EndFunc ;==>Button1Click
Func Button2Click()
GUISetState(@SW_HIDE)
EndFunc ;==>Button2Click
Func Edit1Change()
EndFunc ;==>Edit1Change
Func Edit2Change()
EndFunc ;==>Edit2Change
Func Form1Close()
EndFunc ;==>Form1Close
Func Form1Maximize()
EndFunc ;==>Form1Maximize
Func Form1Minimize()
EndFunc ;==>Form1Minimize
Func Form1Restore()
EndFunc ;==>Form1Restore
Func verifykey($key)
$keys = StringLeft($key, 12)
$crypt = StringTrimLeft($key, 12)
$plain = _StringEncrypt(0, $crypt, _GetMAC(@IPAddress1), "2")
If $plain <> "" Then
Return True
Else
Return False
EndIf
EndFunc ;==>verifykey
Func _GetMAC($sIP)
Local $MAC, $MACSize
Local $i, $s, $r, $iIP
$MAC = DllStructCreate("byte[6]")
$MACSize = DllStructCreate("int")
DllStructSetData($MACSize, 1, 6)
$r = DllCall("Ws2_32.dll", "int", "inet_addr", "str", $sIP)
$iIP = $r[0]
$r = DllCall("iphlpapi.dll", "int", "SendARP", "int", $iIP, "int", 0, "ptr", DllStructGetPtr($MAC), "ptr", DllStructGetPtr($MACSize))
$s = ""
For $i = 0 To 5
;If $i Then $s = $s & ":"
$s = $s & Hex(DllStructGetData($MAC, 1, $i + 1), 2)
Next
Return $s
EndFunc ;==>_GetMAC
Func E()
EndFunc ;==>E |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?加入
×
|