I have been trying for two hours now and I am ready to surrender, as I have to deliver a project and I am running out of time, so I'll just post this query and see if someone helps me.
I am trying to create a script that picks up some text and drops it in a certain box in a Firefox/internet explorer page. It then creates a result and I'd like to copy that result into the clipboard (basically, it's DeepL.com translator, something similar to Google Translate, I want to drop something in the Source box and collect the translation from the Target Box.
Initially, I had a script that did it the straightforward way, that is, copies the text I want into the clipboard, changes to Firefox/Edge (depending on what browser I want to use, I tended to use Firefox), moves the mouse to the relevant point in the screen, clicks there in order to select, pastes the ClipBoard, then moves to the target box, sends Control+A to select all target text, then Control+C to copy that to the clipboard.
The number of problems is huge. To name a few, it's slow, very buggy because of the copy paste typical problems (interaction with other processes), depends on the placement of the windows, and the monitor needs to be ON (I can't create a long loop for a lot of sentences and then turn the monitor OFF).
Then I discovered ControlSend (or Control) so I figured that this could be used to send any text I wanted into the relevant box in the browser and then ControlGetText to get text from the TARGET box.
Here is where I am stuck. I don't exactly know the definition for "CONTROL" so I don' tknow firstly if I am in the right track. What is worse, now, is that I am lost with the syntax of ControlSend.
ControlSend [, Control, Keys, WinTitle, WinText, ExcludeTitle, ExcludeText]
Supposedly, the key to find the right box in which to drop the text I want lies in the variable "Control". But there is NO way in Window Spy to differentiate btween one box or the other. Actually, in Internet Explorer I just see ClassNN: Internet Explorer_Server1 as "Focused Control" but that doesn't differentiate between the Source box (where I want to place the text) and the Target Box (where I want to pick up the text).
So I have tried (in Internet Explorer)
Code: Select all
Control, EditPaste, Hasta la vista baby, Internet Explorer_Server1, Traductor de Google
and
Code: Select all
ControlSend, Internet Explorer_Server1, ^{a}Hasta la vista baby, Traductor de DeepL
When trying to do this in Firefox, Windows Spy WILL NOT give me any information about ClassNN. In Firefox, Windows Spy only tells me about ahk_class and ahk_exe. So when I try this just leaving control blank...
Code: Select all
ControlSend,, ^{a}Hasta la vista baby, Traductor de DeepL
So this is misterious, the same script works in Firefox but NOT in Internet Explorer?? Anyway, I could live with this, provided I am working with Firefox and NOT with Internet Explorer.
However, in that case when trying to recover the translated result (target box) from Mozilla Firefox, I have a problem. How I am I supposed to get it? I have no ClassNN, no way to identify the box I want and pick up the text from there and copy it into Clipboard. So can't use in principle ControlGetText.
How can I pick text from a particular box In Firefox when there is more than one box???
Unless the solution lies in control's HWND (window handles). But there I got completely lost and perhaps that refers to windows only, not to dialog boxes within a window.
And those were all my attempts. At least I tried!!! At this point, I kind of surrendered
Unless the solution lies in HWND (window handles), but then I don't know what a window handle is, whether this could apply to a website where are two dialog boxes, and how it is used, as manual is unclear.
Any help? Since I got to insert the text I want into a particular box in Firefox (not in Internet Explorer), how can I recover the text from a different dialog box in that same page? How can I identify that particular box and collect the text in there???
Thank you!