Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

There is a solution to write scripts for FireFox


  • Please log in to reply
40 replies to this topic
nigelle
  • Members
  • 129 posts
  • Last active: Dec 28 2013 04:31 PM
  • Joined: 26 Sep 2008
AutoHotkey Scripts to Automate Firefox

This post is just to explain the principles I have used : I'll write an "user manual" (a big job) only if a sufficient number of people ask for it.

Background

Previous Attempts - iMacros

I have before AutoHotkey tried "iMacros for Firefox" but the problem is that it is not a complete system : they give some instructions to access the content of the screen, wait for it or fill fields but to do loop, if then else, or string functions you need to go back to the javascript (run by the built-in Firefox machine) that called their instructions : so many lines of code in js.

"iMacros for Firefox" is the free-ware low-end of a line of commercial products. As they say "We hope you'll enjoy iMacros so much that you'll consider upgrading to the business editions ..." There is no much hope of big improvement : they have to earn their living with the paid for products.

For us, the interest of "iMacros" is their documentation and their demos that may give ideas. Also the URL against which the demos are run are simple and with direct access : this is easier to post than the same problem in the 5th screen of an application with userid and password !

Compared with AutoHotkey, the interface with FireFox is far better because it is a FireFox extension but the supporting language is far worst !

Problems with Firefox & AutoHotkey

I have soon discovered that AutoHotkey cannot read the content of a Firefox screen except the title line : AutoHotkey intercept the Windows interface but FireFox, which runs on multiple OS has its own (common for the various OS) interface to screen. So many of AutoHotkey screen functions do not work.
The keyboard interface, at least the "Send, keys" command works, the mouse interface also.

The Solution


This seems very limited and not usable but there is a solution : The FireFox short-cuts.

AutoHotkey script can type them to FireFox with "Send, keys" e.g. "Send, {CTRLDOWN}l{CTRLUP}" selects the Location Bar (e.g. the URL of the page shown by FireFox) and with "Send, {CTRLDOWN}c{CTRLUP}" you have access to it in the clipboard common to AutoHotkey and FireFox.

With the sequence ctrl+u (show the source screen), ctrl+a (select all), ctrl+c (copy to clipboard), AutoHotkey command (it works !) to close source screen : you have the htlm source of the page in the clipboard.

With ctrl+f (search in text) + typing the string_to_search in the status bar that open with the cursor in it + {ESC} the string is selected and you can with "enter" activate the link under it or with "tab" go to the next input area.

The list of standard short-cuts is at :
<!-- m -->http://support.mozil...board shortcuts<!-- m -->

The Firefox Keyconfig extenshion - More Functions

You need also other short-cuts, they can be coded with the Keyconfig extension see :
<!-- m -->http://forums.mozill...pic.php?t=72994<!-- m -->
<!-- m -->http://kb.mozillazin...onfig_extension<!-- m -->The idea is that, if you need a function that does not work or exist in AutoHotkey or to extract some information from FireFox, you use a short-cuts that does it for you, you call it with "Send, keys" command.

In most of the cases the input to and output from the short-cuts are the clipboard.

To write a short-cut, you need to know very well the coding of FireFox to put together some already existing functions of it : "Dorando" the author of Keyconfig is a very helpful expert, personally I am just able to ask, in the forum, for a short-cut that does what I wish to have !

Development of the Keyconfig shortcuts for AutoHottkey


To ease the understanding of my reasons, I'll do an historical presentation.

1. The initial Shortcuts

first batch of short-cuts :

My experiences have shown that :

- clicking at X and Y coordinates was not reliable because too often the application move slightly the components of the screen to make it better looking. If you have several PC with different sizes of screen, you may also have problems.

- navigating by tabs from a corner of the screen was not reliable because too often the application added or subtracted links or areas to click.

So I used the context with the "search in text" short-cut to move by tab from an nearby explanatory text. This text should be unique on the screen to ease the coding of the script. E.g. for login screen often also used for registration, you find "user" twice (in both parts), password and password forgotten (or lost or equivalent) in the login area, password and repeat password in registration area : I searched for "password forgotten" then tabed back to user input area, entered it, then tab to normal password area.

I obtained 3 short-cuts :

1-1. When executed, puts "NotBusy" in the clipboard if the page has finished to load else "Busy". I have built around it an AutoHotkey function that loops with an 0.5 seconds "Sleep" and return when loading has finished or exit if time out.

1-2. Checks if ctrl+f has found the string and puts "found" in the clipboard else "not_found". I have built around it an AutoHotkey function that send ctrl+f, then the string_to_search, then the 2nd short-cut and exit if "not_found", then {ESC} and return leaving the string selected and you can with "enter" activate the link under it or with "tab" go to the next input area.

1-3. Puts the source in the clipboard. It is equivalent (but easier to synchronize with AutoHotkey) to the sequence ctrl+u, ctrl+a, ctrl+c, AutoHotkey command to close source screen. I have built around it an AutoHotkey function that return the source. Then I extract the information I need with a sub-pattern of RegExMatch. Or do an other string search function to verify if I am on the right screen.

With this you can write and run some scripts without knowledge of html language : you need just your eyes to see the text to select.

Limitations

The limitations are :

- Not all application support navigation by tab.

- "false texts" : they are not in character mode in the source of the page, they are drawn on an image. In this case they are not found with ctrl+f.

- national characters when you are abroad. E.g. in a French application the button to disconnect is often called "Déconnexion" (the French word for the action of disconnecting where the 2nd character is "e with acute accent"). This word was found by ctrl+f without problem on a French PC with French Windows and French FireFox but was not found on a English PC with English Windows and English FireFox : I don't know the reason, nevertheless "e with acute accent" was shown on the screen...

2. The Second Shortcuts

Second batch of short-cuts :

2.1.
'Is this possible to define a new function "find in source and click" that has some similarities to ctrl+f but works on the source'?

The answer of the author of Keyconfig was 'it does exceed my abilities in multiple ways'. I said : 'Something similar is done by the "tag" command of iMacros for Firefox' The author : 'what iMacros does seems to translate the input to "XPath"' FireFox function and gave me a shortcut .

The input parameter is put in the clipboard before short-cut : he said:

You can test some on the iMacros demo page

<!-- m -->http://www.iopus.com...6/pos/index.htm<!-- m -->

by copying one of the following to your clipboard:
nigelle;2;//a[contains(text(),"Click to open this page")]
nigelle;1;//a[@href="page1.htm"]
nigelle;1;//input[@value="your E-mail here"] The format is
identifier;occurrence;XPath while for XPath
//tag[@attribute="value"] or
//tag[contains(text(),"text content")] should cover many cases.'


