au3一些代码
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#Include <GuiListView.au3>
Run('rundll32.exe shell32.dll,Control_RunDLL Desk.cpl,,0')
WinWaitActive("显示 属性")
Send("!d")
WinWaitActive("桌面项目", "")
Send("^{tab}")
$list=ControlGetHandle("桌面项目",'','SysListView321')
IF _GUICtrlListView_GetItemChecked($list, 0) then
MsgBox(0,"bar","该列表框第一项状态为选中",10)
Else
MsgBox(0,"bar","该列表框第一项状态为未选中",10)
EndIf
_GUICtrlListView_SetItemChecked($list, 0,True)
Sleep(2000)
_GUICtrlListView_SetItemChecked($list, 0,False)
Run('rundll32.exe shell32.dll,Control_RunDLL Desk.cpl,,0')
WinWaitActive("显示 属性")
Send("!d")
WinWaitActive("桌面项目", "")
Send("^{tab}")
$list=ControlGetHandle("桌面项目",'','SysListView321')
IF _GUICtrlListView_GetItemChecked($list, 0) then
MsgBox(0,"bar","该列表框第一项状态为选中",10)
Else
MsgBox(0,"bar","该列表框第一项状态为未选中",10)
EndIf
_GUICtrlListView_SetItemChecked($list, 0,True)
Sleep(2000)
_GUICtrlListView_SetItemChecked($list, 0,False)
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
Func ProcessClosePath($Path)
;作用:根据程序路径结束进程
;返回:当WMI对象不存在,返回错误值1
;作者:叁恨居士
;版权:www.autoit.net.cn
;BLOG: www.lunhui.net.cn
Local $wbemFlagReturnImmediately
Local $wbemFlagForwardOnly
Local $strComputer, $objWMIService
Local $colItems, $objItem
$strComputer = "localhost"
$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20
$Path = StringReplace($Path, "\", "\\")
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
$colItems = $objWMIService.ExecQuery('SELECT * FROM Win32_Process Where ExecutablePath="' & $Path & '"', "WQL", _
$wbemFlagReturnImmediately + $wbemFlagForwardOnly)
If IsObj($colItems) Then
For $objItem In $colItems
$objItem.Terminate()
Next
Else
SetError(1)
EndIf
EndFunc ;==>ProcessClosePath
;作用:根据程序路径结束进程
;返回:当WMI对象不存在,返回错误值1
;作者:叁恨居士
;版权:www.autoit.net.cn
;BLOG: www.lunhui.net.cn
Local $wbemFlagReturnImmediately
Local $wbemFlagForwardOnly
Local $strComputer, $objWMIService
Local $colItems, $objItem
$strComputer = "localhost"
$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20
$Path = StringReplace($Path, "\", "\\")
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
$colItems = $objWMIService.ExecQuery('SELECT * FROM Win32_Process Where ExecutablePath="' & $Path & '"', "WQL", _
$wbemFlagReturnImmediately + $wbemFlagForwardOnly)
If IsObj($colItems) Then
For $objItem In $colItems
$objItem.Terminate()
Next
Else
SetError(1)
EndIf
EndFunc ;==>ProcessClosePath
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#include <GuiMenu.au3>
Local $hWnd, $hMain
Run("Notepad.exe")
WinWaitActive("[CLASS:Notepad]")
$hWnd = WinGetHandle("[CLASS:Notepad]")
$hMain = _GUICtrlMenu_GetMenu($hWnd)
_GUICtrlMenu_RemoveMenu($hMain, 0,1)
Local $hWnd, $hMain
Run("Notepad.exe")
WinWaitActive("[CLASS:Notepad]")
$hWnd = WinGetHandle("[CLASS:Notepad]")
$hMain = _GUICtrlMenu_GetMenu($hWnd)
_GUICtrlMenu_RemoveMenu($hMain, 0,1)
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#include-once
;#cs
;测试时请在(#cs,#ce)前加(;)
sleep(10000)
_AutoLoginEP("sktu")
;#ce
;===============================================================================
; 函数名称: _AutoLoginEP
; 函数功能: 自动登陆EP,在登陆期间锁定键盘鼠标,如果密码错误则解锁键盘鼠标,直到登陆成功。
; 函数版本: 1.0.0.2
; 入口参数: $EPPassword -EP的密码
; 返回参数: 0 - 成功
;===============================================================================
Func _AutoLoginEP($EPPassword="")
local $i,$j
;等待pubwinep程序启动(超时30秒)=========================
For $i= 1 to 30
if WinExists("Client") Then
$i=999
ExitLoop
EndIf
sleep(1000)
Next
if $i=999 Then
;检测到窗口
Else
;未检测到窗口(可能pubwinep未启动)
Return 0
EndIf
;等待pubwinep锁定画面出现(超时15秒)=========================
for $i=1 to 15
if WinExists("LockDlg") Then
$i=999
ExitLoop
EndIf
sleep(1000)
Next
if $i=999 Then
;检测到锁定画面
Else
;未检测到锁定画面(可能客户机已登陆)
Return 0
EndIf
;等待pubwinep网络初始化完成出现(超时15秒)====================
for $j=1 to 15
If WinExists("ActiveMovie Window") Then
$i=999
ExitLoop
EndIf
sleep(1000)
next
if $i=999 Then
;检测到登陆界面
Else
;未检测到登陆画面(可能客户机已登陆,之前被瞬间锁屏)
Return 0
EndIf
;开始登陆EP====================
BlockInput(1) ;锁定键盘鼠标
sleep(1000) ;开始自动登陆
MouseClick("left")
WinWaitActive("LockDlg","",3)
ControlSetText("LockDlg", "", "Edit1", "admin" )
sleep(250)
WinWaitActive("LockDlg","",3)
ControlSetText("LockDlg", "", "Edit2", "你的管理密码" )
sleep(250)
WinWaitActive("LockDlg","",3)
ControlSend("LockDlg","","Button1","{enter}");结束自动登陆
;退出EP
;FileInstall("pack\exitep.exe","c:\windows\system32\exitep.exe",1)
ShellExecute("C:\xsmenu\data\Pubwin2007.exe","90")
sleep(2000)
if WinExists("验证口令") Then
BlockInput(1)
WinWaitActive("验证口令","",5)
ControlSetText("验证口令", "", "Edit1", "你的退出密码" )
sleep(100)
WinWaitActive("验证口令","",5)
ControlSend("验证口令","","Button1","{enter}")
sleep(2000)
BlockInput(0)
if WinExists("验证口令") Then
msgbox(48,"","pubwin退出失败")
EndIf
if WinExists("询问") Then
ControlSend("询问","","Button2","{n}")
EndIf
EndIf
EndFunc
;#cs
;测试时请在(#cs,#ce)前加(;)
sleep(10000)
_AutoLoginEP("sktu")
;#ce
;===============================================================================
; 函数名称: _AutoLoginEP
; 函数功能: 自动登陆EP,在登陆期间锁定键盘鼠标,如果密码错误则解锁键盘鼠标,直到登陆成功。
; 函数版本: 1.0.0.2
; 入口参数: $EPPassword -EP的密码
; 返回参数: 0 - 成功
;===============================================================================
Func _AutoLoginEP($EPPassword="")
local $i,$j
;等待pubwinep程序启动(超时30秒)=========================
For $i= 1 to 30
if WinExists("Client") Then
$i=999
ExitLoop
EndIf
sleep(1000)
Next
if $i=999 Then
;检测到窗口
Else
;未检测到窗口(可能pubwinep未启动)
Return 0
EndIf
;等待pubwinep锁定画面出现(超时15秒)=========================
for $i=1 to 15
if WinExists("LockDlg") Then
$i=999
ExitLoop
EndIf
sleep(1000)
Next
if $i=999 Then
;检测到锁定画面
Else
;未检测到锁定画面(可能客户机已登陆)
Return 0
EndIf
;等待pubwinep网络初始化完成出现(超时15秒)====================
for $j=1 to 15
If WinExists("ActiveMovie Window") Then
$i=999
ExitLoop
EndIf
sleep(1000)
next
if $i=999 Then
;检测到登陆界面
Else
;未检测到登陆画面(可能客户机已登陆,之前被瞬间锁屏)
Return 0
EndIf
;开始登陆EP====================
BlockInput(1) ;锁定键盘鼠标
sleep(1000) ;开始自动登陆
MouseClick("left")
WinWaitActive("LockDlg","",3)
ControlSetText("LockDlg", "", "Edit1", "admin" )
sleep(250)
WinWaitActive("LockDlg","",3)
ControlSetText("LockDlg", "", "Edit2", "你的管理密码" )
sleep(250)
WinWaitActive("LockDlg","",3)
ControlSend("LockDlg","","Button1","{enter}");结束自动登陆
;退出EP
;FileInstall("pack\exitep.exe","c:\windows\system32\exitep.exe",1)
ShellExecute("C:\xsmenu\data\Pubwin2007.exe","90")
sleep(2000)
if WinExists("验证口令") Then
BlockInput(1)
WinWaitActive("验证口令","",5)
ControlSetText("验证口令", "", "Edit1", "你的退出密码" )
sleep(100)
WinWaitActive("验证口令","",5)
ControlSend("验证口令","","Button1","{enter}")
sleep(2000)
BlockInput(0)
if WinExists("验证口令") Then
msgbox(48,"","pubwin退出失败")
EndIf
if WinExists("询问") Then
ControlSend("询问","","Button2","{n}")
EndIf
EndIf
EndFunc