Transition from IE to Edge (gathering info from frames)

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Nixcalo
Posts: 116
Joined: 06 Feb 2018, 04:24

Transition from IE to Edge (gathering info from frames)

Post by Nixcalo » 02 May 2022, 10:01

Hi,
I used to have a script that worked to retrieve information from the Target section of the DeepL translator. It went like this:

Code: Select all

 IE := ComObjCreate("InternetExplorer.Application") ;~ Creation of hidden Internet Explorer instance to look up Deepl Translate and retrieve translation
   IE.Visible := false

 IE.Navigate(Path) ; Path is the URL which includes the information that needs to be translated
    While IE.readyState!=4 || IE.document.readyState!="complete" || IE.busy ; Wait until page is loaded?
            Sleep 50
	While (IE.document.getElementsByTagName("textarea")[1].value = "")  ;Since the conversion takes a second we want to wait till the value is filled otherwise the return will always be nothing

		{
		Sleep 50
		If (A_Index >190) { ; Taking too long
			; MsgBox ,,,Error`, starting, .5
			IE.Quit
			Return Result:="Translation failed"
			}
		}
Result := IE.document.getElementsByTagName("textarea")[1].value; THIS IS THE RESULT I WANT!
This used to work perfectly in the deepl.com website. But now DeepL.com no longer works with IE. How do I migrate the script to Edge (ideally Edge, Chrome/Firefox a far second option)??? I have been fiddling with Rufaydium library, but I have only managed to open a Chrome instance, not even a MS Edge one, but not able to read anything from the website it is shown. I have not been also even able to hide it from view (open a hidden instance as I used to do in Internet Explorer).

I tried something like this, checking information about Rufaydium, but firstly I am only able to open a Chrome instance instead of an MS Edge one, and secondly I am not able to do anything with it. Very pathetic I know.

Code: Select all

	ChromeDriver := A_ScriptDir "\chromedriver.exe"

; choose different driver in order to automate different Browser
; Driver := new RunDriver("ChromeDriver.exe") ; running driver
Driver := new RunDriver("ChromeDriver.exe")
Chrome := new Rufaydium(Driver) ; this will return control over Browser

; choosing Browser Capabilities, by using Capabilities Class you can make custom profile for specific need
; Chrome.capabilities := Capabilities.ChromeDefault 

; this is how we create session 
Page := Chrome.NewSession()
   Page.Visible := false

Page.Navigate(Path)
    While Page.readyState!=4 || Page.document.readyState!="complete" || Page.busy ; Wait until page is loaded?
            Sleep 50
	While (Page.document.getElementsByTagName("textarea")[1].value = "")  ;Since the conversion takes a second we want to wait till the value is filled otherwise the return will always be nothing
		{
		Sleep 50
		If (A_Index >190) { ; Translation taking too long
			; MsgBox ,,,Error`, restarting, .5
			Page.Quit
			Return Result:="Translation failed"
			}
		}
 Result := Page.document.getElementsByTagName("textarea")[1].value ;
Any help would be very very welcome. I have been as pathetic as to change IE.xxxx for Page.xxx in the hope it would work on Chrome, but nope.

BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: Transition from IE to Edge (gathering info from frames)

Post by BoBo » 02 May 2022, 12:22

I've used :arrow: Acc.ahk to extract data from a Spotify WebPlayer (browser) page: viewtopic.php?f=10&t=100506
Beforehand I had to identify Chrome (and just out of curiosity,) Edge page elements to access its data. No problem so far. HTH

Maybe one of our AHK Web specialists is willing to shed some light on this (and if it helps users like yourself?)! :think:
OLE COM support in Microsoft Edge
In our application, we are using ActiveX framework created by Microsoft that adapts its earlier Component Object Model (COM) and Object Linking and Embedding (OLE) technologies for content downloaded from a network, particularly from the World Wide Web.
We are currently dependent upon the use of ieframe components based upon Microsoft Internet Explorer for some functionality within Amdocs Clarify Client.

[...]

https://answers.microsoft.com/en-us/microsoftedge/forum/all/ole-com-support-in-microsoft-edge/ecca74bd-ce34-47e1-a08d-cc370c55582f
Another AHK thread about this topic: viewtopic.php?p=452203#p452203

Nixcalo
Posts: 116
Joined: 06 Feb 2018, 04:24

Re: Transition from IE to Edge (gathering info from frames)

Post by Nixcalo » 02 May 2022, 12:47

BoBo wrote:
02 May 2022, 12:22
Beforehand I had to identify Chrome (and just out of curiosity,) Edge page elements to access its data. No problem so far. HTH
Haven't seen in your code any way to recognize Edge page elements. Much less access and read them :crazy: :?


Nixcalo
Posts: 116
Joined: 06 Feb 2018, 04:24

Re: Transition from IE to Edge (gathering info from frames)

Post by Nixcalo » 02 May 2022, 19:17

