Leo1906

Clip GUIs together and move simultanioulsy

4 posts in this topic

#1 ·  Posted (edited)

Hey guys, I could need your help aggain ..

Is there a way to clip GUIs together (child GUIs - in one script). So if I use WinMove with speed set to one of those GUIs, the others follow at the same speed like they where one block?
I can't think of an option to do this in pure Autoit. Creating an adlib for each GUI won't help I'm afraid, because adlibs are paused on GUI-move?

And using this type of function didn't help either: 

I can't imagine any other way of achieving multiple GUI moves at once using Autoit, because Autoit waits for the WinMove command to finish ..

Any thoughts? Maybe a build in windows function for clipping GUIs together?

 

Thanks for your help :)

Edited by Leo1906

Share this post


Link to post
Share on other sites



@Leo1906 I use something like this in one of my larger scripts for pop out messages, to ensure they keep pace with the main GUI. May translate to what you are trying to accomplish:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Local $hGUI_Child
$hGUI_Main = GUICreate("Test", 300, 300)
    _Create_Child($hGUI_Main)
    GUIRegisterMsg($WM_MOVE, "_Position_Child")
    GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY")
    GUISetState(@SW_SHOW, $hGUI_Main)
    $btnGo = GUICtrlCreateButton("Show Child", 220, 250, 70, 40)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                Exit
            Case $btnGo
                _SH_Child($hGUI_Main, "Secondary Pop Up That Follows Main", 10000)
        EndSwitch
    WEnd


Func _Create_Child($hGUI_Main)
    Local $lnCount = 100
    $hGUI_Child = GUICreate("Follower", 400, $lnCount, -1, -1, BitOR($WS_POPUP, $WS_BORDER), 0, $hGUI_Main)
    GUISetBkColor(0xCCFFCC)
    GUISetFont(11, 400, Default, "Arial")
    Global $text = GUICtrlCreateLabel("", 10, 10, 380, ($lnCount * 20) - 20)
    _Position_Child($hGUI_Main, 0, 0, 0)
    GUISetState(@SW_HIDE, $hGUI_Child)
EndFunc   ;==>_Create_Child

Func _Position_Child($hGUI_Main, $iMsg, $wParam, $lParam)
    Local $aGUI_Main_Pos = WinGetPos($hGUI_Main)
    WinMove($hGUI_Child, "", $aGUI_Main_Pos[0] + $aGUI_Main_Pos[2], $aGUI_Main_Pos[1])
EndFunc   ;==>_Position_Child

Func _SH_Child($hGUI_Main, $sText, $sLength)
    GUISetState(@SW_SHOW, $hGUI_Child)
    GUICtrlSetData($text, $sText)
    WinActivate($hGUI_Main)
    Sleep($sLength)
    GUISetState(@SW_HIDE, $hGUI_Child)
    GUICtrlSetData($text, "")
EndFunc   ;==>_SH_Child

Func _WM_NOTIFY($nWnd, $iMsg = "", $wParam = "", $lParam = "")
    Local $tStruct = DllStructCreate("hwnd;uint_ptr;int_ptr;int;int", $lParam)
    If BitAND(DllStructGetData($tStruct, 3), 0xFFFFFFFF) = $NM_CLICK Then ; Code
        $hCurrListView = DllStructGetData($tStruct, 1) ; ListView handle
    EndIf
EndFunc   ;==>_WM_NOTIFY

 

1 person likes this

When you're dead, you don't know you're dead - it's only difficult for those that know you. It's the same way when you're stupid...

My Scripts: SCCM UDFInclude Source with Compiled Script, Windows Firewall UDF

Share this post


Link to post
Share on other sites

Unfortunately this doesn't help. I came up with another idea.
I want to create my child guis inside the parent gui and make the parent gui transparent. Then I can move the parent GUI and the child GUIs move with it at the same time. So far my thougts.
Here an example code:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinApi.au3>

HotKeySet("^w", "_test") ; ctrl + w

