#NoTrayIcon
#Region ;**** 编译指令由 AutoIt3Wrapper 选项编译窗口创建 ****
#AutoIt3Wrapper_Icon=Icon.ico
#AutoIt3Wrapper_Outfile=Live800 Helper.exe
#AutoIt3Wrapper_UseX64=n
#EndRegion ;**** 编译指令由 AutoIt3Wrapper 选项编译窗口创建 ****
;~ #RequireAdmin
#include <WindowsConstants.au3>
;~ #include <StaticConstants.au3>
;~ #include <StringConstants.au3>
;~ #include <WinAPI.au3>
;~ #include <StructureConstants.au3>
#include <GUIConstantsEx.au3>
;~ #include <File.au3>
#include <EditConstants.au3>
;~ #include <WinAPISys.au3>
;~ #include <ListViewConstants.au3>
;~ #include <ComboConstants.au3>
#include <GuiListView.au3>
#include <StringEncrypt.au3>
#include <WinAPIProc.au3>
Opt('TrayMenuMode', 3)
Dim $ArrData[0][5]
$Exists = 'Live800自动登录账号管理' ;判断是否只运行一个程序
If WinExists($Exists) Then
WinSetState($Exists, '', @SW_SHOW)
WinActivate($Exists)
Exit
EndIf
Dim $SFile = @ScriptDir & '\账号配置.txt'
Dim $hGuiMain = GUICreate($Exists, 400, 336, -1, -1)
$Listview1 = GUICtrlCreateListView('', 2, 2, 396, 200, BitOR($LVS_REPORT, $LVS_SHOWSELALWAYS, $LVS_SINGLESEL, $LVS_NOSORTHEADER), $LVS_EX_FULLROWSELECT)
$hListview1 = GUICtrlGetHandle($Listview1)
_GUICtrlListView_InsertColumn($hListview1, 0, '备注', 79)
_GUICtrlListView_InsertColumn($hListview1, 1, '公司ID', 79)
_GUICtrlListView_InsertColumn($hListview1, 2, '账号', 79)
_GUICtrlListView_InsertColumn($hListview1, 3, '密码', 79)
_GUICtrlListView_InsertColumn($hListview1, 4, '程序路径', 79)
Dim $id_1 = GUICtrlCreateButton('添加', 8, 298, 70, 30)
Dim $id_2 = GUICtrlCreateButton('删除', 112, 298, 70, 30)
Dim $id_3 = GUICtrlCreateButton('修改', 216, 298, 70, 30)
Dim $id_4 = GUICtrlCreateButton('保存', 320, 298, 70, 30)
$ExistsLabel = GUICtrlCreateLabel('信息备注', 10, 213, 48, 14)
Local $Marks = GUICtrlCreateInput('', 62, 210, 100, 17)
GUICtrlCreateLabel('公司ID', 170, 213, 40, 14)
Local $CID = GUICtrlCreateInput('', 214, 210, 100, 17)
GUICtrlCreateLabel('账号', 10, 243, 24, 14)
Local $AccData = GUICtrlCreateInput('', 62, 240, 100, 17)
GUICtrlCreateLabel('密码', 170, 243, 24, 14)
Local $PWData = GUICtrlCreateInput('', 214, 240, 100, 17, BitOR($ES_AUTOHSCROLL, $ES_PASSWORD))
GUICtrlCreateLabel('程序路径', 10, 273, 48, 14)
Dim $id_5 = GUICtrlCreateButton('浏览', 62, 270, 50, 20)
Local $PathData = GUICtrlCreateInput('点击浏览,选择Live800程序路径。', 116, 271, 276, 17, BitOR($GUI_SS_DEFAULT_INPUT, $ES_READONLY))
Dim $id_6 = GUICtrlCreateButton('登录', 320, 214, 70, 40)
If FileExists($SFile) Then
Local $rFile = FileOpen($SFile)
Local $sFileRead = FileRead($rFile)
FileClose($rFile)
Local $TArrData = StringSplit($sFileRead, @CRLF, 3)
For $i = 0 To UBound($TArrData) - 1
If $TArrData[$i] <> '' Then
ReDim $ArrData[UBound($ArrData) + 1][5]
Local $aData = StringSplit($TArrData[$i], ';', 3)
For $j = 0 To UBound($aData) - 1
If $j = 3 Then
$ArrData[UBound($ArrData) - 1][$j] = StringEncrypt(0, $aData[$j], 'abc123', 1, 4)
Else
$ArrData[UBound($ArrData) - 1][$j] = $aData[$j]
EndIf
Next
_AddArrayListView(UBound($ArrData) - 1)
EndIf
Next
EndIf
TraySetState(2)
GUISetState()
GUIRegisterMsg($WM_NOTIFY, 'WM_NOTIFY')
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
_exit()
Case $id_1 ;添加
Select
Case GUICtrlRead($Marks) = ''
MsgBox(0, '提示', '请填写账号备注。', 0, $hGuiMain)
ControlFocus($hGuiMain, '', $Marks)
Case GUICtrlRead($CID) = ''
MsgBox(0, '提示', '请填写公司ID。', 0, $hGuiMain)
ControlFocus($hGuiMain, '', $CID)
Case GUICtrlRead($AccData) = ''
MsgBox(0, '提示', '请填写账号。', 0, $hGuiMain)
ControlFocus($hGuiMain, '', $AccData)
Case GUICtrlRead($PWData) = ''
MsgBox(0, '提示', '请填写密码。', 0, $hGuiMain)
ControlFocus($hGuiMain, '', $PWData)
Case GUICtrlRead($PathData) = '点击浏览,选择Live800程序路径。'
MsgBox(0, '提示', '请先选择游戏路径。', 0, $hGuiMain)
ControlClick($hGuiMain, '', $id_5)
Case Else
ReDim $ArrData[UBound($ArrData) + 1][5]
$ArrData[UBound($ArrData) - 1][0] = GUICtrlRead($Marks)
$ArrData[UBound($ArrData) - 1][1] = GUICtrlRead($CID)
$ArrData[UBound($ArrData) - 1][2] = GUICtrlRead($AccData)
$ArrData[UBound($ArrData) - 1][3] = GUICtrlRead($PWData)
$ArrData[UBound($ArrData) - 1][4] = GUICtrlRead($PathData)
_AddArrayListView(UBound($ArrData) - 1)
EndSelect
Case $id_2 ;删除
Local $TempSelectIndex = _GUICtrlListView_GetSelectionMark($hListview1), $TempCount = _GUICtrlListView_GetItemCount($hListview1)
If $TempSelectIndex <> -1 Then
_GUICtrlListView_DeleteItem($hListview1, $TempSelectIndex)
_ArrayDelete($ArrData, $TempSelectIndex)
If $TempCount > 1 Then
If $TempSelectIndex < $TempCount - 1 Then
_GUICtrlListView_ClickItem($hListview1, $TempSelectIndex)
Else
_GUICtrlListView_ClickItem($hListview1, $TempCount - 2)
EndIf
EndIf
EndIf
Case $id_3 ;修改
Local $TempSelectIndex = _GUICtrlListView_GetSelectionMark($hListview1)
If $TempSelectIndex <> -1 Then
Local $TempText = ''
For $j = 1 To StringLen(GUICtrlRead($PWData))
$TempText &= '*'
Next
$ArrData[$TempSelectIndex][0] = GUICtrlRead($Marks)
$ArrData[$TempSelectIndex][1] = GUICtrlRead($CID)
$ArrData[$TempSelectIndex][2] = GUICtrlRead($AccData)
$ArrData[$TempSelectIndex][3] = GUICtrlRead($PWData)
$ArrData[$TempSelectIndex][4] = GUICtrlRead($PathData)
_GUICtrlListView_SetItemText($hListview1, $TempSelectIndex, GUICtrlRead($Marks), 0)
_GUICtrlListView_SetItemText($hListview1, $TempSelectIndex, GUICtrlRead($CID), 1)
_GUICtrlListView_SetItemText($hListview1, $TempSelectIndex, GUICtrlRead($AccData), 2)
_GUICtrlListView_SetItemText($hListview1, $TempSelectIndex, $TempText, 3)
_GUICtrlListView_SetItemText($hListview1, $TempSelectIndex, GUICtrlRead($PathData), 4)
EndIf
Case $id_4 ;保存
SaveSetting()
Case $id_5 ;浏览
Local $var = FileOpenDialog('选择执行程序', @ScriptDir, 'Live800(*.exe)', 1)
If Not @error Then
GUICtrlSetData($PathData, $var)
Else
GUICtrlSetData($PathData, '点击浏览,选择Live800程序路径')
EndIf
Case $id_6 ;登录
Local $TempSelectIndex = _GUICtrlListView_GetSelectionMark($hListview1)
If $TempSelectIndex <> -1 Then
_Login($TempSelectIndex)
EndIf
EndSwitch
If _Hover($hGuiMain,2, 2, 396, 200) = 0 Then ToolTip('')
WEnd
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
Local $tNMHDR, $hWndFrom, $iCode, $tInfo
$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
$hWndFrom = DllStructGetData($tNMHDR, 'hWndFrom')
$iCode = DllStructGetData($tNMHDR, 'Code')
Switch $hWndFrom
Case $hListview1
Switch $iCode
Case $NM_CLICK
Local $TempSelectIndex = _GUICtrlListView_GetSelectionMark($hListview1)
If $TempSelectIndex <> -1 Then
GUICtrlSetData($Marks, $ArrData[$TempSelectIndex][0])
GUICtrlSetData($CID, $ArrData[$TempSelectIndex][1])
GUICtrlSetData($AccData, $ArrData[$TempSelectIndex][2])
GUICtrlSetData($PWData, $ArrData[$TempSelectIndex][3])
GUICtrlSetData($PathData, $ArrData[$TempSelectIndex][4])
EndIf
Case $NM_DBLCLK
Local $TempSelectIndex = _GUICtrlListView_GetSelectionMark($hListview1)
If $TempSelectIndex <> -1 Then
_Login($TempSelectIndex)
EndIf
Case $LVN_HOTTRACK
$tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam)
Local $HotItem = _GUICtrlListView_GetHotItem($hListview1)
If $HotItem <> -1 Then
$SubItem = DllStructGetData($tInfo, 'SubItem')
If $SubItem = 4 Then
ToolTip($ArrData[$HotItem][4])
Else
ToolTip('')
EndIf
Else
ToolTip('')
EndIf
EndSwitch
EndSwitch
EndFunc ;==>WM_NOTIFY
Func _AddArrayListView($arrNum)
Local $TempCount = _GUICtrlListView_GetItemCount($hListview1)
For $i = 0 To 4
If $i = 0 Then ;0 加新组
_GUICtrlListView_AddItem($hListview1, $ArrData[$arrNum][$i])
ElseIf $i = 3 Then ;3 显示密码
Local $TempText = ''
For $j = 1 To StringLen($ArrData[$arrNum][$i])
$TempText &= '*'
Next
_GUICtrlListView_AddSubItem($hListview1, $TempCount, $TempText, $i)
Else
_GUICtrlListView_AddSubItem($hListview1, $TempCount, $ArrData[$arrNum][$i], $i)
EndIf
Next
EndFunc ;==>_AddArrayListView
Func _Login($arrNum)
Local $iPID = Run($ArrData[$arrNum][4])
WinWait('登录Live800', '动态口令', 15) ;等待15秒
Local $aPID = _WinAPI_EnumProcessWindows($iPID)
If IsArray($aPID) Then
For $i = 1 To UBound($aPID) - 1
If $aPID[$i][1] = 'TLive800LoginForm' Then ;登录界面
$aHwnd = $aPID[$i][0]
ExitLoop
EndIf
Next
EndIf
ControlSetText($aHwnd, '', 'TAdvOfficeComboBox2', $ArrData[$arrNum][1]) ;公司ID
ControlSetText($aHwnd, '', 'TAdvOfficeComboBox1', $ArrData[$arrNum][2]) ;账号
ControlSetText($aHwnd, '', 'TAdvEdit1', $ArrData[$arrNum][3]) ;密码
ControlClick($aHwnd, '', 'TAdvGlowButton1')
While 1
Local $aPID = _WinAPI_EnumProcessWindows($iPID)
If IsArray($aPID) Then
For $i = 1 To UBound($aPID) - 1
If $aPID[$i][1] = 'TApplication' Then ;聊天界面
$aHwnd = $aPID[$i][0]
ExitLoop (2)
EndIf
Next
EndIf
WEnd
WinSetTitle($aHwnd, '', $ArrData[$arrNum][0])
EndFunc ;==>_Login
Func SaveSetting()
Local $saveData = ''
If UBound($ArrData) > 0 Then
For $i = 0 To UBound($ArrData) - 1
For $j = 0 To 4
If $j = 3 Then
$saveData &= StringEncrypt(1, $ArrData[$i][$j], 'abc123', 1, 4) & ';'
Else
$saveData &= $ArrData[$i][$j] & ';'
EndIf
Next
$saveData = StringTrimRight($saveData, 1) & @CRLF
Next
EndIf
$wFile = FileOpen($SFile, 514)
FileWrite($wFile, $saveData)
FileClose($wFile)
EndFunc ;==>SaveSetting
Func _exit()
Exit
EndFunc ;==>_exit
Func _Hover($cH_hWin = "", $Pos_X = 0, $Pos_Y = 0, $Pos_W = 0, $Pos_H = 0)
$cH_Data = GUIGetCursorInfo($cH_hWin)
;~ TrayTip($cH_Data[0] & " " & $cH_Data[1], $Pos_X & " + " & $Pos_X + $Pos_W & " " & $Pos_Y & " + " & $Pos_Y + $Pos_H,5)
If Not IsArray($cH_Data) Then Return SetError(10086)
If $cH_Data[0] > $Pos_X And $cH_Data[0] < $Pos_X + $Pos_W And $cH_Data[1] > $Pos_Y And $cH_Data[1] < $Pos_Y + $Pos_H Then
Return 1
Else
Return 0
EndIf
EndFunc