Cyote101 Posted March 23, 2008 Share Posted March 23, 2008 Hello, Well here is one for those Geniuses out there. I have a border less window 400x328 that i would like centered to a Vertical line in a window "MPLAYER" The line color is 0xC0C0C0 and is about 591 pixels tall, there are other lines in the window, but this one is the closest to the center of the window. I would like the border less window centered -40 pixels to the left of the line and -400 from the top of the line. In addition to this I would like the alignment to refresh automatically. Thanks any Ideas? Link to comment Share on other sites More sharing options...
PsaltyDS Posted March 23, 2008 Share Posted March 23, 2008 Hello, Well here is one for those Geniuses out there.I have a border less window 400x328 that i would like centered to a Vertical line in a window "MPLAYER" The line color is 0xC0C0C0 and is about 591 pixels tall, there are other lines in the window, but this one is the closest to the center of the window. I would like the border less window centered -40 pixels to the left of the line and -400 from the top of the line. In addition to this I would like the alignment to refresh automatically.Thanks any Ideas?Step 1. Have you coded anything to locate this line in the first place? If the line is the edge of a window or a control then you could find it with WinGetPos() or ControlGetPos(). If you really have to search for it by pixel color, then use PixelSearch(). Read the help file entries for these functions and try the example script for them to see which will work best for you. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Cyote101 Posted March 23, 2008 Author Share Posted March 23, 2008 (edited) Here is what I think would work for the first part. $pos = ControlGetPos("TPS REPORT", "", "Tbookbar") MsgBox(0, "Window Stats:", "POS: " & $pos[0] & "," & $pos[1] & " SIZE: " & $pos[2] & "," & $pos[3] ) I have found the following information for the window I wood like to work off of >>>> Window <<<< Title: TPS REPORT Class: TMainForm Position: 65, 18 Size: 1600, 1024 Style: 0x97000000 ExStyle: 0x00010000 Handle: 0x000404B2 >>>> Control <<<< Class: TBookBar Instance: 1 ClassnameNN: TBookBar1 ID: 263342 Text: Position: 1269, 187 Size: 57, 20 ControlClick Coords: 13, 15 Style: 0x5600804E ExStyle: 0x00010000 Handle: 0x000404AE here is what I'm trying to do. I have a window "Book Helper" and another window "TPS REPORT" I want the first one "Book Helper" set into position and held there based off of the location of the "TPS REPORT" window. to do this I think it would be best to get the position of ClassnameNN: TBookBar1 of the "TPS REPORT" window and then off setting the "Book Helper" window by 506 to the left and -560 down. and that's it. I would also like to make this dynamic. if the user moves the "TPS Report" window then the "Book Helper" window would be re adjusted to line up again. Thanks Edited March 23, 2008 by Cyote101 Link to comment Share on other sites More sharing options...
PsaltyDS Posted March 24, 2008 Share Posted March 24, 2008 So you need a While/WEnd loop that repeatedly gets the location of both windows with WinGetPos(), calculates the position you want for "book helper" from the results of ControlGetPos(), and if the window is not in the right place already, then move it with WinMove(). Sounds like you've already got everything you need. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Cyote101 Posted March 24, 2008 Author Share Posted March 24, 2008 So you need a While/WEnd loop that repeatedly gets the location of both windows with WinGetPos(), calculates the position you want for "book helper" from the results of ControlGetPos(), and if the window is not in the right place already, then move it with WinMove().Sounds like you've already got everything you need. Well, It's good in theory but i must admit I'm not knowledgeable in performing such a script. any help would be amazingly helpful! Link to comment Share on other sites More sharing options...
PsaltyDS Posted March 24, 2008 Share Posted March 24, 2008 Well, It's good in theory but i must admit I'm not knowledgeable in performing such a script. any help would be amazingly helpful!That's why you came here, to get knowledgeable! Look at WinGetPos() and ControlGetPos() in the help file. Run the demo scripts for them and code up enough of your own script to get the current positions of the two windows, and the position of the control you are interested in. Don't move on until you have that part working.Then do the math to calculate the position you want the second window moved to.Next add WinMove() to move it there.When that all works running it just once, add the loop to do it continuously.If you get stuck, come back for more help.You can do it! Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Cyote101 Posted March 24, 2008 Author Share Posted March 24, 2008 If you get stuck, come back for more help.You can do it! Thanks, I went to the help files and got each of the steps done, but i do not know how to use the ControlGetPos to let the winmove know where to more the second window to. I do know that the distance i want the second window to be from TBookBar is 500,-500. Any help on this would be great, Thanks Link to comment Share on other sites More sharing options...
PsaltyDS Posted March 24, 2008 Share Posted March 24, 2008 Thanks, I went to the help files and got each of the steps done, but i do not know how to use the ControlGetPos to let the winmove know where to more the second window to. I do know that the distance i want the second window to be from TBookBar is 500,-500. Any help on this would be great, ThanksHere you are getting into the wild world of relative pixel coordinates. ControlGetPos() returns the coordinates relative to the client area of the parent window. To move another window relative to that, you'll have to get coordinates relative to the desktop. This turns out to be a pain. One solution is a function posted in another topic called _WinGetClientPos(). Calling that with a non-zero parameter will give you coordinates of client area, relative to the desktop. Note that it returns that parameter on the current active window.Take the coord of the client are (relative to the desktop), and add the coord of the control (relative to the client area), then add the offset you want for your second window. That should give the new coordinates for your second window (relative to the desktop) that can be used in WinMove(). Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Cyote101 Posted March 25, 2008 Author Share Posted March 25, 2008 Thanks, I will use the WingetClientPos function. I do not know how to write the script to relay the coords from Wingetclientpos to winmove(), Any help on this would be amazing! Thanks Link to comment Share on other sites More sharing options...
Cyote101 Posted March 25, 2008 Author Share Posted March 25, 2008 (edited) Here is what I came up with, it works! WinActivate ( "TPS REPORT", "") WinWait("TPS REPORT") $pos = ControlGetPos ( "TPS REPORT","+","TBookBar1" ) Opt("MouseCoordMode", 0) MouseClick("secondary", ($Pos[0]) -750, ($Pos[1]) +300) Send("p") Send("p") Thanks for the push!!! Now I'm trying to wrap it up with one final action This is what I have but it does not work, Any help would be good :-) WinActivate ( "My Endles coloring Book", "") WinWait("My Endles coloring Book") $pos = ControlGetPos ( "My Endles coloring Book","+","TBookBar1" ) Opt("MouseCoordMode", 0) MouseMove ($Pos[0]) -750, ($Pos[1]) +300) $mousepos = MouseGetPos() $mouse_x = $mousepos[0] $mouse_y = $mousepos[1] WinMove("Book Helper", "", $mouse_x + 200, $mouse_y +260) Edited March 25, 2008 by Cyote101 Link to comment Share on other sites More sharing options...
PsaltyDS Posted March 25, 2008 Share Posted March 25, 2008 Here is what I came up with, it works!Glad you figured it out! Now I'm trying to wrap it up with one final action This is what I have but it does not work, Any help would be good :-) WinActivate ( "My Endles coloring Book", "") WinWait("My Endles coloring Book") $pos = ControlGetPos ( "My Endles coloring Book","+","TBookBar1" ) Opt("MouseCoordMode", 0) MouseMove ($Pos[0]) -750, ($Pos[1]) +300) $mousepos = MouseGetPos() $mouse_x = $mousepos[0] $mouse_y = $mousepos[1] WinMove("Book Helper", "", $mouse_x + 200, $mouse_y +260) A couple of things here: 1. WinWait before WinActivate. WinWait only waits for the window to exist, so it doesn't make sense right after WinActivate, which requires that the window already exists. 2. "Endless" has two s's in it. If that's a typo, it won't match. You don't have to give the entire title, but the part you do give must match exactly, including case. 3. Remember ControlGetPos is relative to the client area of the window. Your MouseCoordMode = 0 is relative to the whole window. MouseCoordMode = 2 would be relative to the client area. 4. Your MoseGetPos will work as you have it, but just for academic sake, you can get the coordinates straight to the variables with the dimension parameter:; $mousepos = MouseGetPos() ; not needed $mouse_x = MouseGetPos(0) $mouse_y = MouseGetPos(1)(I haven't tested to see if two calls to the function is any performance hit.) Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Cyote101 Posted March 27, 2008 Author Share Posted March 27, 2008 (edited) Well, Most of the script works, The mouse goes to the right place, the book helper window does not move to the right location. Any Ideas? Edited March 27, 2008 by Cyote101 Link to comment Share on other sites More sharing options...
PsaltyDS Posted March 27, 2008 Share Posted March 27, 2008 Well, Most of the script works, The mouse goes to the right place, the book helper window does not move to the right location. Any Ideas? If the book helper window moves, but not to the right place, then it's a math problem. Possibly caused by not having the relative desktop/window/client area coordinates thing quite straight yet. At each point where you deal with coordinates, dump them to the console with something like this:$pos = ControlGetPos ( "My Endles coloring Book","+","TBookBar1" ) ConsoleWrite("Debug: $pos[0] = " & $pos[0] & " [1] = " & $pos[1] & " [2] = " & $pos[2] & " [3] = " & $pos[3] & @LF) Use AU3Info.exe to see if the numbers are what you expected. By comparing the numbers that come out of your script execution with what you see in AU3Info, you can find where the math went wrong. So you've learned scripting and debugging skilz in a couple of days. Keep it up! Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law 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