Const $SC_MOVE = 0xF010
Global $hChild, $bChildMax = False

$hMain = GUICreate("Parent", 500, 500, -1, -1, $WS_POPUP, BitOR($WS_EX_LAYERED,$WS_EX_TOOLWINDOW,$WS_EX_TOPMOST,$WS_EX_LAYERED))
_WinAPI_SetLayeredWindowAttributes($hMain, 0xABCDEF, 255)
GUISetBkColor(0xABCDEF)
GUISetState(@SW_SHOW)

$hChild = GUICreate("Child", 300, 300, 10, 0, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX))
$button1 = GUICtrlCreateButton("Test", 50, 50, 50, 40)
_WinAPI_SetParent($hChild, $hMain)
GUISetState()

GUIRegisterMsg($WM_SYSCOMMAND, "On_WM_SYSCOMMAND")

While 1
    $aMsg = GUIGetMsg(1)
    Switch $aMsg[1]
        Case $hMain
            Switch $aMsg[0]
                Case $GUI_EVENT_CLOSE
                    Exit
            EndSwitch

        Case Else
            Switch $aMsg[0]
                Case $button1
                    WinMove($hMain, "", 1000, 500, 500, 500, 10)
                Case $GUI_EVENT_CLOSE
                    ; Activate menu
                    GUICtrlSetState($mChild, $GUI_ENABLE)
                    ; Clear the Maximised flag
                    $bChildMax = False
                    ; Delete child
                    GUIDelete($hChild)
                Case $GUI_EVENT_MAXIMIZE
                    ; Set the Maximised flag
                    $bChildMax = True
                Case $GUI_EVENT_MINIMIZE
                    ; Clear the Maximised flag
                    $bChildMax = False
                Case $GUI_EVENT_RESTORE
                    ; Clear the Maximised flag
                    $bChildMax = False
            EndSwitch
    EndSwitch
WEnd

Func _test()
    WinMove($hMain, "", 100, 100, 500, 500, 10)
EndFunc

Func On_WM_SYSCOMMAND($hWnd, $Msg, $wParam, $lParam)

    If $hWnd = $hChild Then
        ; Is the child maximised?
        If $bChildMax Then
            ;Is it a MOVE mesage?
            If BitAND($wParam, 0xFFF0) = $SC_MOVE Then Return False
        EndIf
    EndIf

    Return $GUI_RUNDEFMSG
EndFunc   ;==>On_WM_SYSCOMMAND

Works good so far. And having the invisible borders when moving the child GUIs is exactly what I want.
I think I can get this to work just fine, but there is one last thing ..

Why can't I proceed to drag the child GUI after a WinMove was made? I need to get this to work and then all will be fine :D
Any ideas?

Share this post


Link to post
Share on other sites

Ok, solved the problem with dragging the child GUIs after WinMove. The new problem is that it seems like you can't move a child GUI when some transparency is set to it. Is there a way to get around this problem?
Only thing I can imagine is to track the mouse position and when it's over the child GUI, the transparency is removed .. But that's not a very elegant way ...

Try here and press ctrl+w to see what I mean ..

 

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinApi.au3>
#include <SendMessage.au3>
#include <GUIConstantsEx.au3>

HotKeySet("^w", "_test") ; ctrl + w

Global $GUIFADE_MAXTRANS = 255
Const $SC_MOVE = 0xF010
Global $hChild, $bChildMax = False
Global $numberCores = 7
Global $WorkAera = _GetWorkArea()
Global Const $SC_DRAGMOVE = 0xF012

$hMain = GUICreate("Parent", 500, 500, -1, -1, $WS_POPUP, BitOR($WS_EX_LAYERED,$WS_EX_TOOLWINDOW,$WS_EX_TOPMOST,$WS_EX_LAYERED))
_WinAPI_SetLayeredWindowAttributes($hMain, 0xABCDEF, 255)
GUISetBkColor(0xABCDEF)
GUISetState(@SW_SHOW)

