Sign in to follow this  
Followers 0
DarkBoost

Move GUI when another GUI Moves

3 posts in this topic

Hi... looking for a quick solution, how can I get the RegisterMsg function to initiate when the Calculator moves?

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

Global $title = "child"
Global $exe = "calc.exe"
Global $width = 200
Global $height = 200

ShellExecute($exe)
ProcessWait($exe)

GUICreate($title, $width, $height)
GUISetState()
GUIRegisterMsg($WM_MOVE, "_move")

While 1
    Dim $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            If ProcessExists($exe) Then ProcessClose($exe)
            Exit

    EndSelect
WEnd

Func _move()
    Local $wintitle = WinGetTitle("[CLASS:CalcFrame]", "")
    Local $winpos = WinGetPos($wintitle)

    WinMove($title, "", $winpos[0] + $winpos[2], $winpos[1], $width, $winpos[3])
EndFunc ;=> Function: reposition child window

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Try this way:

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

Global $title = "child"
Global $exe = "calc.exe"
Global $width = 200
Global $height = 200
Global $msg

$run = Run($exe)
ProcessWait($run)

GUICreate($title, $width, $height)
GUISetState()

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            If ProcessExists($exe) Then ProcessClose($exe)
            GUIDelete()
            Exit
    EndSelect
    If Not ProcessExists($exe) Then Exit GUIDelete()
    $wintitle = WinGetTitle("[CLASS:CalcFrame]", "")
    $winpos = WinGetPos($wintitle)
    WinMove($title, "", $winpos[0] + $winpos[2], $winpos[1], $width, $winpos[3])
WEnd

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

this works well, thanks for the quick response!

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
Sign in to follow this  
Followers 0