Jump to content

Event on Window Move


Recommended Posts

Were all familiar with the windows error post-65393-0-33815300-1311390451_thumb.j

So I want to Emulate that with auto it, so everytime you move the window it would make another window where is was 20 pixels ago, so is there a GUIRegisterMsg or something like that that keeps track of the Window'sPOS. Any maybe a way to recreate window too? I don't know where to start

Link to comment
Share on other sites

the window moving part isn't that hard.

$pos = WinGetPos("Untitled - Notepad")

While 1
    $pos2 = WinGetPos("Untitled - Notepad")
    If $pos[0] <> $pos2[0] And $pos[1] <> $pos2[1] Then
        ;commands here
    EndIf
WEnd

example:

$pos = WinGetPos("Untitled - Notepad")

While 1
    $pos2 = WinGetPos("Untitled - Notepad")
    If $pos[0] <> $pos2[0] And $pos[1] <> $pos2[1] Then
        ConsoleWrite($pos[0] & "=" & $pos2[0] & ";" & $pos[1] & "=" & $pos2[1] & @CRLF)
        $pos = WinGetPos("Untitled - Notepad")
    EndIf
WEnd

the hard part in my opinion is the 20 pixels and the acitual function to make another window. i would say in the commands put a guicreate with the cords of the original $pos and then make $pos have the same value as the new location, then it should repeat. but creating so many gui's might crash your computer if they get outta hand.

Edited by pieeater

[spoiler]My UDFs: Login UDF[/spoiler]

Link to comment
Share on other sites

Something like this ?

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

$_Gui = GUICreate ( "", 350, 150, Default, Default, Default, $WS_EX_TOPMOST )
GUISetState ( )
GUIRegisterMsg ( $WM_MOVE, "_WM_MOVE" )

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Func _WM_MOVE ( $hWnd, $Msg, $wParam, $lParam )
    $_WinPos = WinGetPos ( $_Gui )
    $_Gui2 = GUICreate ( "", 200, 100, $_WinPos[0]-20, $_WinPos[1]-20 )
    GUISetState ( )
    Return $GUI_RUNDEFMSG
EndFunc ;==> _WM_COMMAND ( )

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

So I got stuck... every new notepad I make has the same name so... how would I do this diffently?

FileWrite("notepad.bat", "start notepad.exe")
Sleep(1000)
ShellExecute(@ScriptDir&"\notepad.bat")
Sleep(1000)

$pos = WinGetPos("Untitled - Notepad")

While 1
    $pos2 = WinGetPos("Untitled - Notepad")
    If $pos[0] <> $pos2[0] And $pos[1] <> $pos2[1] Then
        ConsoleWrite($pos[0] & "=" & $pos2[0] & ";" & $pos[1] & "=" & $pos2[1] & @CRLF)
        makenew()
        $pos = WinGetPos("Untitled - Notepad")
    EndIf
WEnd

FileDelete(@ScriptDir&"\notepad.bat")

Func makenew()
    ShellExecute(@ScriptDir&"\notepad.bat")
    WinMove("Untitled - Notepad", -1, $pos2[0], $pos2[1])
EndFunc
Link to comment
Share on other sites

What's wrong with this script

MsgBox(0, "Troll", "Lol")

$pos = WinGetPos("Troll")
$t = 0

While 1
    $pos2 = WinGetPos("Troll")
    If $pos[0] <> $pos2[0] And $pos[1] <> $pos2[1] Then
        makenew()
        $pos = WinGetPos("Troll")
    EndIf
WEnd

Func makenew()
    $t = $t + 1
    MsgBox(0, "Troll" & $t, "Lol")
    WinMove("Troll" & $t, -1, $pos2[0], $pos2[1])
EndFunc
Link to comment
Share on other sites

Something like this ?

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

$_Gui = GUICreate ( "", 350, 150, Default, Default, Default, $WS_EX_TOPMOST )
GUISetState ( )
GUIRegisterMsg ( $WM_MOVE, "_WM_MOVE" )

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Func _WM_MOVE ( $hWnd, $Msg, $wParam, $lParam )
    $_WinPos = WinGetPos ( $_Gui )
    $_Gui2 = GUICreate ( "", 200, 100, $_WinPos[0]-20, $_WinPos[1]-20 )
    GUISetState ( )
    Return $GUI_RUNDEFMSG
EndFunc ;==> _WM_COMMAND ( )

Dude thanks, total lol time over here
Link to comment
Share on other sites

Is it possible to get rid of the taskbar notification for when it is up I tryed the whole toolwindow thing and it didn't work.

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

$_Gui = GUICreate ( "", 200, 100, Default, Default, Default, BitOR($WS_EX_TOPMOST,$WS_EX_TOOLWINDOW) )
GUISetState ( )
GUIRegisterMsg ( $WM_MOVE, "_WM_MOVE" )

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Func _WM_MOVE ( $hWnd, $Msg, $wParam, $lParam )
    $_WinPos = WinGetPos ( $_Gui )
    $_Gui2 = GUICreate ( "", 200, 100, $_WinPos[0], $_WinPos[1] )
    GUISetState ( )
    Return $GUI_RUNDEFMSG
EndFunc ;==> _WM_COMMAND ( )
Link to comment
Share on other sites

Is it possible to get rid of the taskbar notification for when it is up I tryed the whole toolwindow thing and it didn't work.

Try

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

$_Gui = GUICreate ( "", 200, 100, Default, Default, Default, $WS_EX_TOPMOST )
GUISetState ( )
GUIRegisterMsg ( $WM_MOVE, "_WM_MOVE" )

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Func _WM_MOVE ( $hWnd, $Msg, $wParam, $lParam )
    $_WinPos = WinGetPos ( $_Gui )
    $_Gui2 = GUICreate ( "", 200, 100, $_WinPos[0], $_WinPos[1], Default, Default, WinGetHandle ( AutoItWinGetTitle ( ) ) )
    GUISetState ( )
    Return $GUI_RUNDEFMSG
EndFunc ;==> _WM_COMMAND ( )

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

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...