$hChild = GUICreate("Child", 300, 300, 10, 0, $WS_POPUP, BitOR($WS_EX_LAYERED,$WS_EX_TOOLWINDOW,$WS_EX_TOPMOST,$WS_EX_LAYERED))
GUISetBkColor(0x919191)
$button1 = GUICtrlCreateButton("Test", 50, 50, 50, 40)
_GuiRoundCorners($hChild, 0, 0, 20, 20)

_WinAPI_SetParent($hChild, $hMain)
WinSetTrans($hChild, "", 240)
GUISetState()

;~ _FadeInGUI($hChild)

;~ GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST")
;~ GUIRegisterMsg($WM_SYSCOMMAND, "On_WM_SYSCOMMAND")



While 1
    $aMsg = GUIGetMsg(1)
    Switch $aMsg[1]
        Case $hMain
            Switch $aMsg[0]
                Case $GUI_EVENT_CLOSE
                    Exit
            EndSwitch

        Case Else
            Switch $aMsg[0]
                Case $GUI_EVENT_PRIMARYDOWN

                    _SendMessage($hChild, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0)
                Case $button1
                    WinMove($hMain, "", 1000, 500, 500, 500, 10)
                Case $GUI_EVENT_CLOSE
                    ; Activate menu
                    GUICtrlSetState($mChild, $GUI_ENABLE)
                    ; Clear the Maximised flag
                    $bChildMax = False
                    ; Delete child
                    GUIDelete($hChild)
                Case $GUI_EVENT_MAXIMIZE
                    ; Set the Maximised flag
                    $bChildMax = True
                Case $GUI_EVENT_MINIMIZE
                    ; Clear the Maximised flag
                    $bChildMax = False
                Case $GUI_EVENT_RESTORE
                    ; Clear the Maximised flag
                    $bChildMax = False
            EndSwitch
    EndSwitch
WEnd

Func _GetWorkArea()
    Local $Area[6]
    Local $StartRect = DllStructCreate("int[4]")
    Local $PStartRect = DllStructGetPtr($StartRect)
    DllCall("user32.dll", "int", "SystemParametersInfo", "int", 48, "int", 0, "ptr", $PStartRect, "int", 0)
    $Area[0] = DllStructGetData($StartRect,1,1)
    $Area[1] = DllStructGetData($StartRect,1,2)
    $Area[2] = DllStructGetData($StartRect,1,3)
    $Area[3] = DllStructGetData($StartRect,1,4)
    $Area[4] = $Area[2] - $Area[0]
    $Area[5] = $Area[3] - $Area[1]
    Return $Area
EndFunc

Func _GuiRoundCorners($h_win, $i_x1, $i_y1, $i_x3, $i_y3)
    Dim $pos, $ret, $ret2
    $pos = WinGetPos($h_win)
    $ret = DllCall("gdi32.dll", "long", "CreateRoundRectRgn", "long", $i_x1, "long", $i_y1, "long", $pos[2], "long", $pos[3], "long", $i_x3, "long", $i_y3)
    If $ret[0] Then
        $ret2 = DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $h_win, "long", $ret[0], "int", 1)
        If $ret2[0] Then
            Return 1
        Else
            Return 0
        EndIf
    Else
        Return 0
    EndIf
EndFunc

Func _test()
;~  WinMove($hMain, "", 100, 100, 500, 500, 10)
WinSetTrans($hChild, "", 255)
EndFunc

Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam)
    If ($iMsg = $WM_NCHITTEST) Then Return $HTCAPTION
EndFunc

Func On_WM_SYSCOMMAND($hWnd, $Msg, $wParam, $lParam)

    If $hWnd = $hChild Then
        ; Is the child maximised?
        If $bChildMax Then
            ;Is it a MOVE mesage?
            If BitAND($wParam, 0xFFF0) = $SC_MOVE Then Return False
        EndIf
    EndIf

    Return $GUI_RUNDEFMSG
EndFunc   ;==>On_WM_SYSCOMMAN