The clipboard after short-cut contains "Found" (success) or "NotFound" (failure to find) or the text of the internal error in FireFox (generally bad format of the input)...

With this you can activate a link or put the cursor in an input area : this is very powerful, it can do the same as ctrl+f and far more.

For documentation on "XPath" see :
<!-- m -->https://developer.mozilla.org/En/XPath<!-- m -->
<!-- m -->http://www.w3.org/TR/xpath<!-- m -->
<!-- m -->http://www.w3schools.com/xpath/<!-- m -->
<!-- m -->http://www.examplede... ... html?l=rel<!-- m -->With this you can write and run many scripts but with knowledge of html language and format of Xpath.

2.2. Maximizes the window (the AutoHotkey function does not works except in the "run" command). Use this when you don't need to see the background.
2.3. Restores the window to the non-maximized state, I have not used it because often it gives a size of 1x1 inch on my 20" monitor !

3. The Third Shortcuts

Third batch of short-cuts :

3.1. Puts the source of the DOM in clipboard
With an application that modified the content of the window with Javascript, I discovered that there are 2 sources defined in FireFox;

a) source1 the classical source shown by Ctrl+u on a screen with the title : "Source of : <!-- m -->http://url_with_parameters<!-- m --> - Mozilla Firefox". Source1 is not modified by Javascript and is given by 1.3.

B) source2 shown by selecting an area on a screen, right click and choosing "source code of the selection" : the title of the screen is :
"DOM source of the selection - Mozilla Firefox". Normally it shows from the <div> before the selection to the </div> after it. It works also for the full page after ctrl+a .

The present short-cut puts the source of the DOM (of the whole window) in clipboard, I have built an AutoHotkey function that return it.

3.2. Set the window to 3 quarters of the size of the screen. Use this when you need to see the background.

4. The Final Shortcuts

fourth batch of short-cuts

4.1. URL in clipboard
It is equivalent to the sequence ctrl+l, ctrl+c but without the problem of synchronizing the 2 short-cuts.

Known limitations

- The Xpath short-cut does not start a Flash application. As flash simulation is low in my priority list, I have not tested the methods that Imacros uses in this case : clicking at X and Y coordinates when the image of the Flash application does not move or ImageSearch function and click on the found coordinates. I assume they work.

- ControlSend command does not works properly, only Send does the job : you are forced to keep the focus on the FireFox screen and you cannot run another thing during your script, this is annoying when its duration is 10 minutes or more !
I have tried to change, in one of my script that worked fine and in all my functions, "send, keys" to "ControlSend,, keys, %Wtit%" where %Wtit% is the wintittle field corresponding to the application.

a) First I run it keeping the focus on the FireFox screen to see what occurred, the short-cuts did their job but 'Send, "my_userid" ' (after an Xpath call to put the cursor in the userid input area) entered nothing.

I changed this to
clipboard := "my_userid"
ControlSend,, {CTRLDOWN}v{CTRLUP}, %Wtit%
and it worked.

B) Then I tried to run this corrected script, switching to an other window then going back to see what occurred : the script was blocked : the Xpath has put the cursor in the userid area, nothing was entered in this field and the next Xpath to the password has time outed (without putting any result in the clipboard) after more than 40 seconds when normally it takes from 0.3 to 1s to execute with "send, keys" ...

I am an user and not a developer, I cannot give any reason or cure to this behaviour. FireFox ? Its javascript or XUL machine ? AutoHotkey ?

With the fore mentioned limitations, I run happily a few dozens of scripts.

As I am lazy, and does not wish to write more than 3 times the same group of lines, I have many more functions than described here...

So I ask again the question : Do you need that I write an "user manual" ?

This is a big job, I'll not start it without strong request.
AutoHotkey Scripts to Automate Firefox

This post is just to explain the principles I have used : I'll write an "user manual" (a big job) only if a sufficient number of people ask for it.

Background

Previous Attempts - iMacros

I have before AutoHotkey tried "iMacros for Firefox" but the problem is that it is not a complete system : they give some instructions to access the content of the screen, wait for it or fill fields but to do loop, if then else, or string functions you need to go back to the javascript (run by the built-in Firefox machine) that called their instructions : so many lines of code in js.

"iMacros for Firefox" is the free-ware low-end of a line of commercial products. As they say "We hope you'll enjoy iMacros so much that you'll consider upgrading to the business editions ..." There is no much hope of big improvement : they have to earn their living with the paid for products.

For us, the interest of "iMacros" is their documentation and their demos that may give ideas. Also the URL against which the demos are run are simple and with direct access : this is easier to post than the same problem in the 5th screen of an application with userid and password !

Compared with AutoHotkey, the interface with FireFox is far better because it is a FireFox extension but the supporting language is far worst !

Problems with Firefox & AutoHotkey

I have soon discovered that AutoHotkey cannot read the content of a Firefox screen except the title line : AutoHotkey intercept the Windows interface but FireFox, which runs on multiple OS has its own (common for the various OS) interface to screen. So many of AutoHotkey screen functions do not work.
The keyboard interface, at least the "Send, keys" command works, the mouse interface also.

The Solution


This seems very limited and not usable but there is a solution : The FireFox short-cuts.

AutoHotkey script can type them to FireFox with "Send, keys" e.g. "Send, {CTRLDOWN}l{CTRLUP}" selects the Location Bar (e.g. the URL of the page shown by FireFox) and with "Send, {CTRLDOWN}c{CTRLUP}" you have access to it in the clipboard common to AutoHotkey and FireFox.

With the sequence ctrl+u (show the source screen), ctrl+a (select all), ctrl+c (copy to clipboard), AutoHotkey command (it works !) to close source screen : you have the htlm source of the page in the clipboard.

With ctrl+f (search in text) + typing the string_to_search in the status bar that open with the cursor in it + {ESC} the string is selected and you can with "enter" activate the link under it or with "tab" go to the next input area.

The list of standard short-cuts is at :
<!-- m -->http://support.mozil...board shortcuts<!-- m -->

The Firefox Keyconfig extenshion - More Functions

You need also other short-cuts, they can be coded with the Keyconfig extension see :
<!-- m -->http://forums.mozill...pic.php?t=72994<!-- m -->
<!-- m -->http://kb.mozillazin...onfig_extension<!-- m -->The idea is that, if you need a function that does not work or exist in AutoHotkey or to extract some information from FireFox, you use a short-cuts that does it for you, you call it with "Send, keys" command.

In most of the cases the input to and output from the short-cuts are the clipboard.

