Jump to content

Help on copy status of a window


jony
 Share

Recommended Posts

Hi,

How can I make an application, for example notepad.exe be docked to another program, such as Internet Explorer.exe ? I mean when move Internet Explorer window then move together window of notepad.exe

And when I minimize, maximize or close Internet Explorer then notepad.exe copy the all status of Internet Explorer.

Can I pay by paypal anyone can help me.

Thanks.

Link to comment
Share on other sites

For docking a GUI you can do something like that:

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

Opt("WinTitleMatchMode", 4)

$iWidth = 320
$iHeight = 460

;Create the GUI Window
Global $hMigration = GUICreate("Migration Assistant", $iWidth, $iHeight, Default, Default, $WS_SIZEBOX)
GUICtrlCreateLabel("Folders/Files to Migrate", 10, 10, ($iWidth - 20), 17)
GUICtrlSetResizing(-1, $GUI_DOCKALL)
GUICtrlCreateList("", 10, 35, $iWidth - 20, $iHeight - 60)
GUICtrlSetResizing(-1, $GUI_DOCKBORDERS)
GUISetState ()

;Identify the position of the AutoIT GUI
$WinPos = WinGetPos($hMigration)
Global $x1 = $WinPos[0]
Global $y1 = $WinPos[1]

; Set Explorer GUI coords
Global $x2 = $x1 - $iWidth
Global $y2 = $y1

; Create the Explorer GUI
Global $hExplHolder = GUICreate("Explorer", $iWidth, $iHeight, $x2, $y2, BitOr($GUI_SS_DEFAULT_GUI ,$WS_CLIPCHILDREN, $WS_SIZEBOX))
GUISetState ()

Run("explorer.exe /n, C:\")  ; Set it the folder you want as a start point
WinWait("[CLASS:CabinetWClass]")
Global $hExplorer = WinGetHandle("[CLASS:CabinetWClass]")
_WinAPI_SetParent($hExplorer, $hExplHolder)
WinMove($hExplorer, "", 0, 0, $iWidth, $iHeight)
WinSetState($hExplorer, "", @SW_MAXIMIZE)

;Tell the _KeepWindowsDocked function to perform the initial dock
Global $Dock = 2
;Dock the windows now
_KeepWindowsDocked($hMigration, $hMigration, $hExplHolder, $Dock, $x1, $x2, $y1, $y2)

;Register messages
GUIRegisterMsg($WM_MOVE, "_WinMoved")
GUIRegisterMsg($WM_SIZE, "_WinMoved")

While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then
        Exit
    EndIf

    ; Exit if Explorer window is shut
    If Not WinExists($hExplorer) Then Exit

WEnd

Func _KeepWindowsDocked($hWnd, $GUI1, $GUI2, $Dock, ByRef $x1, ByRef $x2, ByRef $y1, ByRef $y2)

    Local $p_win1 = WinGetPos($GUI1)
    Local $p_win2 = WinGetPos($GUI2)
    ; If Migration is active
    If $hWnd = $GUI1 Then
        ; If Migration has moved or has changed size
        If $p_win1[0] <> $x1 Or $p_win1[1] <> $y1 Or $p_win1[2] <> $p_win2[2] Or $p_win1[3] <> $p_win2[3] Then
            $x1 = $p_win1[0]
            $y1 = $p_win1[1]
            $x2 = $x1 - $p_win1[2]
            $y2 = $y1
            WinMove($GUI2, "", $x2, $y2, $p_win1[2], $p_win1[3])
            WinMove($hExplorer, "", 0,0, $p_win2[2], $p_Win2[3])
        EndIf
    ElseIf $hWnd = $GUI2 Or $Dock = 2 Then
        If $p_win2[0] <> $x2 Or $p_win2[1] <> $y2 Then
            $x2 = $p_win2[0]
            $y2 = $p_win2[1]
            $x1 = $x2 + $p_win1[2]
            $y1 = $y2
            WinMove($GUI1, "", $x1, $y1)
            $Dock = 1
        EndIf
    ElseIf ($p_win1[0] <> $x1 Or $p_win1[1] <> $y1) And BitAND(WinGetState($GUI1), 16) Then
        WinSetState($GUI2, "", @SW_MINIMIZE)
    ElseIf ($p_win2[0] <> $x2 Or $p_win2[1] <> $y2) And BitAND(WinGetState($GUI2), 16) Then
        WinSetState($GUI1, "", @SW_MINIMIZE)
    ElseIf ($p_win1[0] <> $x1 Or $p_win1[1] <> $y1) And BitAND(WinGetState($GUI1), 2) Then
        WinSetState($GUI2, "", @SW_RESTORE)
    ElseIf ($p_win2[0] <> $x2 Or $p_win2[1] <> $y2) And BitAND(WinGetState($GUI2), 2) Then
        WinSetState($GUI1, "", @SW_RESTORE)
    EndIf

EndFunc  ;==>_KeepWindowsDocked

Func _WinMoved($hWndGUI, $MsgID, $wParam, $lParam)

    #forceref $hWndGUI, $MsgID, $wParam, $lParam
    If ($hWndGUI = $hMigration) Or ($hWndGUI = $hExplHolder) Then
        _KeepWindowsDocked($hWndGUI, $hMigration, $hExplHolder, $Dock, $x1, $x2, $y1, $y2)
    EndIf
    Return $GUI_RUNDEFMSG

EndFunc  ;==>_WinMoved

The func _KeepWindowsDocked written by Melba23 do all the work for you ;)

