nusaki Posted September 6, 2009 Posted September 6, 2009 (edited) I have two windows open with same Class and Title. Is it possible to find window by its position if it’s not selected (activated)? I also herd that you can find window by its handle, but how can do that if handle always changes when I close and open that window? Help me please! Edited September 6, 2009 by nusaki keywen.com
PsaltyDS Posted September 6, 2009 Posted September 6, 2009 I have two windows open with same Class and Title. Is it possible to find window by its position if it’s not selected (activated)? I also herd that you can find window by its handle, but how can do that if handle always changes when I close and open that window? Help me please! You are right about the handles: they change every time and are not useful for initial identification of the window, but are the most reliable way to ID the window after you get them. Look in the help file at "Window Titles and Text (Advanced)" in the section "Advanced Window Descriptions", where you find: A special description can be used as the window title parameter. This description can be used to identify a window by the following properties: TITLE - Window title CLASS - The internal window classname REGEXPTITLE - Window title using a regular expression (if the regular expression is wrong @error will be set to 2) REGEXPCLASS - Window classname using a regular expression (if the regular expression is wrong @error will be set to 2) LAST - Last window used in a previous AutoIt command ACTIVE - Currently active window X \ Y \ W \ H - The position and size of a window INSTANCE - The 1-based instance when all given properties matchThe help doesn't include an example using X\Y\W\H though, so here's one: ; Create GUI GUICreate("GUI 1", 300, 300, 150, 175) GUISetState() ; Get handle by X/Y pos $hGUI = WinGetHandle("[X:150; Y:175]", "") ; Use handle to get title $sTitle = WinGetTitle($hGUI) ; Display results ConsoleWrite("$hGUI = " & $hGUI & ", $sTitle = " & $sTitle & @LF) ; Wait for close Do Sleep(10) Until GUIGetMsg() = -3 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
nusaki Posted September 6, 2009 Author Posted September 6, 2009 (edited) Thank You for help But it doesn’t seem to work for me.There is my code belowI need to find windows at coordinates 0,0 and 0,208 (so I can activate them when I need to) but program returns wrong handles Global $Pause #Include <Misc.au3> HotKeySet("{F2}","close") HotKeySet("{F1}","start") While 1 Sleep(1800000) start() Wend Func close() Exit EndFunc Func start() setup() EndFunc Func setup() $h1 = WinGetHandle("[X:0; Y:0]", "") $h2 = WinGetHandle("[X:0; Y:208]", "") MsgBox(0,"",$h1) MsgBox(0,"",$h2) EndFunc===============================================EDIT nvm sorryi changed $h1 = WinGetHandle("[X:0; Y:0]", "") to $h1 = WinGetHandle("[X:0; Y:1]", "")and moved window to 0,1 and it works perfect! thanks! Edited September 6, 2009 by nusaki keywen.com
torels Posted September 6, 2009 Posted September 6, 2009 make a winlist of all active windows then make a search in the array for widows with the positions you need (and let's say a 5px margin of error, if the window's position resulted slightly moved for any reason) so you get something like if $PosY-208<6 and $PosY-208>-6 then ;do whatver endif where $PosY is the position of the window you find by WinList you will obviously have to go all through the WinList Array Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org
PsaltyDS Posted September 6, 2009 Posted September 6, 2009 EDIT nvm sorry i changed $h1 = WinGetHandle("[X:0; Y:0]", "") to $h1 = WinGetHandle("[X:0; Y:1]", "") and moved window to 0,1 and it works perfect! thanks! The problem with 0,0 is that every full-screen window including the desktop is at that position. So if you just use "[X:0; Y:0]" then you get whichever one is at that position and nearest the top of the z-order. Add more parameters to make it more specific. For example, in my demo if you change this: ; Get handle by Class plus X/Y pos $hGUI = WinGetHandle("[CLASS:AutoIt v3 GUI; X:0; Y:0]", "") It will now only find an AuotIt GUIs at 0,0 even if it's not currently on top. 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
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