自动控制到子窗口

时间:2013-12-02 17:23:12

标签: autoit

我在一个窗口中有1-6个命令提示符。当他们不在窗口时,我可以使用controlsend罚款。 代码:

    $GUI2 = GUICreate("Consoles", 1020, 600, 1282, 300, BitOR($WS_MINIMIZEBOX, $WS_SYSMENU, $WS_CAPTION, $WS_CLIPCHILDREN, $WS_POPUP, $WS_POPUPWINDOW, $WS_GROUP, $WS_BORDER, $WS_CLIPSIBLINGS))
$hwnd00 = WinGetHandle("Consoles")
If GUICtrlRead($Bungee) = 1 Then
    $BungeeServer = Run("java -Xmx512M -jar " & '"' & $file0 & "\BungeeCord.jar" & '"', $file0, $Hide)
    If Not ProcessWait($BungeeServer) = 0 Then
        WinSetTitle("C:\Windows\system32\java.exe", "", "Bungee")
        WinSetTitle("C:\WINDOWS\SYSTEM32\java.exe", "", "Bungee")
        Global $hwnd0 = WinGetHandle("Bungee")
    EndIf
EndIf
If GUICtrlRead($server1) = 1 Then
    $1 = Run("java " & $chosen & " -jar " & '"' & $file1 & '"' & "\minecraft_server.jar", $file1, $Hide)
    If Not ProcessWait($1) = 0 Then
        WinSetTitle("C:\Windows\system32\java.exe", "", "Server1")
        WinSetTitle("C:\WINDOWS\SYSTEM32\java.exe", "", "Server1")
        Global $hwnd1 = WinGetHandle("Server1")
    EndIf
EndIf
If GUICtrlRead($server2) = 1 Then
    $2 = Run("java " & $chosen & " -jar " & '"' & $file2 & '"' & "\minecraft_server.jar", $file2, $Hide)
    If Not ProcessWait($2) = 0 Then
        WinSetTitle("C:\Windows\system32\java.exe", "", "Server2")
        WinSetTitle("C:\WINDOWS\SYSTEM32\java.exe", "", "Server2")
        Global $hwnd2 = WinGetHandle("Server2")
    EndIf
EndIf
If GUICtrlRead($server3) = 1 Then
    $3 = Run("java " & $chosen & " -jar " & '"' & $file3 & '"' & "\minecraft_server.jar", $file3, $Hide)
    If Not ProcessWait($3) = 0 Then
        WinSetTitle("C:\Windows\system32\java.exe", "", "Server3")
        WinSetTitle("C:\WINDOWS\SYSTEM32\java.exe", "", "Server3")
        Global $hwnd3 = WinGetHandle("Server3")
    EndIf
EndIf
If GUICtrlRead($server4) = 1 Then
    $4 = Run("java " & $chosen & " -jar " & '"' & $file4 & '"' & "\minecraft_server.jar", $file4, $Hide)
    If Not ProcessWait($4) = 0 Then
        WinSetTitle("C:\Windows\system32\java.exe", "", "Server4")
        WinSetTitle("C:\WINDOWS\SYSTEM32\java.exe", "", "Server4")
        Global $hwnd4 = WinGetHandle("Server4")
    EndIf
EndIf
If GUICtrlRead($server5) = 1 Then
    $5 = Run("java " & $chosen & " -jar " & '"' & $file5 & '"' & "\minecraft_server.jar", $file5, $Hide)
    If Not ProcessWait($5) = 0 Then
        WinSetTitle("C:\Windows\system32\java.exe", "", "Server5")
        WinSetTitle("C:\WINDOWS\SYSTEM32\java.exe", "", "Server5")
        Global $hwnd5 = WinGetHandle("Server5")
    EndIf
EndIf
_WinAPI_SetWindowLong($hwnd0, $GWL_EXSTYLE, $WS_EX_MDICHILD)
_WinAPI_SetParent($hwnd0, $GUI2)
_WinAPI_SetWindowLong($hwnd1, $GWL_EXSTYLE, $WS_EX_MDICHILD)
_WinAPI_SetParent($hwnd1, $GUI2)
_WinAPI_SetWindowLong($hwnd2, $GWL_EXSTYLE, $WS_EX_MDICHILD)
_WinAPI_SetParent($hwnd2, $GUI2)
_WinAPI_SetWindowLong($hwnd3, $GWL_EXSTYLE, $WS_EX_MDICHILD)
_WinAPI_SetParent($hwnd3, $GUI2)
_WinAPI_SetWindowLong($hwnd4, $GWL_EXSTYLE, $WS_EX_MDICHILD)
_WinAPI_SetParent($hwnd4, $GUI2)
_WinAPI_SetWindowLong($hwnd5, $GWL_EXSTYLE, $WS_EX_MDICHILD)
_WinAPI_SetParent($hwnd5, $GUI2)
WinMove($hwnd0, "", 0, 0, 340, 300)
WinMove($hwnd1, "", 340, 0, 340, 300)
WinMove($hwnd2, "", 680, 0, 340, 300)
WinMove($hwnd3, "", 0, 300, 340, 300)
WinMove($hwnd4, "", 340, 300, 340, 300)
WinMove($hwnd5, "", 680, 300, 340, 300)

之前我使用过:ControlSend(“Server1”,“”,$ hwnd1,'stop'&'{ENTER}') 每个窗口一行。如何在父窗口中向他们发送信息(即使父窗口被隐藏)?

1 个答案:

答案 0 :(得分:2)

此命令允许窗口搜索例程搜索子窗口以及顶级窗口。

Opt("WinSearchChildren", 1) ;0=no, 1=search children also
0 = Only search top-level windows (default)
1 = Search top-level and child windows