本帖最后由 李岸 于 2015-5-1 23:26 编辑 #include <WinAPIShellEx.au3>
#include <WinAPIProc.au3>
$sCmd = 'C:\Users\Administrator\Desktop\Play.lnk'
$sVerb = 'open'
$iCmdLen = StringLen($sCmd)
$iVerb = StringLen($sVerb)
$stCmd = DllStructCreate("wchar[" & $iCmdLen + 1 & "]")
$stVerb = DllStructCreate("wchar[" & $iVerb + 1 & "]")
DllStructSetData($stCmd, 1, $sCmd)
DllStructSetData($stVerb, 1, $sVerb)
$stINFO = DllStructCreate("ulong;ulong;long;ptr;ptr;ptr;ptr;long;long;ptr;ptr;long;ulong;long;long")
DllStructSetData($stINFO, 1, DllStructGetSize($stINFO))
DllStructSetData($stINFO, 2, BitOR(0x40, 0x400))
DllStructSetData($stINFO, 3, 0)
DllStructSetData($stINFO, 4, DllStructGetPtr($stVerb))
DllStructSetData($stINFO, 5, DllStructGetPtr($stCmd))
DllStructSetData($stINFO, 8, 1)
_WinAPI_ShellExecuteEx($stINFO)
$hProcess = DllStructGetData($stINFO, 15)
$PID = _WinAPI_GetProcessID($hProcess)
$hWnd = _GetHwndFromPID($PID)
Func _GetHwndFromPID($PID)
$hWnd = 0
$stPID = DllStructCreate("int")
Do
$winlist2 = WinList()
For $i = 1 To $winlist2[0][0]
If $winlist2[$i][0] <> "" Then
DllCall("user32.dll", "int", "GetWindowThreadProcessId", "hwnd", $winlist2[$i][1], "ptr", DllStructGetPtr($stPID))
If DllStructGetData($stPID, 1) = $PID Then
$hWnd = $winlist2[$i][1]
ExitLoop
EndIf
EndIf
Next
Sleep(100)
Until $hWnd <> 0
Return $hWnd
EndFunc ;==>_GetHwndFromPID
|