To write a short-cut, you need to know very well the coding of FireFox to put together some already existing functions of it : "Dorando" the author of Keyconfig is a very helpful expert, personally I am just able to ask, in the forum, for a short-cut that does what I wish to have !

Development of the Keyconfig shortcuts for AutoHottkey


To ease the understanding of my reasons, I'll do an historical presentation.

1. The initial Shortcuts

first batch of short-cuts :

My experiences have shown that :

- clicking at X and Y coordinates was not reliable because too often the application move slightly the components of the screen to make it better looking. If you have several PC with different sizes of screen, you may also have problems.

- navigating by tabs from a corner of the screen was not reliable because too often the application added or subtracted links or areas to click.

So I used the context with the "search in text" short-cut to move by tab from an nearby explanatory text. This text should be unique on the screen to ease the coding of the script. E.g. for login screen often also used for registration, you find "user" twice (in both parts), password and password forgotten (or lost or equivalent) in the login area, password and repeat password in registration area : I searched for "password forgotten" then tabed back to user input area, entered it, then tab to normal password area.

I obtained 3 short-cuts :

1-1. When executed, puts "NotBusy" in the clipboard if the page has finished to load else "Busy". I have built around it an AutoHotkey function that loops with an 0.5 seconds "Sleep" and return when loading has finished or exit if time out.

1-2. Checks if ctrl+f has found the string and puts "found" in the clipboard else "not_found". I have built around it an AutoHotkey function that send ctrl+f, then the string_to_search, then the 2nd short-cut and exit if "not_found", then {ESC} and return leaving the string selected and you can with "enter" activate the link under it or with "tab" go to the next input area.

1-3. Puts the source in the clipboard. It is equivalent (but easier to synchronize with AutoHotkey) to the sequence ctrl+u, ctrl+a, ctrl+c, AutoHotkey command to close source screen. I have built around it an AutoHotkey function that return the source. Then I extract the information I need with a sub-pattern of RegExMatch. Or do an other string search function to verify if I am on the right screen.

With this you can write and run some scripts without knowledge of html language : you need just your eyes to see the text to select.

Limitations

The limitations are :

- Not all application support navigation by tab.

- "false texts" : they are not in character mode in the source of the page, they are drawn on an image. In this case they are not found with ctrl+f.

- national characters when you are abroad. E.g. in a French application the button to disconnect is often called "Déconnexion" (the French word for the action of disconnecting where the 2nd character is "e with acute accent"). This word was found by ctrl+f without problem on a French PC with French Windows and French FireFox but was not found on a English PC with English Windows and English FireFox : I don't know the reason, nevertheless "e with acute accent" was shown on the screen...

2. The Second Shortcuts

Second batch of short-cuts :

2.1.
'Is this possible to define a new function "find in source and click" that has some similarities to ctrl+f but works on the source'?

The answer of the author of Keyconfig was 'it does exceed my abilities in multiple ways'. I said : 'Something similar is done by the "tag" command of iMacros for Firefox' The author : 'what iMacros does seems to translate the input to "XPath"' FireFox function and gave me a shortcut .

The input parameter is put in the clipboard before short-cut : he said:

You can test some on the iMacros demo page

<!-- m -->http://www.iopus.com...6/pos/index.htm<!-- m -->

by copying one of the following to your clipboard:
nigelle;2;//a[contains(text(),"Click to open this page")]
nigelle;1;//a[@href="page1.htm"]
nigelle;1;//input[@value="your E-mail here"] The format is
identifier;occurrence;XPath while for XPath
//tag[@attribute="value"] or
//tag[contains(text(),"text content")] should cover many cases.'


The clipboard after short-cut contains "Found" (success) or "NotFound" (failure to find) or the text of the internal error in FireFox (generally bad format of the input)...

With this you can activate a link or put the cursor in an input area : this is very powerful, it can do the same as ctrl+f and far more.

For documentation on "XPath" see :
<!-- m -->https://developer.mozilla.org/En/XPath<!-- m -->
<!-- m -->http://www.w3.org/TR/xpath<!-- m -->
<!-- m -->http://www.w3schools.com/xpath/<!-- m -->
<!-- m -->http://www.examplede... ... html?l=rel<!-- m -->With this you can write and run many scripts but with knowledge of html language and format of Xpath.

2.2. Maximizes the window (the AutoHotkey function does not works except in the "run" command). Use this when you don't need to see the background.
2.3. Restores the window to the non-maximized state, I have not used it because often it gives a size of 1x1 inch on my 20" monitor !

3. The Third Shortcuts

Third batch of short-cuts :

3.1. Puts the source of the DOM in clipboard
With an application that modified the content of the window with Javascript, I discovered that there are 2 sources defined in FireFox;

a) source1 the classical source shown by Ctrl+u on a screen with the title : "Source of : <!-- m -->http://url_with_parameters<!-- m --> - Mozilla Firefox". Source1 is not modified by Javascript and is given by 1.3.

B) source2 shown by selecting an area on a screen, right click and choosing "source code of the selection" : the title of the screen is :
"DOM source of the selection - Mozilla Firefox". Normally it shows from the <div> before the selection to the </div> after it. It works also for the full page after ctrl+a .

The present short-cut puts the source of the DOM (of the whole window) in clipboard, I have built an AutoHotkey function that return it.

3.2. Set the window to 3 quarters of the size of the screen. Use this when you need to see the background.

4. The Final Shortcuts

fourth batch of short-cuts

4.1. URL in clipboard
It is equivalent to the sequence ctrl+l, ctrl+c but without the problem of synchronizing the 2 short-cuts.

Known limitations

- The Xpath short-cut does not start a Flash application. As flash simulation is low in my priority list, I have not tested the methods that Imacros uses in this case : clicking at X and Y coordinates when the image of the Flash application does not move or ImageSearch function and click on the found coordinates. I assume they work.

- ControlSend command does not works properly, only Send does the job : you are forced to keep the focus on the FireFox screen and you cannot run another thing during your script, this is annoying when its duration is 10 minutes or more !
I have tried to change, in one of my script that worked fine and in all my functions, "send, keys" to "ControlSend,, keys, %Wtit%" where %Wtit% is the wintittle field corresponding to the application.

a) First I run it keeping the focus on the FireFox screen to see what occurred, the short-cuts did their job but 'Send, "my_userid" ' (after an Xpath call to put the cursor in the userid input area) entered nothing.

I changed this to
clipboard := "my_userid"
ControlSend,, {CTRLDOWN}v{CTRLUP}, %Wtit%
and it worked.

