dwaynek Posted April 6, 2006 Share Posted April 6, 2006 Since Windows Explorer dynamically changes it's title depending on which folder it's in, i can't use the regular WinActive() function to detect it. is there another way? Link to comment Share on other sites More sharing options...
Valuater Posted April 6, 2006 Share Posted April 6, 2006 maybe ; get Active Window (Title)(Text) ; Author - SmOke_N & Valuater Sleep(5000); set active window for testing $MyText = WinGetText(FindActiveWindow()) $MyTitle = WinGetTitle(FindActiveWindow()) MsgBox(0, $MyTitle, $MyText) Func FindActiveWindow() Local $HidOpt = Opt("WinDetectHiddenText", 1);0=don't detect, 1=do detect Local $w_WinList = WinList() For $i = 1 to $w_WinList[0][0] If $w_WinList[$i][0] <> "" AND BitAnd(WinGetState($w_WinList[$i][1]), 2) _ And BitAnd(WinGetState($w_WinList[$i][1]), 8) Then Return $w_WinList[$i][0] Next Opt("WinDetectHiddenText", $HidOpt) EndFunc ; and................. $iPID = WinGetProcess ( $MyTitle, $MyText) #include <Process.au3> $name = _ProcessGetName ( $iPID ) MsgBox(0, $MyTitle, $name) 8) Link to comment Share on other sites More sharing options...
herewasplato Posted April 7, 2006 Share Posted April 7, 2006 (edited) Since Windows Explorer dynamically changes it's title depending on which folder it's in, i can't use the regular WinActive() function to detect it. is there another way?Here is the short answer: AutoItSetOption("WinTitleMatchMode", 4) While 1 If WinActive("classname=ExploreWClass") _ Or WinActive("classname=CabinetWClass") Then ToolTip("Explorer Window is Active") Else ToolTip("") EndIf Sleep(88) WEnd Here is the (very) long answer: I wrote that code while Valuater was posting... but I wanted to read the help file on WinTitleMatchMode option 4 and classname. I did not understand what I read, so I did not make the post. Also, I originally used a MsgBox in the code and it made things a bit messy attempting to determine when the test window was active... yet another reason not to post any code. I chased some other rabbits (translation - I had a class to go to). When I got back to this, I used a ToolTip and convinced myself that the code works for the various explorer views that I can bring up using the classic view for XP SP2. Now dwaynek, if you don't mind - I'm going to hijack your thread and ask my own question of those in the forum. The "AutoIt Window Info" shows various values for ClassNameNN within an explorer window and one value for Class. Can someone explain the difference between those two terms and maybe tell me what section of the help file was supposed to convey that I could use the value labeled "Class" like this "classname=ExploreWClass"? Sorry if the question is unclear - the topic is unclear for me. Edited April 7, 2006 by herewasplato [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
DaleHohm Posted April 7, 2006 Share Posted April 7, 2006 Depending on your flow, another option would be to get the HWND of the explorer window when you CAN identify it (like when it is created) and then use the HWND with WinActive. Dale Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model Automate input type=file (Related) Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded Better Better? IE.au3 issues with Vista - Workarounds SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead? Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted April 7, 2006 Moderators Share Posted April 7, 2006 If there was a search done: "Windows Explorer" you would have found this: http://www.autoitscript.com/forum/index.ph...ndpost&p=164448I took the same approach as plato did... but at that time did not know about CabinetWClass.@plato... I would assume that one is the "Windows Class" and the other is the "Control Class", of course I'd love to see the real answer myself Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
herewasplato Posted April 7, 2006 Share Posted April 7, 2006 If there was a search done: "Windows Explorer" you would have found this: http://www.autoitscript.com/forum/index.ph...ndpost&p=164448I took the same approach as plato did... but at that time did not know about CabinetWClass.@plato... I would assume that one is the "Windows Class" and the other is the "Control Class", of course I'd love to see the real answer myself Funny, I found that post while composing my post. (I searched for CabinetWClass.) I referenced it (in a very wordy paragraph) in my reply but took it out to make that post shorter. I had wondered if others had found other values for "Class" using other views of explorer:CabinetWClass = right click on "my computer" and select openExploreWClass = right click on "my computer" and select exploreMake a folder on the desktop.Double click = CabinetWClassMake the folders show like a classic two pane view and it is still a CabinetWClass(So, whatever class you were born to......)I know that it should not be much of a leap to go from the label "Class:" under the section named:>>>>>>>>>>>> Window Details <<<<<<<<<<<<<to the instructions in the help file under Window Titles and Text (Advanced):Mode 4Advanced mode.In this mode special sequences are used in the title parameter so that window classnames and handles can be used. The text parameter remains the same.The special sequences must contain no whitespace. They are: "classname=CLASSNAME" "active".....but sadly, I never made that leap (small step) until today... even worse, I've looked at this more than once. Oh well, enough with the confessions of stupidity (for today).On the one hand, I can only hope that this discussion helps someone else...On the other hand, I hope that no one else is that dense...On the third hand (okay, I cannot tie that to "Click and Clack's" - "On the third half of our show...") [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
rakeshranjan1985 Posted July 18, 2008 Share Posted July 18, 2008 thanks Valuater for the code you posted. it works muttley Link to comment Share on other sites More sharing options...
rakeshranjan1985 Posted July 18, 2008 Share Posted July 18, 2008 thanks Valuater for the code you posted. it works until the point where you retrieve the PID. Many times, text retrieved is not readable because of which $MyText is garbled and WinGetProcess returns -1. Any advice for this problem??? Link to comment Share on other sites More sharing options...
rakeshranjan1985 Posted July 18, 2008 Share Posted July 18, 2008 Or else we can use WinGetTitle("[active]") and WinGetText("[active]") to get the title and text of the currently active window.... Link to comment Share on other sites More sharing options...
rakeshranjan1985 Posted July 18, 2008 Share Posted July 18, 2008 Or else we can use WinGetTitle("[active]") and WinGetText("[active]") to get the title and text of the currently active window.... 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