Ármányos Kő Posted November 3, 2006 Share Posted November 3, 2006 (edited) I made some script which brings up different Sub-windows by keyboard shortcuts. I mean windows like Paste Special, Open, ... These windows do have different titles under different language OS. So the question came how to manipulate these windows by title reference, if not nowing the name? Even, how to WinWaitActive if not knowing the title? The answer is below. Maybe it is some use of someone. (Basically the script in this form is a try to make a quasi-UDF, it's a bit dodgy, I am not expert in ByRef functioning yet.) expandcollapse popup#Include <Constants.au3> #Include <Array.au3> #include <file.au3> #include <GUIConstants.au3> Func WinWaitNew_GetTitle(ByRef $NT) $NT = "" Do Sleep(50) $PostList = WinList() Until $PostList[0][0] <> $WinWaitNew_Start[0][0] For $i = 1 to $PostList[0][0] If $PostList[$i][0] <> "" AND IsVisible($PostList[$i][1]) Then $NT = $NT&$PostList[$i][0] EndIf Next For $i = 1 to $WinWaitNew_Start[0][0] If $WinWaitNew_Start[$i][0] <> "" AND IsVisible($WinWaitNew_Start[$i][1]) Then $NT = StringReplace($NT, $WinWaitNew_Start[$i][0],"", 1,1) EndIf Next EndFunc Func IsVisible($handle) If BitAnd( WinGetState($handle), 2 ) Then Return 1 Else Return 0 EndIf EndFunc ;Testing the functions AutoItSetOption("WinTitleMatchMode", 2) $NewTitle = "" Run("notepad.exe") WinWaitActive("Notepad", "") $WinWaitNew_Start = WinList() ;Start watching right before bringing up new window with some action Send ("^o") ;This action brings up the new window, which we do not know the title of WinWaitNew_GetTitle($NewTitle) ;Get the title of the new window MsgBox(0, "The title", "Your title of OPEN window is: "&@CRLF&@TAB&$NewTitle) MsgBox(0, "The title", "Now you can reference to this window with $NewTitle and perform actions with ControlClick and others") WinActivate ($NewTitle, "") WinWaitActive( $NewTitle, "") ControlClick ($NewTitle, "", "ComboBox2") Sleep(1000) ControlClick ($NewTitle, "", "ComboBox3") Sleep(1000) ControlClick ($NewTitle, "", "ComboBox4") Sleep(1000) WinClose( $NewTitle, "") Sleep(500) WinClose("Notepad", "") Edit: added codetags Edited November 4, 2006 by JdeB Link to comment Share on other sites More sharing options...
Ed_Maximized Posted November 4, 2006 Share Posted November 4, 2006 Sounds interesting... I´m working in a similar script... I´ll test yours and post later... Suggestion: put your code in autoit tags... it makes more readable... Ed ShapedGUI Creator : Shaped gui the easy way!!!Txt2au3 : the easy way to include text files into your program without fileinstall_GUICreateWithTiledBackground : Put a GIF in the background of your formsSQLite Database BrowserAnimated GIF UDF : Put animations in your GUI's Link to comment Share on other sites More sharing options...
slayerz Posted February 1, 2008 Share Posted February 1, 2008 Whhoooaa....I've been searching for this example long time ago... Thanks 4 sharing AUTOIT[sup] I'm lovin' it![/sup] Link to comment Share on other sites More sharing options...
James Posted February 1, 2008 Share Posted February 1, 2008 Dont post code in the AutoIt code tags as it scrambles the wording up Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
Michel Claveau Posted February 1, 2008 Share Posted February 1, 2008 Hi! Thanks you, for this good sample/script. One info: for french language, replace the lineWinWaitActive("Notepad", "") by WinWaitActive("Bloc-notes", "") 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