B) Then I tried to run this corrected script, switching to an other window then going back to see what occurred : the script was blocked : the Xpath has put the cursor in the userid area, nothing was entered in this field and the next Xpath to the password has time outed (without putting any result in the clipboard) after more than 40 seconds when normally it takes from 0.3 to 1s to execute with "send, keys" ...

I am an user and not a developer, I cannot give any reason or cure to this behaviour. FireFox ? Its javascript or XUL machine ? AutoHotkey ?

With the fore mentioned limitations, I run happily a few dozens of scripts.

As I am lazy, and does not wish to write more than 3 times the same group of lines, I have many more functions than described here...

So I ask again the question : Do you need that I write an "user manual" ?

This is a big job, I'll not start it without strong request.

P. S.

The format of the original post has been improved by Markup done by Michael@oz .

There is now a Wiki, see :
<!-- m -->http://www.autohotke... ... te_FireFox<!-- m -->
structure given by hugov .

SoLong&Thx4AllTheFish
  • Members
  • 4999 posts
  • Last active:
  • Joined: 27 May 2007
I'm sure some members are interested in automating firefox, but IE seems to be the favourite for automation. I haven't read your post completely yet, but I do wonder how does (or would) your solution compare to using MozRepl <!-- m -->http://www.autohotke...pic.php?t=46974<!-- m --> perhaps you can explain?

nigelle
  • Members
  • 129 posts
  • Last active: Dec 28 2013 04:31 PM
  • Joined: 26 Sep 2008
To hugov
I have gone to the referenced post and also to the posts it referenced : Both require the MozRepl Firefox extension to be installed
1)
<!-- m -->http://search.cpan.o... ... efox-0.15/<!-- m -->
Seems to need high knowledge of Javascript and XUL, does not seems to interface with AHK and its powerful language...
2)
<!-- m -->http://english.docum... ... illert.de/<!-- m -->
The functions defined seem similar to what my(?) short-cuts plus my AHK functions do. But it does not seems to interface with AHK and its powerful language...

Many users thinks that there are too many security problems in IE and that FireFox is better. My solution needs Keyconfig extension (that has also other uses) + AHK and uses its powerful language...

fsnow55
  • Members
  • 36 posts
  • Last active: Jun 07 2011 07:27 PM
  • Joined: 08 Jun 2006
Nigelle, thanks. I think AHK complements FF usage nicely.

BTW, I use a bookmarklet to duplicate a tab, i.e. open up a new tab with the last active URL:
javascript:dtTim=new%20Date();void(window.open(location.href,'w'+dtTim.getTime()))


I can't figure how to open up a new FF window (with last active URL) instead,
since my default setup is to open new windows in tab (which I want to keep, most of the time).

Anyway, here's a simple solution via AHK, making use of FF shortcut keys
(note that ^l and F6 do the same function i.e. to select the location, but I have to use F6 later to get it to work (don't know why 2nd ^l don't work))

#f:: ;;open new Firefox window with present url
; original #f is for Windows Explorer Search
{
send ^l ; select the location
send ^c ; copy the URL
send ^n ; open new window (not tab)
WinWaitActive, Mozilla
WinActivate, Mozilla
send {F6} ; select the location in the new window
send ^v ; replace with last URL
send, {Enter}
return
}


fsnow55

nigelle
  • Members
  • 129 posts
  • Last active: Dec 28 2013 04:31 PM
  • Joined: 26 Sep 2008
I need to give more clarifications.

My scripts are not generally definitions of hot keys but automation of applications : login, going from screens to (half a dozen) screens, extracting data from them or putting data into them, log off. This need synchronization : AutoHotkey should wait till the end of loading of the new window in FireFox, till Firefox has put some information (source, URL, etc.) in the clipboard before processing it, etc. because there is a mixing of Firefox (=short-cuts) and AutoHotkey instructions. In the definition of hot key there are practically only Firefox (=short-cuts) instructions and they execute presently in the order in which they have been stacked : this is easier to do.

To use my method you should :
1) install Keyconfig extension in the Firefox profile you plan to use.
2) define in Keyconfig the special short-cuts.
3) after this you have only to use AutoHotkey language instructions in your script.
E.g. "send, keys_of_the _short-cut", call to the functions you or I have defined, any other instructions.

As nobody is asking for, I'll not write an "user manual".

To fsnow55
Without the short-cuts it is difficult to do something with Firefox : we agree.
With my short-cuts you will need less lines because some of them chain actions.
Do you know that there is an other way to reach a Firefox (if it is your default browser) window knowing its URL ? It is the "run, URL, " AHK instruction see documentation for the exact format. For me, it opens in a new window but this may depend of the options...
I don't like {F6} because its meaning may depend of where you are : in the official Firefox list it is defined in 2 places !
Beware of WinWait_... instructions, it just wait for the appearance of the title line not for the complete loading of the html page.
I have a short text but in French (I have written it for my children) that explain how to create or modify a short-cut in Keyconfig and gives the codes to enter. Are you interested ?

SoLong&Thx4AllTheFish
  • Members
  • 4999 posts
  • Last active:
  • Joined: 27 May 2007
The drawback of your solution is that it is hard to exchange scripts between users as you would have to make sure the same shortcut performs the same function. But interesting concept none the less, perhaps I'll have a look at keyconfig and see how that works.

nigelle
  • Members
  • 129 posts
  • Last active: Dec 28 2013 04:31 PM
  • Joined: 26 Sep 2008
I already exchange scripts with my children...
But OK this need standardization and more than you say : I have sent to my children :
1) For each short-cut, the code used by FF and the combination of letters to use (generally it has a meaning).
2) My library of functions "commonX.ahk" (X is a version number, I have an "#Include %A_ScriptDir%\commonX.ahk" at the top of my scripts). Each function call its corresponding short-cut using the combination defined in 1). There are also defined global variables to pass some data from one function to the others or from the script to the functions.
3) Some scripts, but they can also write their ones.

tim1
  • Guests
  • Last active:
  • Joined: --
