【已解决】鼠标滑过显示tool,但是划出窗口不会消失i
本帖最后由 3131210 于 2019-5-26 19:50 编辑如图,鼠标移到程序路径,会显示tooltip,移到其他位置会隐藏。但是显示tooltip的时候,鼠标移出程序窗口范围,就不会消失,要怎么改呢?
附件是源码,贴上显示tooltip的代码
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 $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])
Else
ToolTip('')
EndIf
Else
ToolTip('')
EndIf
EndSwitch
EndSwitch
EndFunc ;==>WM_NOTIFY
#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
$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
Local $aData = StringSplit($TArrData[$i], ';', 3)
For $j = 0 To UBound($aData) - 1
If $j = 3 Then
$ArrData[$j] = StringEncrypt(0, $aData[$j], 'abc123', 1, 4)
Else
$ArrData[$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
$ArrData = GUICtrlRead($Marks)
$ArrData = GUICtrlRead($CID)
$ArrData = GUICtrlRead($AccData)
$ArrData = GUICtrlRead($PWData)
$ArrData = 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] = GUICtrlRead($Marks)
$ArrData[$TempSelectIndex] = GUICtrlRead($CID)
$ArrData[$TempSelectIndex] = GUICtrlRead($AccData)
$ArrData[$TempSelectIndex] = GUICtrlRead($PWData)
$ArrData[$TempSelectIndex] = 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])
GUICtrlSetData($CID, $ArrData[$TempSelectIndex])
GUICtrlSetData($AccData, $ArrData[$TempSelectIndex])
GUICtrlSetData($PWData, $ArrData[$TempSelectIndex])
GUICtrlSetData($PathData, $ArrData[$TempSelectIndex])
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 <> -1Then
$SubItem = DllStructGetData($tInfo, 'SubItem')
If $SubItem = 4 Then
ToolTip($ArrData[$HotItem])
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])
WinWait('登录Live800', '动态口令', 15) ;等待15秒
Local $aPID = _WinAPI_EnumProcessWindows($iPID)
If IsArray($aPID) Then
For $i = 1 To UBound($aPID) - 1
If $aPID[$i] = 'TLive800LoginForm' Then ;登录界面
$aHwnd = $aPID[$i]
ExitLoop
EndIf
Next
EndIf
ControlSetText($aHwnd, '', 'TAdvOfficeComboBox2', $ArrData[$arrNum]) ;公司ID
ControlSetText($aHwnd, '', 'TAdvOfficeComboBox1', $ArrData[$arrNum]) ;账号
ControlSetText($aHwnd, '', 'TAdvEdit1', $ArrData[$arrNum]) ;密码
ControlClick($aHwnd, '', 'TAdvGlowButton1')
While 1
Local $aPID = _WinAPI_EnumProcessWindows($iPID)
If IsArray($aPID) Then
For $i = 1 To UBound($aPID) - 1
If $aPID[$i] = 'TApplication' Then ;聊天界面
$aHwnd = $aPID[$i]
ExitLoop (2)
EndIf
Next
EndIf
WEnd
WinSetTitle($aHwnd, '', $ArrData[$arrNum])
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 & " " & $cH_Data, $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 > $Pos_X And $cH_Data < $Pos_X + $Pos_W And $cH_Data > $Pos_Y And $cH_Data < $Pos_Y + $Pos_H Then
Return 1
Else
Return 0
EndIf
EndFunc gzh888666 发表于 2019-5-26 13:19
很完美。。。
用你的思路在循环里面加下面代码就可以了
$CursorInfo = GUIGetCursorInfo($hGuiMain)
If IsArray($CursorInfo) Then
If $CursorInfo <> $Listview1 Then
ToolTip('')
EndIf
EndIf #include <StringEncrypt.au3>这个文件哪里有? redapple2008 发表于 2019-5-27 08:40
#include 这个文件哪里有?
打包在附件里面了,自己下载 学习一下,谢谢
页:
[1]