Jump to content

If window moves move it back


st4vr0s
 Share

Recommended Posts

Hi,

I have a dual monitor setup.

Left screen is main window, right screen has a stats window of my pc.

Whenever I play a game at the monitors non-native resolution the stats box on the right screen moves over to the right and I cant read half the info.

I want to write a script that runs at start up that will check to see if my stats window is in a certain position in relation to the screen. If it moves it moves it back straight away then when I quit gaming and return to the desktop back at native res it moves it back.

In other words I need a script that always checks to see if a window is always at a certain position.

I'm running into a brick wall here, can anyone help?

Thanks

Link to comment
Share on other sites

I'll be brutally honest. I'm still quite new to autoit and have only written a few scripts that do work :D

Could anyone write be a brief script to say for example move ("Untitled - Notepad") then check to see if its moved and move back, needs to be in a loop forever checking to see if windows moved.

I'm sure I can modify it to suit.

Thanks again

Link to comment
Share on other sites

$XValue = 50 ;this is the x value that the window should be located at
$YValue = 100 ;this is the y value that the window should be located at 

;Loop
While 1

;Make sure the window exists
If WinExists("Untitled - Notepad") Then

;Find the position of the window
$Position = WinGetPos("Untitled - Notepad")

;Find out if window is in that position
If $Position[0] <> $XValue Then WinMove("Untitled - Notepad", "", $XValue, Default)
If $Position[1] <> $YValue Then WinMove("Untitled - Notepad", "", Default, $YValue)

EndIf

Sleep(250) ;save the cpu a few cycles

WEnd

This code is untested, but should work.

Edited by dantay9
Link to comment
Share on other sites

Because I was bored.

Global $title = "Untitled - Notepad"
While 1
    If WinExists($title) Then
        $whnd = WinGetHandle($title)
        $pos = WinGetPos($whnd)
        While WinExists($title)
            $currpos = WinGetPos($whnd)
            For $a = 0 To 3
                If $pos[$a] <> $currpos[$a] Then
                    WinMove( $whnd, '', $pos[0], $pos[1], $pos[2], $pos[3])
                EndIf
            Next
            Sleep(10)
        WEnd
    EndIf
    Sleep(10)
WEnd

EDIT: Ooops, sorry dantay9, didn't see your post while I was replying.

Edited by danwilli
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...