Riko Posted January 28, 2008 Posted January 28, 2008 Dear All, Please share information whether it is possible to run external application inside GUI created by autoit3. For example, to create a GUI that will display a window divided in two sections, on the left section we'll have Windows Netmeeting running, on the right section we'll have our controls. Thank you very much, Riko
Xenobiologist Posted January 28, 2008 Posted January 28, 2008 Hi, expandcollapse popup;Gui drumrun #include <GUIConstants.au3> #include <Array.au3> HotKeySet("{ESC}", "_end") Global $title = 'Unbenannt - Editor' ; German! $PID = Run(@WindowsDir & "\notepad.exe", "", @SW_SHOW) WinWait($title, '', 2) $handle = WinGetHandle($title) WinMove($handle, '', 100, 200, 400, 200) Global $start = WinGetPos($handle) $gui = GUICreate("GUI", $start[2] + 50, $start[3] + 50, $start[0] - 25, $start[1] - 55, Default) $exit_B = GUICtrlCreateButton('Exit', 5, 1, 100, 20) GUISetBkColor(0x00FF00) WinSetTitle($handle, '', 'Megas Notepad :-)') _GUICreateInvRect($gui, 20, 50, $start[2] + 10, $start[3] + 10) GUISetState(@SW_SHOW) ; will display an empty dialog box ; UnComment this line and see the difference!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ;DllCall("user32.dll", "int", "SetParent", "hwnd", WinGetHandle($handle), "hwnd", WinGetHandle($gui)) ;Variables Global $saveGuipos = WinGetPos('GUI') ; Run the GUI until the dialog is closed While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE WinClose($handle) ExitLoop Case $exit_B WinClose($handle) ExitLoop EndSwitch ;_checkWin() WEnd Func _checkWin() $newGUIpos = WinGetPos('GUI') $p1 = _ArrayToString($saveGuipos, ',') $p2 = _ArrayToString($newGUIpos, ',') If $p1 <> $p2 Then ConsoleWrite(1 & @CRLF) WinMove($handle, '', $newGUIpos[0] + 25, $newGUIpos[1] + 55) $saveGuipos = $newGUIpos EndIf EndFunc ;==>_checkWin Func _GUICreateInvRect($hwnd, $l, $t, $w, $h) $pos = WinGetPos($hwnd) $1 = 0 $2 = 0 $3 = $pos[2] $4 = $t $ret = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", $1, "long", $2, "long", $3, "long", $4) $1 = 0 $2 = 0 $3 = $l $4 = $pos[3] $ret2 = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", $1, "long", $2, "long", $3, "long", $4) $1 = $l + $w $2 = 0 $3 = $pos[2] $4 = $pos[3] $ret3 = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", $1, "long", $2, "long", $3, "long", $4) $1 = 0 $2 = $t + $h $3 = $pos[2] $4 = $pos[3] $ret4 = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", $1, "long", $2, "long", $3, "long", $4) DllCall("gdi32.dll", "long", "CombineRgn", "long", $ret[0], "long", $ret[0], "long", $ret2[0], "int", 2) DllCall("gdi32.dll", "long", "CombineRgn", "long", $ret[0], "long", $ret[0], "long", $ret3[0], "int", 2) DllCall("gdi32.dll", "long", "CombineRgn", "long", $ret[0], "long", $ret[0], "long", $ret4[0], "int", 2) DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $hwnd, "long", $ret[0], "int", 1) EndFunc ;==>_GUICreateInvRect Func _end() Exit (0) EndFunc ;==>_end Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times
martin Posted January 30, 2008 Posted January 30, 2008 (edited) Dear All, Please share information whether it is possible to run external application inside GUI created by autoit3. For example, to create a GUI that will display a window divided in two sections, on the left section we'll have Windows Netmeeting running, on the right section we'll have our controls. Thank you very much, Riko Or maybe like this #include <windowsconstants.au3> #include <constants.au3> $hGui1 = GUICreate('Parent',800,600,100,100, BitOr($GUI_SS_DEFAULT_GUI,$WS_CLIPCHILDREN)) $iBtn1 = GUICtrlCreateButton("fit",560,10,100,21) $hLV1 = GUICtrlCreateListView("lvexample",410,50,300,300) GUISetState() Run("notepad.exe") Sleep(300) WinMove("Untitled","",0,0,395,600) WinMove("D:\WINDOWS\System32\cmd","",395,0,400,620) Sleep(300) DllCall("user32.dll", "int", "SetParent", "hwnd", WinGetHandle("Untitled"), "hwnd", WinGetHandle('Parent')) While 1 $msg = GUIGetMsg() If $msg = -3 Then Exit WEnd Edited January 30, 2008 by martin Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
BrettF Posted January 30, 2008 Posted January 30, 2008 Or we could use _WinAPI_SetParent... Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version!
Xenobiologist Posted January 30, 2008 Posted January 30, 2008 HI, I tested it with both func. When setting the parent window the notepad window is moved. Why? expandcollapse popup;Gui drumrun #include <GUIConstants.au3> #include <Array.au3> HotKeySet("{ESC}", "_end") HotKeySet("1", "_parent") Global $title = 'Unbenannt - Editor'; German! $PID = Run(@WindowsDir & "\notepad.exe", "", @SW_SHOW) WinWait($title, '', 2) $handle = WinGetHandle($title) WinMove($handle, '', 100, 200, 400, 200) Global $start = WinGetPos($handle) $gui = GUICreate("GUI", $start[2] + 50, $start[3] + 50, $start[0] - 25, $start[1] - 55, Default) $exit_B = GUICtrlCreateButton('Exit', 5, 1, 100, 20) GUISetBkColor(0x00FF00) WinSetTitle($handle, '', 'Megas Notepad :-)') _GUICreateInvRect($gui, 20, 50, $start[2] + 10, $start[3] + 10) GUISetState(@SW_SHOW); will display an empty dialog box Func _parent() ; UnComment this line and see the difference!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! _WinAPI_SetParent(WinGetHandle($handle), WinGetHandle($gui)) ;DllCall("user32.dll", "int", "SetParent", "hwnd", WinGetHandle($handle), "hwnd", WinGetHandle($gui)) EndFunc ;==>_parent ;Variables Global $saveGuipos = WinGetPos('GUI') ; Run the GUI until the dialog is closed While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE WinClose($handle) ExitLoop Case $exit_B WinClose($handle) ExitLoop EndSwitch ;_checkWin() WEnd Func _checkWin() $newGUIpos = WinGetPos('GUI') $p1 = _ArrayToString($saveGuipos, ',') $p2 = _ArrayToString($newGUIpos, ',') If $p1 <> $p2 Then ConsoleWrite(1 & @CRLF) WinMove($handle, '', $newGUIpos[0] + 25, $newGUIpos[1] + 55) $saveGuipos = $newGUIpos EndIf EndFunc ;==>_checkWin Func _GUICreateInvRect($hwnd, $l, $t, $w, $h) $pos = WinGetPos($hwnd) $1 = 0 $2 = 0 $3 = $pos[2] $4 = $t $ret = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", $1, "long", $2, "long", $3, "long", $4) $1 = 0 $2 = 0 $3 = $l $4 = $pos[3] $ret2 = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", $1, "long", $2, "long", $3, "long", $4) $1 = $l + $w $2 = 0 $3 = $pos[2] $4 = $pos[3] $ret3 = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", $1, "long", $2, "long", $3, "long", $4) $1 = 0 $2 = $t + $h $3 = $pos[2] $4 = $pos[3] $ret4 = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", $1, "long", $2, "long", $3, "long", $4) DllCall("gdi32.dll", "long", "CombineRgn", "long", $ret[0], "long", $ret[0], "long", $ret2[0], "int", 2) DllCall("gdi32.dll", "long", "CombineRgn", "long", $ret[0], "long", $ret[0], "long", $ret3[0], "int", 2) DllCall("gdi32.dll", "long", "CombineRgn", "long", $ret[0], "long", $ret[0], "long", $ret4[0], "int", 2) DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $hwnd, "long", $ret[0], "int", 1) EndFunc ;==>_GUICreateInvRect Func _end() Exit (0) EndFunc ;==>_end Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times
Richard Robertson Posted January 30, 2008 Posted January 30, 2008 The window moves because instead of it being screen coordinates, it gets copied to child coordinates instead of translating to child coordinates.
Xenobiologist Posted January 30, 2008 Posted January 30, 2008 The window moves because instead of it being screen coordinates, it gets copied to child coordinates instead of translating to child coordinates.Hmmh, it does look strange, doesn't it? The GUI is also not shown. Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times
BrettF Posted January 31, 2008 Posted January 31, 2008 _WinAPI_ScreenToClient / _WinAPI_ClientToScreen... _WinAPI_RedrawWindow maybe... Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version!
qsek Posted August 9, 2009 Posted August 9, 2009 I did not tested the above scripts but mine is working like a charm. Setting WS_EX_MDICHILD to the external windows followed by _WinAPI_SetParent will do the trick. expandcollapse popup#include <Constants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Include <WinAPI.au3> Opt("GUIOnEventMode", 1) $GUI = GUICreate("Audio Setup (Virtual Audio Cable) - Qsek", 1020, 484, 1282, 300, BitOR($WS_MINIMIZEBOX,$WS_SYSMENU,$WS_CAPTION,$WS_CLIPCHILDREN,$WS_POPUP,$WS_POPUPWINDOW,$WS_GROUP,$WS_BORDER,$WS_CLIPSIBLINGS)) GUISetState(@SW_SHOW) GUISetOnEvent($GUI_EVENT_CLOSE, "Close") $PID_AR1 = Run(@WindowsDir & '\notepad.exe') ; Mic(Soundcard) --> VirtualCable 1 Sleep(100) $PID_AR2 = Run(@WindowsDir & '\notepad.exe') ; SBM(VirtualCable 2) --> VirtualCable 1 Sleep(100) $PID_AR3 = Run(@WindowsDir & '\notepad.exe') ; SBM(VirtualCable 2) --> Soundcard $AR1 = _GetHwndFromPID($PID_AR1) $AR2 = _GetHwndFromPID($PID_AR2) $AR3 = _GetHwndFromPID($PID_AR3) WinSetTitle($AR1,"","Mic(Soundcard) --> VirtualCable 1") WinSetTitle($AR2,"","SBM(VirtualCable 2) --> VirtualCable 1") WinSetTitle($AR3,"","SBM(VirtualCable 2) --> Soundcard") _WinAPI_SetWindowLong($AR1, $GWL_EXSTYLE , $WS_EX_MDICHILD) _WinAPI_SetParent($AR1,$GUI) _WinAPI_SetWindowLong($AR2, $GWL_EXSTYLE , $WS_EX_MDICHILD) _WinAPI_SetParent($AR2,$GUI) _WinAPI_SetWindowLong($AR3, $GWL_EXSTYLE , $WS_EX_MDICHILD) _WinAPI_SetParent($AR3,$GUI) WinMove($AR1,"",0 ,0,340,300) WinMove($AR2,"",340 ,0,340,300) WinMove($AR3,"",340+340 ,0,340,300) Sleep(100) ;~ WinSetState($AR1,"",@SW_MINIMIZE) ;~ WinSetState($AR2,"",@SW_MINIMIZE) ;~ WinSetState($AR3,"",@SW_MINIMIZE) While 1 Sleep(10) WEnd 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 Func Close() Exit EndFunc Teamspeak 3 User Viewer - Quick and functional TS3 Query script, which shows online users.Cached Screenshot Deleter - Deletes older Fraps Screenshots if they exceed a specified limit.Unresolved Topics:Intercept and modify dragdrop text behaviour in scite
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now