st4vr0s Posted September 14, 2009 Share Posted September 14, 2009 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 More sharing options...
dantay9 Posted September 14, 2009 Share Posted September 14, 2009 WinGetPos() and WinMove() Link to comment Share on other sites More sharing options...
st4vr0s Posted September 14, 2009 Author Share Posted September 14, 2009 I'll be brutally honest. I'm still quite new to autoit and have only written a few scripts that do work 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 More sharing options...
dantay9 Posted September 15, 2009 Share Posted September 15, 2009 (edited) $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 September 15, 2009 by dantay9 Link to comment Share on other sites More sharing options...
DW1 Posted September 15, 2009 Share Posted September 15, 2009 (edited) 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 September 15, 2009 by danwilli AutoIt3 Online Help Link to comment Share on other sites More sharing options...
st4vr0s Posted September 15, 2009 Author Share Posted September 15, 2009 Cheers guys thats much appreciated. Tried Dantay9's script first and worked a treat, just needed to add a WEnd. Will give danwilli's a go next. Many thanks again. Seeing real world examples like this helps me understand how it works Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now