It seems your system only shows a few characters of the translation string and ends it with an ellipsis (...).

So if the translation result is "I want to break free from your arms", the string shown is "I want to break..." so it's no good for the purpose of obtaining a translation.

BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: Transition from IE to Edge (gathering info from frames)

Post by BoBo » 03 May 2022, 00:54

Well, I've created a 5000 character (deepL's free service maximum character restriction) dummy text here: https://www.blindtextgenerator.com/lorem-ipsum
(see text copy below) to translate it there from English to German: https://www.deepl.com/translator.
Once the translation went successfully I pressed F12 to extract the German text from Chrome and display it within a ToolTip.
Here it's showing the whole translated text.

PS. Your statement regarding the 'path' - see my comment here
PPS. Fun fact, deepL's translated text has 5226 characters (so won't restrict the output to 5k chars) + it has auto-corrected the chopped off last word of the original text.

One morning, when Gregor Samsa woke from troubled dreams, he found himself transformed in his bed into a horrible vermin. He lay on his armour-like back, and if he lifted his head a little he could see his brown belly, slightly domed and divided by arches into stiff sections. The bedding was hardly able to cover it and seemed ready to slide off any moment. His many legs, pitifully thin compared with the size of the rest of him, waved about helplessly as he looked. "What's happened to me?" he thought. It wasn't a dream. His room, a proper human room although a little too small, lay peacefully between its four familiar walls. A collection of textile samples lay spread out on the table - Samsa was a travelling salesman - and above it there hung a picture that he had recently cut out of an illustrated magazine and housed in a nice, gilded frame. It showed a lady fitted out with a fur hat and fur boa who sat upright, raising a heavy fur muff that covered the whole of her lower arm towards the viewer. Gregor then turned to look out the window at the dull weather. Drops of rain could be heard hitting the pane, which made him feel quite sad. "How about if I sleep a little bit longer and forget all this nonsense", he thought, but that was something he was unable to do because he was used to sleeping on his right, and in his present state couldn't get into that position. However hard he threw himself onto his right, he always rolled back to where he was. He must have tried it a hundred times, shut his eyes so that he wouldn't have to look at the floundering legs, and only stopped when he began to feel a mild, dull pain there that he had never felt before. "Oh, God", he thought, "what a strenuous career it is that I've chosen! Travelling day in and day out. Doing business like this takes much more effort than doing your own business at home, and on top of that there's the curse of travelling, worries about making train connections, bad and irregular food, contact with different people all the time so that you can never get to know anyone or become friendly with them. It can all go to Hell!" He felt a slight itch up on his belly; pushed himself slowly up on his back towards the headboard so that he could lift his head better; found where the itch was, and saw that it was covered with lots of little white spots which he didn't know what to make of; and when he tried to feel the place with one of his legs he drew it quickly back because as soon as he touched it he was overcome by a cold shudder. He slid back into his former position. "Getting up early all the time", he thought, "it makes you stupid. You've got to get enough sleep. Other travelling salesmen live a life of luxury. For instance, whenever I go back to the guest house during the morning to copy out the contract, these gentlemen are always still sitting there eating their breakfasts. I ought to just try that with my boss; I'd get kicked out on the spot. But who knows, maybe that would be the best thing for me. If I didn't have my parents to think about I'd have given in my notice a long time ago, I'd have gone up to the boss and told him just what I think, tell him everything I would, let him know just what I feel. He'd fall right off his desk! And it's a funny sort of business to be sitting up there at your desk, talking down at your subordinates from up there, especially when you have to go right up close because the boss is hard of hearing. Well, there's still some hope; once I've got the money together to pay off my parents' debt to him - another five or six years I suppose - that's definitely what I'll do. That's when I'll make the big change. First of all though, I've got to get up, my train leaves at five." And he looked over at the alarm clock, ticking on the chest of drawers. "God in Heaven!" he thought. It was half past six and the hands were quietly moving forwards, it was even later than half past, more like quarter to seven. Had the alarm clock not rung? He could see from the bed that it had been set for four o'clock as it should have been; it certainly must have rung. Yes, but was it possible to quietly sleep through that furniture-rattling noise? True, he had not slept peacefully, but probably all the more deeply because of that. What should he do now? The next train went at seven; if he were to catch that he would have to rush like mad and the collection of samples was still not packed, and he did not at all feel particularly fresh and lively. And even if he did catch the train he would not avoid his boss's anger as the office assistant would have been there to see the five o'clock train go, he would have put in his report about Gregor's not being there a long time ago. The office assistant was the boss's man, spineless, and with no understanding. What about if he reported sick? But that would be extremely strained and suspicious as in fifteen years of service Gregor had never once yet been ill. His boss would certainly come round with the doct
Attachments
getDeepL().png
getDeepL().png (133.81 KiB) Viewed 1135 times

Post Reply

Return to “Ask for Help (v1)”