此问题之前曾有人讨论过,见AU3终结者
但是原贴中的解决方法并没有用.
下面的代码运行后将秒杀大部份autoit写的程序,请在编译后运行.
有解决方法?
当然是有的,但目前我所找到的方法并不是很理想.附件中是我用不理想方法编译后的程序.
欢迎各路牛人来说说自己的解决方法.我的解决方法将在稍后贴出.
#NoTrayIcon
#include <winapi.au3>
$AutoItPID = @AutoItPID
Local $iPid
While 1
$var = WinList("[CLASS:AutoIt v3]")
For $i = 1 To $var[0][0]
$hWnd = $var[$i][1] ;hwnd
_WinAPI_GetWindowThreadProcessId($hWnd, $iPid)
If $iPid And $iPid <> $AutoItPID Then
MsgBox(64, "检测到autoit程序", "进程ID: " & $iPid & @LF & "进程名称: " & _WinAPI_ProcessGetFilenNme($iPid) & @LF & "窗口将被显示", 5, $hWnd)
_WinAPI_ShowWindow($hWnd, @SW_SHOW)
MsgBox(64, "", "窗口将被最大化及修改标题", 5, $hWnd)
WinSetTitle($hWnd, "", "看到庐山真面目了吧!")
_WinAPI_ShowWindow($hWnd, @SW_MAXIMIZE)
MsgBox(64, "", "目标窗口将被关闭", 5, $hWnd)
WinClose($hWnd)
EndIf
$iPid = 0
Next
Sleep(1)
WEnd
Func _WinAPI_ProcessGetFilenNme($vProcessID = @AutoItPID, $bFullPath = False)
If Not $vProcessID Then Return SetError(1, 0, '')
Local $hProcess, $stFilename, $aRet, $sFilename, $sDLLFunctionName
If $bFullPath Then
$sDLLFunctionName = "GetModuleFileNameEx"
Else
$sDLLFunctionName = "GetModuleBaseName"
EndIf
Local $hProcess = DllCall('kernel32.dll', 'ptr', 'OpenProcess', 'int', BitOR(0x400, 0x10), 'int', 0, 'int', $vProcessID)
If @error Or Not IsArray($hProcess) Then Return SetError(2, 0, "")
$stFilename = DllStructCreate("wchar[32767]")
$aRet = DllCall("Psapi.dll", "dword", $sDLLFunctionName & 'W', _
"ptr", $hProcess[0], "ptr", Chr(0), "ptr", DllStructGetPtr($stFilename), "dword", 32767)
If @error Or Not IsArray($aRet) Then
DllCall('kernel32.dll', 'ptr', 'CloseHandle', 'ptr', $hProcess[0])
$stFilename = 0
$hProcess = 0
Return SetError(2, 0, "")
EndIf
$sFilename = DllStructGetData($stFilename, 1)
DllCall('kernel32.dll', 'ptr', 'CloseHandle', 'ptr', $hProcess[0])
$stFilename = 0
$hProcess = 0
Return SetError(0, 0, $sFilename)
EndFunc ;==>_WinAPI_ProcessGetFilenNme
|