我的系统中正在运行许多应用程序。我需要将特定的应用程序窗口作为活动窗口。据我所知,这将由shell脚本完成,这就是我选择AutoIt脚本的原因。
答案 0 :(得分:0)
尝试查看帮助文件。 WinActivate,Winexists ......
#include<Array.au3>
$a = ProcessGetId('firefox.exe')
For $i = 1 To UBound($a) - 1
ConsoleWrite(ProcessGetWindow($a[$i]) & @CRLF)
Next
Func ProcessGetWindow($PId)
If IsNumber($PId) = 0 Or ProcessExists(ProcessGetName($PId)) = 0 Then
SetError(1)
Else
Local $WinList = WinList()
Local $i = 1
Local $WindowTitle = ""
While $i <= $WinList[0][0] And $WindowTitle = ""
If WinGetProcess($WinList[$i][0], "") = $PId Then
$WindowTitle = $WinList[$i][0]
Else
$i += 1
EndIf
WEnd
Return $WindowTitle
EndIf
EndFunc ;==>ProcessGetWindow
Func ProcessGetId($Process)
If IsString($Process) = 0 Then
SetError(2)
ElseIf ProcessExists($Process) = 0 Then
SetError(1)
Else
Local $PList = ProcessList($Process)
Local $i
Local $PId[$PList[0][0] + 1]
$PId[0] = $PList[0][0]
For $i = 1 To $PList[0][0]
$PId[$i] = $PList[$i][1]
Next
Return $PId
EndIf
EndFunc ;==>ProcessGetId
Func ProcessGetName($PId)
If IsNumber($PId) = 0 Then
SetError(2)
ElseIf $PId > 9999 Then
SetError(1)
Else
Local $PList = ProcessList()
Local $i = 1
Local $ProcessName = ""
While $i <= $PList[0][0] And $ProcessName = ""
If $PList[$i][1] = $PId Then
$ProcessName = $PList[$i][0]
Else
$i = $i + 1
EndIf
WEnd
Return $ProcessName
EndIf
EndFunc ;==>ProcessGetName