At work we had good success with the free iMacros Firefox (its open source, too). So unless you need the Flash or Image Recognition features of their PRO Edition (we don't!) the free version works very well for us.

iMacros for Firefox supports JavaScript Macros (Scripting)
JavaScript supports Java via LiveConnect

Therefore: You can write powerful macros with iMacros for Firefox. Have a look at this one: http://forum.iopus.c... ... 727#p22731

Tim

a_h_k
  • Members
  • 681 posts
  • Last active: Oct 27 2012 04:50 AM
  • Joined: 02 Feb 2008

ControlSend command does not works properly, only Send does the job : you are forced to keep the focus on the FireFox screen and you cannot run another thing during your script, this is annoying when its duration is 10 minutes or more !

Just an idea :idea: .. might work?: Put Firefox in an "virtual desktop" screen --> that way Firefox can be always active (& using Send) even though can't see it ("hidden" in an its-own virtual desktop)

I have a short text but in French (I have written it for my children) that explain how to create or modify a short-cut in Keyconfig and gives the codes to enter. Are you interested?

Yes, please!. I've had keyconfig for "ages" but have never understand even how to change the hotkeys via it!! :oops:

My library of functions "commonX.ahk"

Could you share this libray here? :D

nigelle
  • Members
  • 129 posts
  • Last active: Dec 28 2013 04:31 PM
  • Joined: 26 Sep 2008
To a_h_k
Where can I find documentation on "virtual desktop" : I know nothing about it.
"short text" sent by PM.
To use "commonX.ahk" you need a documentation on what do the functions that I have not written, the functions give messages in French that I should localize or at least translate in English. That is a big job !
Are there interested people in sufficient number ?

Michael@Oz
  • Members
  • 234 posts
  • Last active: Dec 30 2011 11:24 PM
  • Joined: 08 Nov 2009

Are there interested people in sufficient number ?

+1 YYYEEESSS :D

Even without the translation would be useful, I've been looking for a good AHK FF method for a while now.

a_h_k
  • Members
  • 681 posts
  • Last active: Oct 27 2012 04:50 AM
  • Joined: 02 Feb 2008

Where can I find documentation on "virtual desktop"

Try Desk Illusion:D

"short text" sent by PM

Eh? I did not receive no PM?:?

To use "commonX.ahk" you need a documentation on what do the functions that I have not written, the functions give messages in French that I should localize or at least translate in English. That is a big job !

Maybe you could share it here .. and ahk (community) can translate it??:wink:

nigelle
  • Members
  • 129 posts
  • Last active: Dec 28 2013 04:31 PM
  • Joined: 26 Sep 2008
Desk illusion
Not too much information on the link given. Proposed site for download is in Russia : that may be a dangerous file : trojan, virus or other malware . I have not dared to download it !
Have you used it ?

What are your need ?
1) short text that explain how to create or modify a short-cut in Keyconfig and gives the codes to enter. The part to translate is around 10 lines that may be done rapidly.
2) what the functions do probably 100 to 200 lines.
3) documentation (100 lines) on the format of input to the Xpath function implemented in FF. Do you need this or do you have already knowledge of it ?
4) 1 or 2 examples of scripts e.g. to logon to the AHK forum and go to it (to be written) ? Probably easy with my experience and useful for you to to start.

What are your priorities ?
a) short text as is (French).
B) short text translated and re-formatted with "Code" to forum standard.
c) "commonX.ahk" as is (French).
d) "commonX.ahk" translated.
e) what the functions do.
f) format of input to the Xpath function.
g) examples of scripts.
Please give me the order for posting them as a string, e.g.
a)c)e)b)g)f)d) most important first...

a_h_k
  • Members
  • 681 posts
  • Last active: Oct 27 2012 04:50 AM
  • Joined: 02 Feb 2008

Desk illusion
Not too much information on the link given. Proposed site for download is in Russia : that may be a dangerous file : trojan, virus or other malware . I have not dared to download it !
Have you used it ?

Microdesk comes with a big amount of utilities with wich you can easily configure your program.

Note: Some antivirus and antispyware programs flag ... as being infected/malware, although the application is perfectly safe and does not pose a threat to your system. This is called a 'false positive'. The term false positive is used when antivirus software wrongly classifies an innocuous ( inoffensive ) file as a virus. The incorrect detection may be due to heuristics or to an incorrect virus signature in a database. [Similar problems can occur with antitrojan or antispyware software

Microdesk installation package is prepared to be downloaded from our fast download servers. It is chcecked for possible viruses and is proven to be 100% clean and safe. Various leading antiviruses have been used to test Microdesk, if it contains any viruses. No infections have been found and downloading Microdesk is completelly problem free because of that reason. Our experts on malware detection tested Microdesk with various spyware and malware detection programs, including fyxm.net custom malware and spyware detection, and absolutelly no malware or spyware was found in Microdesk

I've used it, & works goodly. However my anti-virus does says its "Trojan horse Generic11.BKSP", which is either true or a false positive
So far it hasn't don't anything "abnormal" on my pc, didn't create any "extra" files or modify any files .. but who knows it may in registry a secretive keylogger or something!?
But you may use an older "safe" version here (less features)

What are your need ?
1) short text that explain how to create or modify a short-cut in Keyconfig and gives the codes to enter. The part to translate is around 10 lines that may be done rapidly.
2) what the functions do probably 100 to 200 lines.
3) documentation (100 lines) on the format of input to the Xpath function implemented in FF. Do you need this or do you have already knowledge of it ?
4) 1 or 2 examples of scripts e.g. to logon to the AHK forum and go to it (to be written) ? Probably easy with my experience and useful for you to to start

Yes, that would be good :)

I'm a newbie concerning firefox scripting/shortcutting, and want to start do some scripting for it

What are your priorities ?
a) short text as is (French).
B) short text translated and re-formatted with "Code" to forum standard.
c) "commonX.ahk" as is (French).
d) "commonX.ahk" translated.
e) what the functions do.
f) format of input to the Xpath function.
g) examples of scripts.
Please give me the order for posting them as a string, e.g.
a)c)e)b)g)f)d) most important first...

My priority are: a --> g --> c/e --> f --> b/d

nigelle
  • Members
  • 129 posts
  • Last active: Dec 28 2013 04:31 PM
  • Joined: 26 Sep 2008
