johnmcloud Posted July 25, 2012 Posted July 25, 2012 (edited) Hi guys, check it out this: #include <GuiConstants.au3> #include <WindowsConstants.au3> $Main_GUI = GUICreate("Main", 500, 500) GUISetState(@SW_SHOW, $Main_GUI) $Child_GUI = GUICreate("Child", 200, 100, 10, 50) GUISetState(@SW_SHOW, $Child_GUI) DllCall("user32.dll", "int", "SetParent", "hwnd", $Child_GUI, "hwnd", $Main_GUI) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd I want to do the exact opposite, i'd like to have the Main_GUI always on focus and the $Child_GUI always without focus also if you click on it. And now you need to close the Child for close the Main So, everything in this script is the opposite of the result i want to do. Where i'm doing wrong? Thanks for help Edited July 27, 2012 by johnmcloud
water Posted July 25, 2012 Posted July 25, 2012 You can find a very good tutorial about how to work with two GUIs in the wiki. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
johnmcloud Posted July 25, 2012 Author Posted July 25, 2012 I have read that, but i don't see anything about Parent/Child gui, and my focus problem
jdelaney Posted July 25, 2012 Posted July 25, 2012 GUICreate ( "title" [, width [, height [, left [, top [, style [, exStyle [, parent]]]]]]] ) IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
johnmcloud Posted July 25, 2012 Author Posted July 25, 2012 I have make the DllCall for set the child-parent, why i need to set it again in GuiCreate? Also my Gui is in another Gui without using WinGetPos, my problem is the inverted close/focus of the child instead of the main. Please provide an example script like mine if possible. Thanks to all
jdelaney Posted July 25, 2012 Posted July 25, 2012 #include <GuiConstants.au3> #include <WindowsConstants.au3> $Main_GUI = GUICreate("Main", 500, 500) GUISetState(@SW_SHOW, $Main_GUI) $Child_GUI = GUICreate("Child", 200, 100, 10, 50, -1, -1, $Main_GUI) GUISetState(@SW_SHOW, $Child_GUI) While 1 $aMessage = GUIGetMsg(1) If $aMessage[0] = $GUI_EVENT_CLOSE And $aMessage[1] = $Main_GUI Then Exit EndIf If $aMessage[0] = $GUI_EVENT_CLOSE And $aMessage[1] = $Child_GUI Then GUIDelete ( $Child_GUI ) EndIf WEnd IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
bogQ Posted July 25, 2012 Posted July 25, 2012 (edited) and the $Child_GUI always without focus also if you click on it this is 100% ilogical, you cant have win with no focus even if you click on it and expect it to close when you click X on it! they only thing you can do is disable that win so that he dont get any focus or input at all and close it with other win (or i totaly did not understand the problem) Edited July 25, 2012 by bogQ TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) There are those that believe that the perfect heist lies in the preparation.Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.
jdelaney Posted July 25, 2012 Posted July 25, 2012 (edited) #include <GuiConstants.au3> #include <WindowsConstants.au3> $Main_GUI = GUICreate("Main", 500, 500) GUISetState(@SW_SHOW, $Main_GUI) GuiSetState ( @SW_DISABLE, $Main_GUI ) $Child_GUI = GUICreate("Child", 200, 100, 10, 50, -1, -1, $Main_GUI) GUISetState(@SW_SHOW, $Child_GUI) While 1 $aMessage = GUIGetMsg(1) If $aMessage[0] = $GUI_EVENT_CLOSE And $aMessage[1] = $Main_GUI Then Exit EndIf If $aMessage[0] = $GUI_EVENT_CLOSE And $aMessage[1] = $Child_GUI Then GUIDelete ( $Child_GUI ) GuiSetState ( @SW_ENABLE, $Main_GUI ) EndIf WEnd Edited July 25, 2012 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
johnmcloud Posted July 25, 2012 Author Posted July 25, 2012 @bogQ It's possible, i'm sure at 100%. The Main GUI is always focused also if you click-move on the child gui, and the child gui don't have focus, never, but you can move-click like a normal gui. If you move the Main Gui the child gui follow it, the child gui is inside the main gui and can't go outside, but can be minimized,maximized and closed. Close the main gui close also the child. I don't know if i can post binary of other language, but i have see this with my eyes, i have here on my pc. Make a gui like that can be really useful imho. @jdelaney I'll test it soon, now i afk but thanks.
bogQ Posted July 25, 2012 Posted July 25, 2012 (edited) something like this? #include <GuiConstants.au3> #include <WindowsConstants.au3> $Main_GUI = GUICreate("Main", 500, 500) GUISetState(@SW_SHOW, $Main_GUI) $Child_GUI = GUICreate("Child", 200, 100, 10, 50, $WS_CHILD + $WS_CAPTION +$WS_SYSMENU, Default, $Main_GUI) GUICtrlCreateButton('SecondguiButton', 0, 0) GUISetState(@SW_SHOW, $Child_GUI) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd edit: if its something like that, than i still do think that you did switch the word "focus" for something else on your mind and added the wrong meaning to it. No focus = no interaction. Blue line on top of win isnt applicable indicator. Edited July 25, 2012 by bogQ TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) There are those that believe that the perfect heist lies in the preparation.Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.
jdelaney Posted July 25, 2012 Posted July 25, 2012 (edited) this one is pretty cool, you can minimize/maximize within the parent window: #include <GuiConstants.au3> #include <WindowsConstants.au3> $Main_GUI = GUICreate("Main", 500, 500) GUISetState(@SW_SHOW, $Main_GUI) $Child_GUI = GUICreate("Child", 200, 100, 10, 50, bitor( $WS_OVERLAPPEDWINDOW,$WS_CHILD , $WS_CAPTION ,$WS_SYSMENU),-1 , $Main_GUI) GUICtrlCreateButton('SecondguiButton', 0, 0) GUISetState(@SW_SHOW, $Child_GUI) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd also, for the closing issue, you need to use the while loop like I posted above Edited July 25, 2012 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
AZJIO Posted July 25, 2012 Posted July 25, 2012 bogQbased on your#include <GuiConstants.au3> #include <WindowsConstants.au3> Opt("GUIOnEventMode", 1) $Main_GUI = GUICreate("Main", 500, 500) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") GUISetState(@SW_SHOW, $Main_GUI) $Child_GUI = GUICreate("Child", 200, 100, 10, 50, BitOr($WS_CHILD, $WS_OVERLAPPEDWINDOW), Default, $Main_GUI) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") GUICtrlCreateButton('SecondguiButton', 0, 0) GUISetState(@SW_SHOW, $Child_GUI) While 1 Sleep(1000) WEnd Func _Exit() Switch @GUI_WinHandle Case $Main_GUI Exit Case $Child_GUI GUIDelete($Child_GUI) EndSwitch EndFuncanother option#include <WindowsConstants.au3> #include <GUIConstantsEx.au3> Opt("GUIOnEventMode", 1) $Main_GUI = GUICreate("Main", 500, 500, -1, -1) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") GUISetState() $Child_GUI = GUICreate("Child", 200, 100, 10, 50, $GUI_SS_DEFAULT_GUI, $WS_EX_MDICHILD, $Main_GUI) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") $iButton = GUICtrlCreateButton('Start', 10, 10, 120, 22) GUISetState(@SW_SHOW, $Child_GUI) WinActivate($Main_GUI) GUISwitch($Main_GUI) While 1 Sleep(1000) WEnd Func _Exit() Switch @GUI_WinHandle Case $Main_GUI Exit Case $Child_GUI GUIDelete($Child_GUI) EndSwitch EndFunc My other projects or all
johnmcloud Posted July 26, 2012 Author Posted July 26, 2012 (edited) Nice example, thanks I'm trying, using the same method, to make a floating GUI inside another software ( like Photoshop panel for make an idea )expandcollapse popup#include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <Constants.au3> #include <WinAPI.au3> HotKeySet("{ESC}", "Close") $PID = Run(@WindowsDir & 'notepad.exe') $PARENT = _GetHwndFromPID($PID) $CHILD = GUICreate("GUI Inside Notepad", 400, 400, 0, 0, $WS_OVERLAPPEDWINDOW, $WS_EX_COMPOSITED) _WinAPI_SetParent($CHILD, $PARENT) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE ExitLoop EndSwitch If Not ProcessExists("notepad.exe") Then Exit EndIf Sleep(100) 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 ;==>CloseMain problems are:1) Move autoit GUI is little flickering, don't know how to update it2) If i click on Notepad the gui disappearFor the second point:http://msdn.microsoft.com/en-us/library/windows/desktop/ms633541(v=vs.85).aspxI don't understand the Remarks part about WS_POPUP style and the WS_CHILD, this part:Therefore, if [i]hWndNewParent[/i] is [b]NULL[/b], you should also clear the [b]WS_CHILD[/b] bit and set the [b]WS_POPUP[/b] style after calling [b]SetParent[/b]Thanks for any help EDIT: I think this post can be useful: Edited July 27, 2012 by johnmcloud
johnmcloud Posted July 26, 2012 Author Posted July 26, 2012 I really don't understand the problem: #include <WindowsConstants.au3> #include <Constants.au3> #include <WinAPI.au3> $PARENT = GUICreate("Parent", 400, 300, 100, 100) GUISetState(@SW_SHOW, $PARENT) $CHILD = GUICreate("Child", 200, 100, 200, 200) GUISetState(@SW_SHOW, $CHILD) DllCall("user32.dll", "long", "SetWindowLong", "hwnd", $CHILD, "int", -16, "long", $WS_POPUP) DllCall("user32.dll", "int", "SetParent", "hwnd", $CHILD, "hwnd", $PARENT) DllCall("user32.dll", "long", "SetWindowLong", "hwnd", $CHILD, "int", -16, "long", $WS_CHILD) ;~ _WinAPI_SetWindowLong($CHILD, $GWL_STYLE, $WS_POPUP) ;~ _WinAPI_SetParent($CHILD, $PARENT) ;~ _WinAPI_SetWindowLong($CHILD, $GWL_STYLE, $WS_CHILD) While 1 Sleep(100) WEnd I have do what the MSDN say, but i can't move the child gui... Try it with DllCall and WinApi, same result... Need a help here
bogQ Posted July 26, 2012 Posted July 26, 2012 (edited) for notepad problem the answer is probably betwean lines...The new parent window and the child window must belong to the same application. Edited July 26, 2012 by bogQ TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) There are those that believe that the perfect heist lies in the preparation.Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.
johnmcloud Posted July 26, 2012 Author Posted July 26, 2012 Do you mean the flickering or the gui disappear? For the flickering, i rebember to see a WinApi function for redraw the GUI, the problem is remember the name and how to apply. For the gui disapper, it's only a child not correct configuration, because the child remove the focus for the parent ( the msdn say i can create a child gui and when i click on it, it don't take the focus from the main gui. I have post an example script with 2 ie in one autoit gui, when you click on ie the main gui don't lose focus ) Anyway, not work also with 2 autoit gui, but i don't understand the problem...
johnmcloud Posted July 27, 2012 Author Posted July 27, 2012 (edited) I have found a solution for the flickering problem for the autoit gui on notepad, add this 2 Style to the child autoit gui: $GUI = GUICreate("GUI Inside Notepad", 400, 400, 0, 0, $WS_OVERLAPPEDWINDOW, $WS_EX_COMPOSITED) 1 problem solved, 1 to go ( p.s. child correct configuration, avoid parent from losing focus for 2 autoit GUI ) I have never seen a GUI like this ( except for the example posted above #13 ) so i think this was an intresting stuff...but i'm wrong Where are all MPVs and expert of this forum, on vacation? Lucky they EDIT: Update post #13 script with no flickering problem Edited July 27, 2012 by johnmcloud
johnmcloud Posted July 28, 2012 Author Posted July 28, 2012 I'm in a dead end, wainting for someone more expert then me
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