Hi!

My UDF: NetInfo UDF Play with your network, check your download/upload speed and much more! YTAPI Easy to use YouTube API, now you can easy retrive all needed info from a video. NavInfo Check if a specific browser is installed and retrive other usefull information. YWeather Easy to use Yahoo Weather API, now you can easily retrive details about the weather in a specific region. No-IP UDF Easily update your no-ip hostname(s).

My Script: Wallpaper Changer Change you wallpaper dinamically, you can also download your wallpaper from your website and share it with all!   My Snippet: _ImageSaveToBMPConvert an image to bmp format. _SciteGOTO Open a file in SciTE at specific fileline. _FileToHex Show the hex code of a specified file

Link to comment
Share on other sites

Sounds like you need to make a gui, where you have two buttons to somehow cause an action (manually) to get the window handles(primary and secondary), then use WinMove and WinGetState with WinSetState for the min/maximize and movement.

Try it out, post your code, get help where needed.

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.
Link to comment
Share on other sites

Here we don't help other people for money. Just show us some of your code, what are your problem with the code and what do you want exatly do ;)

Hi!

My UDF: NetInfo UDF Play with your network, check your download/upload speed and much more! YTAPI Easy to use YouTube API, now you can easy retrive all needed info from a video. NavInfo Check if a specific browser is installed and retrive other usefull information. YWeather Easy to use Yahoo Weather API, now you can easily retrive details about the weather in a specific region. No-IP UDF Easily update your no-ip hostname(s).

My Script: Wallpaper Changer Change you wallpaper dinamically, you can also download your wallpaper from your website and share it with all!   My Snippet: _ImageSaveToBMPConvert an image to bmp format. _SciteGOTO Open a file in SciTE at specific fileline. _FileToHex Show the hex code of a specified file

Link to comment
Share on other sites

  • Moderators

If you are looking to pay for support, you can try http://www.freelancer.com/ (formerly VWorker.com, formerly Rent-A-Coder). There are many on this site that do AutoIt work. Here in the forum, however, we try to follow the "teach a man to fish" model, for those that want to learn the language, not just complete a single task :)

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Thanks JLogan3o13.

Unfortunately my knowledge is very low in autoit :(

Anyway, I tried to use the code below, but unfortunately does not work all. When I click on any link in IE window, nothing happens (window immediately loses focus).

#include 
#include 
#include 
#include 


Opt("WinTitleMatchMode", 2)

Global $iLast_X, $iLast_Y, $fToolBar_Vis = True, $iX = 360, $iY = 5

Global $sMain_Title = "Notepad"
If Not WinExists($sMain_Title) Then
Run("Notepad.exe")
WinWait($sMain_Title)
EndIf
Global $hApplication_Wnd = WinGetHandle($sMain_Title)
Global $iApplication_PID = WinGetProcess($sMain_Title)

ConsoleWrite($hApplication_Wnd & @CRLF)

Global $hToolBar = GUICreate("ToolBarxx", 590, 530, 10, 10, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS), BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST))
$IE = ObjCreate("Shell.Explorer.2")
$iActiveX = GUICtrlCreateObj($IE,0,0,489,389)
$IE.navigate("http://www.google.com")




GUISetState()

_Toolbar_Follow()

;Register move event
GUIRegisterMsg($WM_MOVE, "MY_WM_MOVE")

While 1

; Check Application is running
If Not ProcessExists($iApplication_PID) Then Exit

; Hide/show toolbar as required
_Toolbar_State()

