|
本帖最后由 jevonleen 于 2012-8-1 21:42 编辑
先上源码:
#NoTrayIcon
#Include <GuiToolBar.au3>
_SysTray_ClickItem("卡巴斯基全功能安全软件", "right", 1)
If @error Then MsgBox(48, "Failure", "Required item not found")
Send('{UP 6}')
Send('{ENTER}')
Send('{TAB 4}')
Send('{TAB }')
Send('{SPACE}')
Send('{RIGHT}')
Send('{DOWN 18}')
Send('{TAB}')
Send('{SPACE}')
Send('{ENTER}')
;=========# _SysTray_ClickItem #======================================================
;
;Function Name: _SysTray_ClickItem()
;Description: Click on item in Windows system tray by any substring in the title
;Parameters: $iTitle - The title of the item in Windows system tray (you can see the title of the item when mouse cursor hovered on item).
; $iButton - [optional] The button to click, "left" or "right". Default is the left button.
; $iClick - [optional] The number of times to click the mouse. Default is 1
; $sMove = [optional] True = Mouse will be moved, False (default) = Mouse will not be moved
; $iSpeed = [optional] Mouse movement speed
;Return Value(s): Success - Returns 1
; Failure - Returns 0 and sets @error to 1 if required item not found
;Requirement(s): AutoIt 3.2.10.0 and above
;Autor(s): R.Gilman (a.k.a rasim); Siao (Thanks for idea)
;
;====================================================================================
Func _SysTray_ClickItem($iTitle, $iButton = "left", $iClick = 1, $sMove = False, $iSpeed = 1)
Local $hToolbar, $iButCount, $aRect, $hButton, $cID, $i
$hToolbar = ControlGetHandle("[Class:Shell_TrayWnd]", "", "[Class:ToolbarWindow32;Instance:1]")
If @error Then
Return SetError(1, 0, 0)
EndIf
$iButCount = _GUICtrlToolbar_ButtonCount($hToolbar)
If $iButCount = 0 Then
Return SetError(1, 0, 0)
EndIf
$hButton = ControlGetHandle("[Class:Shell_TrayWnd]", "", "Button2")
If $hButton <> "" Then ControlClick("[Class:Shell_TrayWnd]", "", "Button2")
For $i = 0 To $iButCount - 1
$cID = _GUICtrlToolbar_IndexToCommand($hToolBar, $i)
If StringInStr(_GUICtrlToolbar_GetButtonText($hToolBar, $cID), $iTitle) Then
_GUICtrlToolbar_ClickButton($hToolbar, $cID, $iButton, $sMove, $iClick, $iSpeed)
Return 1
EndIf
Next
Return SetError(1, 0, 0)
EndFunc
因为本人想搞个自动激活卡巴的,所以写了以上代码.(托盘右键不是本人写的).但执行代码后,打开窗口还未出现,后台进程却已关闭.而源码能正常执行完毕.但是后面执行的程序需要此代码完全执行完毕后再执行,用RunWait和ProcessWaitClose都不行,请高手帮忙,谢谢!
注:不用SLEEP
刚刚又试了一个脚本,原来可以关闭卡巴保护和自我保护的,现在却只能关闭保护而不能关闭自我保护!请高手帮忙,谢谢! |
|