Func _FadeInGUI($hWnd)
    WinSetTrans($hWnd, "", 0)
    GUISetState(@SW_SHOW, $hWnd)
    For $i = 1 To $GUIFADE_MAXTRANS Step 0.05
        WinSetTrans($hWnd, "", $i)
    Next
EndFunc

Func _FadeOutGUI($hWnd)
    For $i = $GUIFADE_MAXTRANS To 0 Step -0.05
        WinSetTrans($hWnd, "", $i)
    Next
    GUISetState(@SW_HIDE, $hWnd)
EndFunc

 

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Similar Content

    • FMS
      Winmove GUI moves buttons
      By FMS
      Hello,
      Below is a code whish i made for this problem i've. (code 1)
      The problem is that iff i try Winmove to to show the hidden button it's not working as i tought.
      What i try to do is just simple expand the GUI to make the hidden button visible. (code 2)
      I've already looked into GUICoordMode but don't think that's the problem.(or I don't understand it properly)
      Also tried to look into the forum but din't find anything around this subject but could't find anything around this subject.
      Does somebody knows what I'm doing wrong?
       
      Code 1 (winmove prblem) :
      #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Form1", 134, 103, 192, 124) $Button1 = GUICtrlCreateButton("1", 8, 8, 75, 25) $Button2 = GUICtrlCreateButton("2", 8, 40, 75, 25) $Button3 = GUICtrlCreateButton("3", 8, 72, 75, 25) $expand_button = GUICtrlCreateButton("EXP", 96, 40, 27, 25) $hidden_button = GUICtrlCreateButton("Hidden", 160, 40, 75, 25) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $expand_button WinMove($Form1, "From1", 192, 124, 300, 103) EndSwitch WEnd  
      Code 2 What I'm trying to expand to :
      #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Form1", 265, 114, 192, 124) $Button1 = GUICtrlCreateButton("1", 8, 8, 75, 25) $Button2 = GUICtrlCreateButton("2", 8, 40, 75, 25) $Button3 = GUICtrlCreateButton("3", 8, 72, 75, 25) $expand_button = GUICtrlCreateButton("EXP", 96, 40, 27, 25) $hidden_button = GUICtrlCreateButton("Hidden", 160, 40, 75, 25) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd  
    • DesireDenied
      WinMove, GUIResize
      By DesireDenied
      Hi all,
      Can anyone tell me please, how to make my GUI stop moving/resizing elements that lays below $hInput (editbox) when I am trying to change the window size?
      The problem is that when I try to initialize my GUI 23px high I dont even get the buttons drawn, and if I try to redraw the window to smaller one, all elements get stuck together.
      All I want to do is to have a simple GUI, initialized with edit box only, and to have a window slowly expand if user type: add %s (command).
      ; INCLUDES #Region - INCLUDES #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Misc.au3> #include <Array.au3> #include <WinAPI.au3> #EndRegion #Region - OPTIONS Opt("GUIOnEventMode", 1) Opt("GUIEventOptions", 1) ;0=default, 1=just notification, 2=GUICtrlRead tab index #endregion #Region - GLOBAL VARIABLES Global Enum $Title, $Handle, $X, $Y, $Width, $Height, $isVisible, $isActive Global Enum $Short, $Long Global Enum $Len=0, $Client, $Order, $Year Global $hGUI Global $AI[7], $HP[8] $AI[$Title] = "Illustrator" $HP[$Title] = "Helper" $HP[$Handle] = $hGUI $HP[$isVisible] = True $HP[$isActive] = True $HP[$Y] = 2 $HP[$Width] = 160 $HP[$Height] = 23 Global $aClient[][] = [ ["SHORT", "LONG"], ["1st", "First client"], ["2nd", "Second client"] ] Global $tAutoExit = TimerInit() #EndRegion #Region - GUI ; GUI INITIALIZATION $hGUI = GUICreate("Helper", 160, 110, Default, 2, $WS_POPUP, BitOR($WS_EX_TOOLWINDOW,$WS_EX_TOPMOST,$WS_EX_TRANSPARENT)) ;~ GUISetBkColor(0x3399FF) $hInput = GUICtrlCreateInput("", 0, 0, 160, 23) GUICtrlSetOnEvent($hInput, "InputHandler") $Button1 = GUICtrlCreateButton("File", 8, 28, 145, 22) $Button2 = GUICtrlCreateButton("Folder", 8, 50, 145, 22) $Button3 = GUICtrlCreateButton("Win Search", 8, 72, 145, 22) GUISetState(@SW_SHOW) Sleep(2000) WinMove($HP[$Title], "", Default, Default, Default, 23, 3) #EndRegion GUI #Region - MAIN LOOP While 1 CheckForRequest($HP) AutoExit(10) Sleep(10) WEnd #EndRegion #Region - FUNCTIONS Func AutoExit($iSeconds) If TimerDiff($tAutoExit) > $iSeconds*1000 Then Exit EndFunc Func CheckForRequest($vObject) If $vObject[$isActive] And _IsPressed("1B") Then Fade($HP) If (_IsPressed("12") And _IsPressed("C0")) Then Fade($HP) EndFunc Func InputHandler() Local $sMsg = GUICtrlRead(@GUI_CtrlId) ConsoleWrite("+ Command: " & $sMsg & @CRLF) Switch $sMsg Case "bye" ConsoleWrite("> Exiting... " & @CRLF) Exit Case "ai" ConsoleWrite("> " & $AI[$Title] & @CRLF) Case "hp" ConsoleWrite("> " & $HP[$Title] & @CRLF) Case StringInStr($sMsg, " ") <> False GetArgs($sMsg) Case Else EndSwitch Fade($HP) EndFunc Func GetArgs($sMsg) Local $aMsg = StringSplit($sMsg, " ") Switch $aMsg[0] Case 2 To 3 isClientFolder($aMsg) isNewCommand($aMsg) EndSwitch EndFunc Func isNewCommand($aArgs) If $aArgs < 2 Then Return -1 Switch $aArgs[1] Case "add" CommandAdd($aArgs[2]) Case "del" CommandDel($aArgs[2]) EndSwitch EndFunc Func CommandAdd($vVar) Local $t = 0 ConsoleWrite("-> Adding new command..." & @CRLF) WinMove($HP[$Title], "", Default, Default, Default, 140, 1) GUICtrlSetState($Button1, $GUI_SHOW) While $t < 4 $t += 1 Sleep(1000) WEnd EndFunc Func CommandDel($vVar) ConsoleWrite("-> Removing existing command..." & @CRLF) EndFunc Func isClientFolder($aArgs) Local $aSearch = _ArraySearch($aClient, $aArgs[$Client]) Local $hSearch, $sFileName = "" Local $aOrderNo, $sOrderNo, $sOrderName, $nOrder=1 Local $sPath = "D:\" Local $iYear = "2015" ; Check if user is looking for client folder If $aSearch=-1 Then Return -1 ; Check if user have specified the year If ($aArgs[$Len]=3 And ($aArgs[3]>11 And $aArgs[3]<15)) Then $iYear = "20" & $aArgs[$Year] EndIf ; Set up new working path $sPath &= $iYear & "\" $sPath &= $aClient[$aSearch][$Long] & "\" ; Reorder? $aOrder = StringSplit($aArgs[$Order], ".") $sOrderNo = $iYear ; Deep search Do FileChangeDir($sPath) $sOrderNo &= "."& $aOrder[$nOrder] $hSearch = FileFindFirstFile($sOrderNo &"*") $sFileName = FileFindNextFile($hSearch) FileClose($hSearch) If $sFileName = "" Then Return -1 Else $sPath &= "\" & $sFileName &"\" EndIf $nOrder += 1 Until $nOrder > $aOrder[$Len] ShellExecute($sPath, "", "", "open") EndFunc Func Fade(ByRef $vObject) If $HP[$isVisible] Then For $i=255 To 0 Step -1 WinSetTrans($vObject[$Title], "", $i) If IsInt($i/10) Then Sleep(2) Next GUICtrlSetData($hInput, "") Else For $i=0 To 255 Step 1 WinSetTrans($vObject[$Title], "", $i) If IsInt($i/10) Then Sleep(2) Next EndIf $vObject[$isVisible] = Not $vObject[$isVisible] $vObject[$isActive] = Not $vObject[$isActive] EndFunc #endregion  
    • major4579
      Wordperfect X5 window handle help
      By major4579
      I'm having a problem using winmove with WordPerfect X5.
      WordPerfect X5 is on top and is the active window. I run the following code
      Opt("ExpandVarStrings", 1) $WinTitle = WinGetTitle("[active]") $Err = WinMove ($WinTitle, "", 10, 10) MsgBox (0, 'Move', "$WinTitle$ $Err$") The WordPerfect window does NOT move and the msgbox shows:
      $WinTitle= "WordPerfect X5 - Document 1"
      $Err = 0, which means:  "Failure: 0 if the window is not found."
        Any other program I've tried works fine. I then tried the following:
      Opt("ExpandVarStrings", 1) $WinTitle = WinGetTitle("[active]") $WinHandle = WinGetHandle( $WinTitle) MsgBox (0, 'Handle', "$WinTitle$ $WinHandle$") Again the msgbox showed $WinTitle= "WordPerfect X5 - Document 1"
      $WinHandle = 0
      So I now assume that WordPerfect does NOT respond to the standard windows commands. Any suggestions of a work-around, or am I missing something?
      Thanks,
      Marc
    • caramen
      Cannot hook the windows
      By caramen
      Hello i got trouble when i try to move the CMD windows in the picture attached
      Anyhelp apreciated... not my first winmove...
      *
      Here the used code
      Case $ControlCPL GUISetState(@SW_SHOW, $hGUI2) GUISetState(@SW_HIDE, $hGUI) RunAs ( $UID&"", @ComputerName&"",$Password&"", "" , "C:\Windows\System32\Cmd.exe" ) Sleep (2000) WinMove("Administrateur : C:\Windows\System32\Cmd.exe","",0,0) WinMove("Administrator: C:\Windows\System32\Cmd.exe","",0,0) WinMove("Console ADMIN","",660,0) I got the both language in my PC Park so that's why i use administrator and administrateur line
      It work with administrator but not administrateur....

    • willichan
      WinMove() not moving and resizing with single command
      By willichan
      I am having an interesting problem with WinMove() when moving multiple windows.
      Running this code
      WinMove("Session A - [24 x 80]", "", 170, 80, 735, 413, 1) WinMove("Session B - [24 x 80]", "", 915, 80, 735, 413, 1) WinMove("Session C - [24 x 80]", "", 170, 480, 735, 413, 1) WinMove("Session D - [24 x 80]", "", 915, 480, 735, 413, 1) both moves AND resizes the first window, but only moves the remaining windows without resizing them.
      I tried interjecting a Sleep(100) between each WinMove() call, but no change in behavior.
      However, if I double up the calls,
      Global $a $a = WinMove("Session A - [24 x 80]", "", 170, 80, 735, 413, 1) If $a <> 0 Then WinMove("Session A - [24 x 80]", "", 170, 80, 735, 413, 1) WinMove("Session B - [24 x 80]", "", 915, 80, 735, 413, 1) If $a <> 0 Then WinMove("Session B - [24 x 80]", "", 915, 80, 735, 413, 1) WinMove("Session C - [24 x 80]", "", 170, 480, 735, 413, 1) If $a <> 0 Then WinMove("Session C - [24 x 80]", "", 170, 480, 735, 413, 1) WinMove("Session D - [24 x 80]", "", 915, 480, 735, 413, 1) If $a <> 0 Then WinMove("Session D - [24 x 80]", "", 915, 480, 735, 413, 1) then everything seems to work, but it seems a rather uneligant solution.
      Any thoughts?
      (Using AutoIt 3.3.12.0 on a Win7-64bit machine)