Local $iMsg = GUIGetMsg()
Switch $iMsg
Case $GUI_EVENT_CLOSE
; Quit
Exit

EndSwitch

WEnd

Func MY_WM_MOVE($hWnd, $iMsg, $wParam, $lParam)
#forceref $hWnd, $iMsg, $wParam, $lParam
If $hWnd = $hToolBar Then
; if toolbar moved set new relative position
Local $aApplication_Pos = WinGetPos($hApplication_Wnd)
Local $aToolBarPos = WinGetPos($hToolBar)
$iX = Abs($aApplication_Pos[0] - $aToolBarPos[0])
$iY = Abs($aApplication_Pos[1] - $aToolBarPos[1])
EndIf
Return $GUI_RUNDEFMSG
EndFunc ;==>MY_WM_MOVE

Func _Toolbar_Follow()

Local $aApplication_Pos = WinGetPos($hApplication_Wnd)
If $aApplication_Pos[0] <> $iLast_X Or $aApplication_Pos[1] <> $iLast_Y Then
$iLast_X = $aApplication_Pos[0]
$iLast_Y = $aApplication_Pos[1]
WinMove($hToolBar, '', $aApplication_Pos[0] + $iX, $aApplication_Pos[1] + $iY)
EndIf

EndFunc ;==>_Toolbar_Follow

Func _Toolbar_State()

; If Application minimised, then hide toolbar and do nothing
If BitAND(WinGetState($hApplication_Wnd), 16) = 16 Then
GUISetState(@SW_HIDE, $hToolBar)
$fToolBar_Vis = False
; If Application not minimised
Else
; Hide ToolBar when Application not active
If BitAND(WinGetState($hApplication_Wnd), 8) <> 8 And $fToolBar_Vis = True Then
GUISetState(@SW_HIDE, $hToolBar)
$fToolBar_Vis = False
ElseIf BitAND(WinGetState($hApplication_Wnd), 8) = 8 And $fToolBar_Vis = False Then
GUISetState(@SW_SHOW, $hToolBar)
WinActivate($hApplication_Wnd)
$fToolBar_Vis = True
EndIf
; If visible check toolbar position
If $fToolBar_Vis = True Then _Toolbar_Follow()
EndIf

EndFunc ;==>_Toolbar_State
Link to comment
Share on other sites

Simple example...Not real time movement (would have to do something with mousedown/mouseup...done)

This requires 2 Notepad's to be open, one with Document name = Test1.txt, other with Document name = Test2.txt

Use the helpfile to get what the functions are doing (F1)

Also, this is not a true 'dock'...mostly debugged, except when maximized

#include <Misc.au3>
; $sDocArea = "Bottom" ; currently only doc to bottom
$iSecWindowHeight = "200"
$hPriWin = WinGetHandle("test1")
$hSecWin = WinGetHandle("test2")
$aPriPos = WinGetPos($hPriWin)
$aSecPos = WinGetPos($hSecWin)
WinMove($hSecWin, "", $aPriPos[0],$aPriPos[1]+$aPriPos[3], $aPriPos[2], $iSecWindowHeight)
While 1
 If Not WinExists($hPriWin) Or Not WinExists($hSecWin) Then ExitLoop
 If Not _IsPressed (Hex(01)) Then
  Sleep (50)
  If Not WinExists($hPriWin) Or Not WinExists($hSecWin) Then ExitLoop
  $aNewPriPos = WinGetPos($hPriWin)
  If $aPriPos[0]<>$aNewPriPos[0] Or $aPriPos[1]<>$aNewPriPos[1] Or $aPriPos[2]<>$aNewPriPos[2] Or $aPriPos[3]<>$aNewPriPos[3] Then
   $aPriPos = $aNewPriPos
   If BitAND(WinGetState($hPriWin),16) Then
    WinSetState($hSecWin,"",@SW_MINIMIZE)
   ElseIf BitAND(WinGetState($hPriWin),32) Then
    WinSetState($hSecWin,"",@SW_RESTORE)
    WinMove($hSecWin, "", $aPriPos[0],$aPriPos[1]+$aPriPos[3], $aPriPos[2], $iSecWindowHeight)
    WinActivate($hSecWin)
   Else
    WinMove($hSecWin, "", $aPriPos[0],$aPriPos[1]+$aPriPos[3], $aPriPos[2], $iSecWindowHeight)
    WinActivate($hSecWin)
   EndIf
  EndIf
 EndIf
;~  Sleep (2000)
WEnd
Edited 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.
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...