EpicKnarvik97
EpicKnarvik97

Reputation: 165

Autoit Controlsend to child window

I have from 1-6 commandprompts in a window. When they weren't in the window, I could use controlsend fine. Code:

    $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)

Earlier I used this: ControlSend("Server1", "", $hwnd1, 'stop' & '{ENTER}') One line for each of the windows. How can I send information to them when they are in the parent window(Even if the parent window is hidden)?

Upvotes: 1

Views: 1645

Answers (1)

Milos
Milos

Reputation: 2946

This command allows the window search routines to search child windows as well as top-level windows.

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

Upvotes: 2

Related Questions