g) examples of scripts.
1) AHKlogA.ahk log your user-id to AHK forum using the ctrl+F to select a text then navigate by tab except to check the check-box where it use Xpath because I have not found an other solution to click it. There ample comments to explain the use of functions because the text e) what the functions do does not yet exist.
Run, www.autohotkey.com/forum/login.php,Max ; i.e. any URL can be launched.
#Include %A_ScriptDir%\commonB.ahk ; my library of functions + variables initialization
;deb := A_Now ; start time used by dur(deb) at the bottom of script
user := "abcdef" ; change to your user name
pass := "ghijklm" ; change to your password
fnl = %logdir%AHKforum%A_YDay%.log ;normal log file
FileAppend, %A_Now% **** %A_ScriptName% `n, %fnl%
;fnErr = %logdir%Err.log ; error log file
wher := "AHK login screen" ; where we are
rc := fini() ; wait till loading FINIshed, if timeout exit, rc=elapsed time
rc := versourc("AutoHotkey Community Forum") ; VERify that SOURCe include the argument i.e. that we are on an AHK forum screen
; See also other VERify functions : vertit(x) for title, verURL(x) for URL
IfNotInString, source, >Log in<  ; source has already been initialized by versource function, ">Log in<" is in the line source defining login button 
{
	ster := wher " * already logged to an AHK forum screen" ; error message
	rc := err1(ster,fnErr) ; process the error : log it and exit
}
rc := slect("forgot my password") ; SeLECT the argument if found else exit
Sleep, 500
Send, {SHIFTDOWN}{TAB}{TAB}{TAB}{TAB}{SHIFTUP}%user%{TAB}
Sleep, 500 
Send, %pass%
Sleep, 500 
; sorry to use Xpath : a tab bring me to caret position x=4 y=151 but how to translate this to the cursor position 818 471 for click instruction ?
rc := nxpath("nigelle;1;//input[@name='autologin']") ; checkbox "Log me on automatically each visit"
; format of nxpath is identifier;occurrence;XPath while for XPath //tag[@attribute='value'] or //tag[contains(text(),'text content')] which does the
; equivalent of ctrl+F should cover many cases. Xpath support ' and " as string delimiters. identifier "nigelle" is a place holder the same as in
; shortcut * "1" means occurence of rank 1 * "input"  the name of the html tag * "name" the attribute * "autologin" its value * the tag to click on
;is defined in source line below
;<td colspan="2"><span class="gen">Log me on automatically each visit: <input name="autologin" type="checkbox"></span></td>
Random, rand, 900, 1500 ; random sleep gives more realistic simulation
Sleep, %rand%
Send, {ENTER}
wher := "AHK forum " ; where we are
rc := fini()
rc := versourc("AutoHotkey Community Forum") ; we are on an AHK forum screen
IfNotInString, source, >Log out [  ;  ">Log out [" is in the line source defining logout button 
{
	ster := wher " * Not logged " ; error message
	rc := err1(ster,fnErr) ; process the error : log it and exit
}
st := "AHK forum loged `n " ; success message with end of line
FileAppend, %st%, %fnl% ; log success message
rc := Dur(deb) ; log DURation of script
exit ; end of script
2) AHKlogB.ahk does the same thing but using the Xpah function to select a tag in the DOM and click on it.
Run, www.autohotkey.com/forum/login.php,Max ; i.e. any URL can be launched.
#Include %A_ScriptDir%\commonB.ahk ; my library of functions + variables initialization
;deb := A_Now ; start time used by dur(deb) at the bottom
user := "abcdef" ; change to your user name
pass := "ghijkl" ; change to your password
fnl = %logdir%AHKforum%A_YDay%.log ;normal log file
FileAppend, %A_Now% **** %A_ScriptName% `n, %fnl%
;fnErr = %logdir%Err.log ; error log file
wher := "AHK login screen" ; where we are
rc := fini() ; wait till loading FINIshed, if timeout exit, rc=elapsed time
rc := versourc("AutoHotkey Community Forum") ; VERify that SOURCe include the argument i.e. that we are on an AHK forum screen
IfNotInString, source, >Log in<  ; source has already been initialized by versource function, ">Log in<" is in the line source defining login button 
{
	ster := wher " * already logged to an AHK forum screen" ; error message
	rc := err1(ster,fnErr) ; process the error : log it and exit
}
rc := nxpath("nigelle;1;//input[@name='username']") ; move to start of username field
; format of nxpath is identifier;occurrence;XPath while for XPath //tag[@attribute='value'] or //tag[contains(text(),'text content')] which does the
; equivalent of ctrl+F should cover many cases. Xpath support ' and " as string delimiters. identifier "nigelle" is a place holder the same as in
; shortcut * "1" means occurence of rank 1 * "input"  the name of the html tag * "name" the attribute * "username" its value * the tag to click on
;is defined in source line below
;<input class="post" name="username" size="25" maxlength="40" value="" type="text">
Sleep, 500
Send, %user%
rc := nxpath("nigelle;1;//input[@name='password']") ; password field
;<input class="post" name="password" size="25" maxlength="32" type="password">
Sleep, 500 
Send, %pass%
rc := nxpath("nigelle;1;//input[@name='autologin']") ; checkbox "Log me on automatically each visit"
;<td colspan="2"><span class="gen">Log me on automatically each visit: <input name="autologin" type="checkbox"></span></td>
Random, rand, 900, 1500 ; random sleep gives more realistic simulation
Sleep, %rand%
Send, {ENTER}
wher := "AHK forum" ; where we are
rc := fini()
rc := versourc("AutoHotkey Community Forum") ; we are on an AHK forum screen
IfNotInString, source, >Log out [  ;  ">Log out [" is in the line source defining logout button 
{
	ster := wher " * Not logged " ; error message
	rc := err1(ster,fnErr) ; process the error : log it and exit
}
st := "AHK forum loged `n " ; success message with end of line
FileAppend, %st%, %fnl% ; log success message
rc := Dur(deb) ; log DURation of script
exit ; fin script

a) short text as is (French).
15/nov./2009 13:46
1) Définir les raccourcis supplémentaire nécessaire à AHK.
Ouvrir Firefox , onglet outils, chez moi dans le cadre du bas, choisir "configurer les clés" Ctrl+Maj+F12 dans le petit écran qui s'ouvre "nouvelle clé" ouvre un petit écran "identité" = nom de la clé champ name: par exemple "AHK chargement en cours" : ça sert à la retrouver car les clés sont listées par ordre alphabétique (d'où l'intérêt du préfixe AHK), cliquer là où il y a "code:" qui disparaît et y coller ce qui est entre "code:" et la ligne de --- qui sert de séparateur uniquement pour la clarté de mon fichier puis OK on revient dans l'écran précédent (étiquette chez moi) aller cliquer dans la première case du bas qui est vide et contiendra la combinaison
enfoncer toute les touches modificatrices (Ctrl Maj alt etc.) puis la lettre (par exemple Alt et Ctrl puis b) on voit apparaître la combinaison (par exemple Alt+Ctrl+B) qui constitueront le raccourci cliquer sur appliquer puis fermer. 

2) Modifier un raccourci existant
Ouvrir Firefox , Ctrl+Maj+F12, dans le petit écran qui s'ouvre cliquer sur la clé qu'on veut modifier, si elle est modifiable on a sur l'écran "éditer cette clé" : cliquer, faire les modifications (par exemple ajouter "AHK " devant le nom), OK puis Appliquer.

