Innominate Posted May 11, 2017 Share Posted May 11, 2017 By typing CTRL-u (simultaneously pressing the “Control” and “u” keys), the news feed in my e-mail client (Thunderbird) shows the message source containing all the desired information. It is easy (just time-consuming) to MANUALLY do what I want: Type CTRL-u Filter out everything except for selected text between specific tags, specifically between <title>Message title</title> and <body id="msgFeedSummaryBody" selected="false">Summary text</body> I also want to extract the URL, which is given three times: Message-Id: <https://www.linktopage.htm@localhost.localdomain> Content-Base: https://linktopage.htm (no closing tag for this, just a line feed with the next one beginning with “Content-Type: “) <base href="https://www.linktopage.htm"> Having extracted the Message title, Summary text, and URL, I want to save that in one of various text files, with a prompt for user input giving me a way (such as entering a letter, word, or clicking a radio button; the latter is preferable) to specify which file. The problem is how to automate this process with AutoIt. This should be easy for a very smart person skilled in using AutoIt. Using a different program (AutoHotKey), I wrote a script opening the message source window, selecting the text, and copying it: ^h:: ;CTRL-h is the hotkey triggering this script Send, ^u ClipWait, 1 Send, ^a ;to select all ClipWait, 1 Send, ^c ;to copy it AutoHotKey makes it easy to copy the message source onto the clipboard; its problem is a lack of easy ways to filter the text. I tried getting AutoIt to open the message source window, select the text, and copy it, but I couldn't get it to identify the correct window; I can't specify it by name (using the title in AutoIt Window Info) because the title includes a number that is different for every feed item in my news feed. I would greatly appreciate a working script. In the past, I hired a programmer who impressed me, paying him twice as much as what he modestly requested. If you have brilliance, I have other ways for you to demonstrate it and be compensated for it. Link to comment Share on other sites More sharing options...
Floops Posted May 11, 2017 Share Posted May 11, 2017 (edited) 1. To convert your AHK script something like this should work: HotKeySet("^h", "_copy") While 1 Sleep(100) WEnd Func _copy() Send("^u") Sleep(1000) Send("^a") Sleep(1000) Send("^c") Exit EndFunc 2. There is an option to change the way AutoIt matches the window names. Opt("WinTitleMatchMode", 1) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase Option 2 would probably be what you want. Edited May 12, 2017 by Floops Link to comment Share on other sites More sharing options...
Innominate Posted May 12, 2017 Author Share Posted May 12, 2017 That did not work. I tried Opt("WinTitleMatchMode", 2) but AutoIt still cannot identify the correct window even though it is the active one I'm viewing. I don't know how the other program (AutoHotKey) identifies the active window, but it does it easily. Doesn't AutoIt have a way to identify the active window? Link to comment Share on other sites More sharing options...
Floops Posted May 12, 2017 Share Posted May 12, 2017 What is the name of the window? AutoIt should be able to detect it by it's name. In the meantime you can try if the following code works for you. It should give you the name of the active window. $sActive = _get_active_window() Func _get_active_window() $aWindows = WinList() For $i = 1 To UBound($aWindows) - 1 If $aWindows[$i][0] <> "" And WinActive($aWindows[$i][0]) Then Return $aWindows[$i][0] EndIf Next EndFunc Link to comment Share on other sites More sharing options...
Innominate Posted May 12, 2017 Author Share Posted May 12, 2017 AutoIt now works (copying the message source), but it runs only once. If I select a different item in the Thunderbird news feed and enter ^h (the hotkey), AutoIt won't copy the message source unless I precede that by clicking the taskbar icon that runs the executable version of the script, and do this every time for every news feed item. I wasn't sure what to do with your Get Active Window script. I tried running it both as a separate script and adding it to the Get Message Source script, but in neither case did it report anything obvious to me. What is its user output and where should it appear? 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