3) Liste des raccourcis
La ligne de "---------------" ne fait pas partie du code : elle n'est là que pour séparer les raccourcis.
AHK chargement en cours Ctrl Alt b
name: AHK Chargement en cours, id: xxx_key__AHK Chargement en cours, shortcut: Alt+Ctrl+B, code:
    var ClipboardHelper = Components.classes["@mozilla.org/widget/clipboardhelper;1"]
    .getService(Components.interfaces.nsIClipboardHelper);

    ClipboardHelper.copyString( gBrowser.mIsBusy ? "Busy" : "NotBusy" ); 
---------------------------------------------------------------------------------------------
rechercher résultat trouvé ou pas
name: AHK Rechercher resultat, id: xxx_key__AHK Rechercher resultat, shortcut: Ctrl+Maj+F, code:
    var ClipboardHelper = Components.classes["@mozilla.org/widget/clipboardhelper;1"]
    .getService(Components.interfaces.nsIClipboardHelper);

    if(gFindBar._findField.getAttribute("status") == "notfound")
     ClipboardHelper.copyString("not_found");
    else
     ClipboardHelper.copyString("found"); 
-------------------------------------------------------------------------------------------------
Source dans clipboard
name: AHK Source clipboard, id: xxx_key__AHK Source clipboard, shortcut: Ctrl+Maj+U, code:
var ClipboardHelper = Components.classes["@mozilla.org/widget/clipboardhelper;1"]
.getService(Components.interfaces.nsIClipboardHelper);

var request =  new XMLHttpRequest();
request.open("GET", "view-source:"+content.location, false);
request.send(null);

ClipboardHelper.copyString(request.responseText.replace(/\n/g,"\r\n"));
-------------------------------------------------------------
Maximiser l'écran
name: AHK Maximise, id: xxx_key__AHK Maximise, shortcut: Ctrl+Maj+M, code:
    window.maximize();  
-------------------------------------------------------------
Minimiser l'écran (n'est utilisé par aucun script)
name: AHK Minimise, id: xxx_key__AHK Minimise, shortcut: Ctrl+M, code:
    window.restore();  
-------------------------------------------------------------
Xpath sélecte un tag html et clique dessus
name: AHK Xpath, id: xxx_key__AHK Xpath, shortcut: Ctrl+Q, code:
    var ClipboardHelper = Components.classes["@mozilla.org/widget/clipboardhelper;1"]
    .getService(Components.interfaces.nsIClipboardHelper);

    var clipboard = readFromClipboard().match(/(nigelle);([0-9]+);(.*)/);
    if(!clipboard) return;

    try {
    var node = content.document.evaluate(clipboard[3], content.document, null, 7, null).snapshotItem(clipboard[2]-1);
    } catch(err) { ClipboardHelper.copyString(err); return; }

    if(!node) {
     ClipboardHelper.copyString("NotFound"); return;
    }

    ClipboardHelper.copyString("Found");
    node.focus();

    var e = content.document.createEvent("MouseEvents");
    e.initMouseEvent("click", true, true, null, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
    node.dispatchEvent(e); 

-------------------------------------------------------------
Alt Maj u
nom :
AHK DOM dans clipboard
avec le code :
    var node = content.document.documentElement.cloneNode(true);
    var dummy = content.document.createElement("dummy");
    dummy.appendChild(node);

    html = dummy.innerHTML.replace(/\n/g,"\r\n");

    var ClipboardHelper = Components.classes["@mozilla.org/widget/clipboardhelper;1"]
    .getService(Components.interfaces.nsIClipboardHelper);
    ClipboardHelper.copyString(html); 
-------------------------------------------------------------

c) "commonB.ahk" as is (French) : my library
fini()
{
  global wher, fnErr, st, fnl
  StartTime := A_TickCount
  bu = 1
  Loop, 140 ; sleep 100+100+300 = 0.5 s., part. 1 0.5x40=20 s., part. 2 0.5x100=50 s.
  {
    clipboard =  ; Start off empty to allow ClipWait to detect when the text has arrived.
    Sleep, 100
    Send, {CTRLDOWN}{ALTDOWN}b{ALTUP}{CTRLUP}
    Sleep, 100
    ClipWait, 10  ; Wait for the clipboard to contain text.
    if ErrorLevel
    {
      continue
    }
    If clipboard = NotBusy
    {
      bu = 0
      break
    }
    If a_index = 40 ; 20 s.
    {
      Send, {ESC} ; stop
      Sleep, 300
      Send, {CTRLDOWN}{SHIFTDOWN}r{SHIFTUP}{CTRLUP} ; Reload (override cache)
      Sleep, 300
    }
    Sleep, 300
  }
  ElapsedTime := A_TickCount - StartTime
  If bu
    {
      ster := wher " * Dépassement temps de chargement " . ElapsedTime . " ms `n "
      rc := err1(ster,fnErr)
    }
;  MsgBox, , , temps de chargement %ElapsedTime% ms. %wher% ,4
  return ElapsedTime ; >1
}
;--------
slect(x)
{
  global wher, fnErr, st, fnl
  Loop, 2
  {
    Send, {CTRLDOWN}f{CTRLUP}
    Sleep, 300
    Send, %x%
    clipboard =  ; Start off empty to allow ClipWait to detect when the text has arrived.
    Sleep, 100
    Send, {CTRLDOWN}{SHIFTDOWN}f{CTRLUP}{SHIFTUP}
    ClipWait, 10  ; Wait for the clipboard to contain text.
    if ErrorLevel
      {
        continue ;2nd try
      }
    break
  }
  If clipboard = found 
  {
    rc = 0
  } else {
    ster := wher " * Erreur slect(" . x . ") : pas trouvé. `n "
    rc := err1(ster,fnErr)
  }
  Sleep, 100
  Send, {ESC}
  Sleep, 500
  return rc   ; rc=0 OK , rc=1 KO x not found or clipwait timeout
}
;--------
nxpath(x)
{
  global wher, fnErr, st, fnl
  clipboard := x
  Sleep, 100
  Send, {CTRLDOWN}q{CTRLUP}
  rc := WClipChange(x)
  If clipboard <> Found 
  {
    ster := wher " * Erreur Xpat(" . x . ") `n " . clipboard . " `n "
    rc := err1(ster,fnErr)
  }
  Sleep, 100
  return rc   ; rc>1 OK
}
;---------
rxpath(x)
{
  global wher, fnErr, st, fnl, stertxp
  clipboard := x
  Sleep, 100
  Send, {CTRLDOWN}q{CTRLUP}
  rc := WClipChange(x)
  If clipboard = Found ; OK
  {
    return rc   ; rc>1 OK
  }
  stertxp := wher " * Erreur Xpat(" . x . ") `n " . clipboard . " `n "
  If clipboard = NotFound
  {
    return 0  ; rc=0 KO récupérable
  }else{
    rc := err1(stertxp,fnErr) ; KO non récupérable
    return rc  
  }
}
;---------
WClipChange(x)
{
  global wher, fnErr, st, fnl
  StartTime := A_TickCount
  KO = 1
  Loop, 100 ; 10 seconds
  {
    Sleep, 100
    If clipboard <> %x%
    {
      KO = 0
      break
    }
  }
  ElapsedTime := A_TickCount - StartTime
  If KO
    {
      ster := wher " * Dépassement temps ClipChange " . ElapsedTime . " ms `n "
      rc := err1(ster,fnErr)
    }
  return ElapsedTime  ; If OK , rc > 1
}
;--------
err1(x,y)
{
  global st, fnl
  MsgBox %x%
  ster := "**** " . A_Now . " " .  A_ScriptName . "`n" . x . " `n "
  FileAppend, %ster%, %y%
  rc := Purgelog()
  Exit
  return 1   ; rc=0 OK , rc=1 KO
}
--------
err1s(x,y)
{
  global st, fnl, source
  MsgBox %x%
  ster := "**** " . A_Now . " " .  A_ScriptName . "`n" . x
  ster .= "`n ******source*** `n" . source . "`n ************ `n"
  FileAppend, %ster%, %y%
  rc := Purgelog()
  Exit ; err1s = err1 + log source
  return 1   ; rc=0 OK , rc=1 KO
}
;--------
errClipW(x)
{
  global wher, fnErr, st, fnl
  ClipWait, 10  ; Wait for the clipboard to contain text.
  if ErrorLevel
  {
    ster := wher " * Erreur ClipWait dans fonction " . x . " `n "
    rc := err1(ster,fnErr)
  }
  return 1
}
;--------
VerREMatch(x,y)
{
	global wher, fnErr, st, fnl
	If x = 0
	{
		ster := wher " * Erreur RegExMatch pour " . y . " : rien trouvé `n "
		rc := err1s(ster,fnErr)
	}
  Sleep, 100
  return 0   ; rc=0 OK , rc=1 KO
}
;--------
ErrREMatch(x)
{
  global wher, fnErr, st, fnl
  ster := wher " * Erreur RegExMatch pour " . x . " : rien trouvé `n "
  rc := err1s(ster,fnErr)
  Sleep, 100
  return rc   ; rc=0 OK , rc=1 KO
}
;--------
Purgelog()
{
  global st, fnl
  st .= "`n **** Purge " . A_Now . " " .  A_ScriptName . "`n"
  FileAppend, %st%, %fnl%
  return 0   ; rc=0 OK , rc=1 KO
}
;--------
sourc()
{
  clipboard =  ; Start off empty to allow ClipWait to detect when the text has arrived.
  Send, {CTRLDOWN}{SHIFTDOWN}u{SHIFTUP}{CTRLUP}
  errClipW(A_ThisFunc) ; ClipWait, 10 : 10 s. avec gestion d'ErrorLevel
  return clipboard ; source
}
;--------
sdom()
{
  clipboard =  ; Start off empty to allow ClipWait to detect when the text has arrived.
  Send, {ALTDOWN}{SHIFTDOWN}u{SHIFTUP}{ALTUP}
  errClipW(A_ThisFunc) ; ClipWait, 10 : 10 s. avec gestion d'ErrorLevel
  return clipboard ; source du DOM
}
;--------
maxim()
{
  Send, {CTRLDOWN}{SHIFTDOWN}m{SHIFTUP}{CTRLUP}
  Sleep, 200
  return 0
}
;--------
vertit(x)
{
  global wher, fnErr, Title, st, fnl
  WinGetTitle, Title, A
  IfNotInString, Title, x
  {
    ster := wher " * Erreur titre = " . Title . " `n "
    rc := err1(ster,fnErr)
  }
  return 0   ; rc=0 OK , rc=1 KO
}
;--------
versourc(x)
{
  global wher, fnErr, source, st, fnl
  source := sdom()
;    FileAppend, %source%, %fnErr%
  IfNotInString, source, x
  {
    ster := wher " * Erreur : source ne contient pas " . x
    rc := err1s(ster,fnErr)
    return 1   ; rc=0 OK , rc=1 KO
  }
  return 0   ; rc=0 OK , rc=1 KO
}
;--------
verURL(x)
{
  global wher, fnErr, st, fnl, vURL
  vURL := retURL()
  If vURL = %x%
    return 0   ; rc=0 OK , rc=1 KO
  Else
  {
    ster := wher " * Erreur : URL = " . vURL . "`n au lieu de " . x
    rc := err1(ster,fnErr)
    return 1   ; rc=0 OK , rc=1 KO
  }
}
;--------
retURL()
{
  clipboard =  ; Start off empty to allow ClipWait to detect when the text has arrived.
  Send, {ALTDOWN}{SHIFTDOWN}l{SHIFTUP}{ALTUP}
  errClipW(A_ThisFunc) ; ClipWait, 10 : 10 s. avec gestion d'ErrorLevel
  Sleep, 100
  return clipboard ; URL
}
;--------
URLcont(x)
{
  global wher, fnErr, st, fnl
  vURL := retURL()
  IfInString, vURL, %x%
  return 0   ; rc=0 OK , rc=1 KO
  Else
  {
    ster := wher " * Erreur : URL = " . vURL . "`n ne contient pas " . x
    rc := err1(ster,fnErr)
    return 1   ; rc=0 OK , rc=1 KO
  }
}
;--------
Dur(x)
{
  global fnl
  y := A_Now
  EnvSub, y, %x%, seconds
  min := y // 60
  sec := mod(y,60)
;  FileAppend, ********* %A_Now% %y% s %min% min %sec% s `n, %fnl%
  FileAppend, ********* %A_Now% %min% min %sec% s `n, %fnl%
}
;--------
; initialize always used variables
wher := " ??? " ; if you see this, that means that it has not been defined in the script
st := " ... " ; nothing yet to put in normal log file
logdir = %A_ScriptDir%\Log\ ; Répertoire des log : mettre à jour si nécessaire, ici le repertoire des scripts AHK suivi de Log.
fnErr = %logdir%Err.log ; standard error log file : one should be defined
deb := A_Now ; start time used by dur(deb) at the bottom of script

Good luck ! I hope that you have enough knowledge of AHK to understand what I do. I think that next step will be B) short text translated.

I'll be away till Sunday afternoon.