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
I have forgotten to say that with the example scripts you should edit them to put your user-id and password in the variables user and pass (else you will receive "not logged" error message), you should not be logged (else you will receive "already logged" error message).

awannaknow
  • Members
  • 372 posts
  • Last active: Mar 03 2019 05:18 AM
  • Joined: 14 Jun 2009
I read this thread with a great interest.
As a noob, I understand only some part.
Say 50 %
I repetively try to automate, with ahk, iMacros, etc..., login in, filling form, login out and multiple actions that could be done online.
. . . Without much success . . .
:oops: 8) :shock:

Pleazzze, you may correct my below writing, as I try to put the small knowledge I may have in it :
Apparently there is no easy way to input/output actions/datas online.

I mainly use Opera as my only browser and never succeeded in automating anything in it.

One browser may be better than an other to automate internet things, but which one ?

It may be done better with an ahk gui browser type or ahk online command line, I mean no need for an interface, just datas/actions exchange between client/server.

I noticed that since the emergence of new web languages/technologies -aka xml, ajax, etc..., web site I used to partly automate with some success are now unresponsive to my attempts.

HttpS, which is usually the protocol used by web sites I need to automate from, make my attempts useless 100% of the time . . .
:?

Until I read this thread, which gives lots of details on how to do it, I wondered how others did it.
Especially how skilled people did it.
I imagine they use very fast and efficient client/server data flow without gui browser, just parsing html/xml/or wathever code/data to do what it has to be done in a 10th of the time needed to do it thru a gui browser.

But what I've read here is quite similar, althought much better, than the way I've tried to do it up to now.

It may be a better way, but it may need very specific knowledge about it.

That's all for today folks ! !
:D

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

Good luck ! I hope that you have enough knowledge of AHK to understand what I do.

Thank You! :D

I just had a quick look, seems to make sense. I'm sure if I need to I could try online translators... :D

Merci de partager cette pièce magnifique de code :wink: Blame Google if I said anything offensive :)

nigelle
  • Members
  • 129 posts
  • Last active: Dec 28 2013 04:31 PM
  • Joined: 26 Sep 2008
To Michael@oz
Nothing offensive : apparently Google translation was good !
I agree that a translated version is better, wait for it... But you point to a good idea : if I have a .txt file in French, how can I obtain the same text in English with Google and check/correct it. As Italian people say "tradutore, traditore" that means "translator = traitor".

To "awannaknow"
I have not yet written a script login to an HttpS site. Firefox should process it transparently but we have to test !
I have not used Opera since 3 or 4 years, I don't know how to interface to it with a program.
I don't like IE due to its security problems.
AHK does not interface so well with Firefox : you need the short-cuts to bridge between them with good results.
I don't know a browser with an programming language integrated in it. It is probably a big thing to develop.
As the post of "tim1" shows you can do many things with "iMacros for Firefox" if you know it + Javascript + Java in their object versions (not basic) that is not my case...
I have not yet practised Chrome (I don't like its user licence). Does it has now the equivalent of extensions ?
My dream is a Firefox extension (as iMacros) integrating also my functions and the instructions of the AHK language... An hybrid of Imacros and AHK !

To others
I have changed my mind : my next job is to write a text on the "reserved variables" that are global in my library. If you use one of them with an other meaning you may probably obtain strange results !

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

To Michael@oz
if I have a .txt file in French, how can I obtain the same text in English with Google and check/correct it. As Italian people say "tradutore, traditore" that means "translator = traitor".

Google Translation of your short text.
15/nov./2009 13:46
1) Define the necessary additional shortcuts to AHK.
Open Firefox, Tools tab, at home in the bottom frame, choose "configure keys" Ctrl + Shift + F12 in the small screen that opens "new key" opens a small screen "identity" = key name field name: eg "AHK loading in progress": it serves to trace because the keys are listed alphabetically (hence the interest of the prefix AHK), click where it is "code" that disappears and paste what is between "code" and the line --- separator used only for the clarity of my file is OK then returns to the previous screen (home label) go click in the first box at the bottom is empty and contain a combination
press any modifier keys (Ctrl Alt Shift etc.) then the letter (eg Alt and Ctrl then B) we see a combination (eg Alt + Ctrl + B) which constitute the shortcut click apply then close.

2) Modify an existing shortcut
Open Firefox, Ctrl + Shift + F12, in the small screen that opens click the key you want to change, if it has changed on the screen "edit this key" click, make changes (for example adding "AHK" before the name), OK then Apply.

3) List of shortcuts
The line "---------------" not part of the code: it is only there to separate shortcuts.
AHK is being loaded Ctrl Alt b
name: AHK loading, id: xxx_key__AHK loading, shortcut: Ctrl + Alt + B Code:
var ClipboardHelper = Components.classes [ "@ mozilla.org / widget / clipboardhelper; 1"]
. getService (Components.interfaces.nsIClipboardHelper);

ClipboardHelper.copyString (gBrowser.mIsBusy? "Busy": "NotBusy");
-------------------------------------------------- -------------------------------------------
search result found or not
name: AHK search result, id: xxx_key__AHK search result, shortcut: Ctrl + Shift + 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 from clipboard
name: AHK Source clipboard, id: xxx_key__AHK Source clipboard, shortcut: Ctrl + Shift + 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"));
-------------------------------------------------- -----------
Maximize screen
name: Maximize AHK, id: Maximize xxx_key__AHK, shortcut: Ctrl + Shift + M code:
window.maximize ();
-------------------------------------------------- -----------
Minimize the screen (not used by any script)
name: Minimizes AHK, id: Minimizes xxx_key__AHK, shortcut: Ctrl + M, code:
window.restore ();
-------------------------------------------------- -----------
Xpath selects an html tag and clicked
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 (/ (Nigel) ([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 Shift u
Name:
AHK DOM clipboard
with the 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);
-------------------------------------------------- -----------
:)
See http://translate.goo.../?hl=en&tab=nT# click the upload... link

ps I haven't checked anything in the translation.

nigelle
  • Members
  • 129 posts
  • Last active: Dec 28 2013 04:31 PM
  • Joined: 26 Sep 2008
Now it is the text on reserved variables.
Reserved variables
You may find examples of their uses in the library (where most of them are "global") or in the scripts.

The "log" variables :
1)logdir The full path of the directory where you put the log files. I have defined it as logdir = %A_ScriptDir%\Log\ which is the sub directory "Log" of the directory of AHK scripts. So the scripts and the log are separated but near : you can go easily from one to the other. I have put this in the library because there is no need to change this.
2) fnErr The full path name of the standard error log file. I have defined it as fnErr = %logdir%Err.log . One should be defined but you don't need several because it is hopefully not used often. I have put it in the library because there is no need to change this.
3) ster The string, defining the error message, passed to the error processing function which writes it to the error log and show it in a MsgBox.
4) fnl The full path name of the normal log file. I define it, in each script, as fnl = %logdir%Xyz%A_YDay%.log  where Xyz characterizes the script for you. I have put %A_YDay% in the name to have a log per day. You have to code in the script the writes to the log. The first record is for me : FileAppend, %A_Now% **** %A_ScriptName% `n, %fnl%  it is useful to have in the log the exact name of the script if you have several versions of it. The last record is written for me by the dur(x) function that put the DURation in it. x is the %A_Now% or start time of the script.
5) st The string defining the message to put in the normal log. As st can be constructed by concatenating pieces at each iteration of a loop, the content of st is "purged" (written) to the normal log file in case of error. There is a trap in the library st := " ... "  if you have not defined st in the script.

The other variables :
6) wher The string defining WHERe we are. It is included in error messages and useful to know where the error has occurred ! There is a trap in the library wher := " ??? "  if you have not defined wher in the script.
7) source is the source of the html page or of the DOM.
8) Title The string defined by AHK instruction giving the Title line of the page.
9) vURL The string containing the URL of the page.
10) deb %A_Now% i.e. the start time used by dur(deb) at the bottom of the script. I have put it in the library because it is used by all my scripts deb := A_Now . You may change it but in both the library and dur(deb) at the bottom of script.
11) stertxp the error string of Rxpath() may be sometimes needed in the script out of the function in case of "NotFound".

Now I need your opinion :
Do we keep the functions and the initialization of the always used variables in the library as I have done or do we use 2 separate files one for functions, the other for variables ?
 That needs 2 #Include instructions but is more flexible.

To Michael@oz
I'll answer your post after checking the Google translation. Thanks for your help !

Edited Jan 27 : stertxp added.

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

Do we keep the functions and the initialization of the always used variables in the library as I have done or ...

Seems fine where they are now, but I have yet to do any large modularised AHK coding yet, so others would be more qualified to comment.

As soon as I started reading the translated text it all [mostly] became clear. I was trying to find the keycodes in your library functions in keyconfig.

I started adding the codes but decided to wait, as the translation of some Names seemed to be just a bit off, wouldn"t want to have a proliferation of dodge key names.

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

- 2nd set the window to 3 quarters of the size of the screen. Use this when you need to see the background.

4) fourth batch of short-cuts : only 1, URL in clipboard
It is equivalent to the sequence ctrl+l, ctrl+c but without the problem of synchronizing the 2 short-cuts.


Your shortcut text doesn't seem to include these two?

b.
So I have finally read through all your code and shortcuts, :idea:

Very Nice Job
:D

Can I just point out one trivial thing...tiny little thing, not to take anything away for your work...

name: AHK search result, ...
ClipboardHelper.copyString ( "Not_found");
else
ClipboardHelper.copyString ( "found");

All the other results are Capitalised. Perhaps change it to 'Found'? Will also need to change in slect(x).
Yes, I know I'm a pedantic retentive etc... :oops:

a_h_k
  • Members
  • 685 posts
  • Last active: Sep 28 2015 12:32 AM
  • Joined: 02 Feb 2008
Here is CommonX translated... :)
Edit: Now referred to as CommonC
/*
My library
*/

;-------------------------------------------------------------------------------------------------------------------------------
Finished()
{
  Global wher, fnErr, st, fnl
  StartTime := A_TickCount
  bu = 1
  Loop, 140							;Sleep 100+100+300 = 0.5s -- part 1: 0.5 x 40 = 20s -- part 2: 0.5 x 100 = 50s
  {
    clipboard =							;Start off empty to allow ClipWait to detect when the text has arrived
    Sleep, 100
    Send, {CTRL DOWN}{ALT DOWN}b{ALT UP}{CTRL UP}
    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, {CTRL DOWN}{SHIFT DOWN}{SHIFT UP}r{CTRL UP}			;Reload (override cache)
      Sleep, 300
    }
    Sleep, 300
  }
  ElapsedTime := A_TickCount - StartTime
  If bu
    {
      ster := wher " * Timeout loading " . ElapsedTime . " ms` n "
      rc := err1(ster, fnErr)
    }
  ;MsgBox,, loading time% %ElapsedTime% ms. %Wher%, 4
  return ElapsedTime							;>1
}
;-------------------------------------------------------------------------------------------------------------------------------
slect(x)
{
  Global wher, fnErr, st, fnl
  Loop, 2
  {
    Send, {CTRL DOWN}f{CTRL UP}
    Sleep, 300
    Send,% x%
    clipboard =							;Start off empty to allow ClipWait To detect when the text has arrived
    Sleep, 100
    Send, {CTRL DOWN}{SHIFT DOWN}f{CTRL UP}{SHIFT UP}
    ClipWait, 10						;Wait for the clipboard to contain text
    if ErrorLevel
      {
        continuous						;2nd try
      }
    break
  }
  If clipboard = found
  {
    rc = 0
  } else {
    ster: wher = "* Error in slect(". x. ") : not found.` n "	;not found
    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) means "Normal XPATH" (En & Fr)
;-------------------------------------------------------------------------------------------------------------------------------
nxpath(x)
{
  Global wher, fnErr, st, fnl
  Clipboard := x
  Sleep, 100
  Send, {CTRL DOWN}q{CTRL UP}
  rc := WClipChange(x)
  If clipboard <> Found
  {
    ster := wher " * Error in Xpat(" . x . ") `n " . clipboard . " `n "
    rc := err1(ster, fnErr)
  }
  Sleep, 100
  return rc							;cr> 1 OK
}
;-------------------------------------------------------------------------------------------------------------------------------
;rxpath(x) means "Recoverable XPATH" (En) or "XPATH Récupérable" (Fr)
;-------------------------------------------------------------------------------------------------------------------------------
rxpath(x)
{
  global wher, fnErr, st, fnl, stertxp
  clipboard := x
  Sleep, 100
  Send, {CTRL DOWN}q{CTRL UP}
  rc := WClipChange(x)
  If clipboard = Found							;OK
  {
    return rc								;cr> 1 OK
  }
  stertxp := wher " * Error in Xpat(" . x . ") `n " . clipboard . " `n "
  If clipboard = NotFound
  {
    return 0								;rc=0 KO Recoverable
  } else {
    rc := err1(stertxp, fnErr)						;KO non Recoverable/récupérable
    return rc
  }
}
;-------------------------------------------------------------------------------------------------------------------------------
;WClipChange(x) means "Wait Clipboard Change" (En)
;-------------------------------------------------------------------------------------------------------------------------------
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 " * Timeout WClipChange " . ElapsedTime . " ms `n "
      rc := err1(ster,fnErr)
    }
  return ElapsedTime								;If OK, cr> 1
}
;-------------------------------------------------------------------------------------------------------------------------------
;err1(ster,fnErr) normal error procedure : ster is written it to the error log and show it in a MsgBox. st is put in the normal log
;-------------------------------------------------------------------------------------------------------------------------------
err1(x, y)
{
  global st, fnl
  MsgBox %x%
  ster := "**** " . A_Now . " " .  A_ScriptName . "`n" . x . " `n "
  FileAppend, %ster%, %y%
  rc := Purgelog()								;st is put in the normal log
  Exit
  return 1									;rc=0 OK , rc=1 KO
}
;-------------------------------------------------------------------------------------------------------------------------------
;err1s = err1 + log source
;-------------------------------------------------------------------------------------------------------------------------------
err1(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									;err1 = err1 + log source
  return 1								;rc=0 OK, rc=1 KO
}
;-------------------------------------------------------------------------------------------------------------------------------
;errClipW(x) ClipWait 10s with ErrorLevel processing
;-------------------------------------------------------------------------------------------------------------------------------
errClipW(x)
{
  global wher, fnErr, st, fnl
  ClipWait, 10								;Wait for the clipboard to contain text
  if ErrorLevel
  {
    ster := wher " * Error in ClipWait function " . x . " `n "
    rc := err1(ster,fnErr)
  }
  return 1
}
;-------------------------------------------------------------------------------------------------------------------------------
;VerREMatch(x,y) VERify that RegExMatch has found (returned variable x not 0), pass y to the error message
;-------------------------------------------------------------------------------------------------------------------------------
VerREMatch(x,y)
{
   global wher, fnErr, st, fnl
   If x = 0
   {
      ErrREMatch(y)
   }
  Sleep, 100
  return 0		;rc=0 OK, rc=1 KO
}
;-------------------------------------------------------------------------------------------------------------------------------
;ErrREMatch(x) ERRor procedure for RegExMatch
;-------------------------------------------------------------------------------------------------------------------------------
ErrREMatch(x)
{
  global wher, fnErr, st, fnl
  ster := wher " * Error RegExMatch for " . x . " : nothing found `n "
  rc := err1(ster,fnErr)
  Sleep, 100
  return rc		;rc=0 OK, rc=1 KO
}
;-------------------------------------------------------------------------------------------------------------------------------
;Purgelog() st is put in the normal log
;-------------------------------------------------------------------------------------------------------------------------------
Purgelog()
{
  global st, fnl
  st .= "`n **** Purge " . A_Now . " " .  A_ScriptName . "`n"
  FileAppend, %st%, %fnl%
  return 0		;rc=0 OK, rc=1 KO
}
;-------------------------------------------------------------------------------------------------------------------------------
;sourc() return normal SOURCe (ctrl u)
;-------------------------------------------------------------------------------------------------------------------------------
source()
{
  clipboard =			;Start off empty to allow ClipWait to detect when the text has arrived.
  Send, {CTRL DOWN}{SHIFT DOWN}u{SHIFT UP}{CTRL UP}
  errClipW(A_ThisFunc)		;ClipWait 10 s. with ErrorLevel processing
  return clipboard		;source
}
;-------------------------------------------------------------------------------------------------------------------------------
;sdom() return source of DOM
;-------------------------------------------------------------------------------------------------------------------------------
sdom()
{
  clipboard =			;Start off empty to allow ClipWait to detect when the text has arrived.
  Send, {ALT DOWN}{SHIFT DOWN}u{SHIFT UP}{ALT UP}
  errClipW(A_ThisFunc)		;ClipWait 10 s. with ErrorLevel processing
  return clipboard		;DOM source
}
;-------------------------------------------------------------------------------------------------------------------------------
;maxim() MAXIMise (<-Fr/En-US->) MAXIMize
;-------------------------------------------------------------------------------------------------------------------------------
maxim()
{
  Send, {CTRL DOWN}{SHIFT DOWN}m{SHIFT UP}{CTRL UP}
  Sleep, 200
  return 0
}
;-------------------------------------------------------------------------------------------------------------------------------
;max3q() MAXimise au 3 Quarts (<-Fr/En-US->) MAXimize to 3 Quarters
;-------------------------------------------------------------------------------------------------------------------------------
max3q()
{
  Send, {CTRLDOWN}m{CTRLUP}
  Sleep, 200
  return 0
}
;-------------------------------------------------------------------------------------------------------------------------------
;vertit(x) VERify that TITle contains x
;-------------------------------------------------------------------------------------------------------------------------------
vertit(x)
{
  global wher, fnErr, Title, st, fnl
  WinGetTitle, Title, A
  IfNotInString, Title, x
  {
      ster := wher " * Error title = " . Title . " `n "
    rc := err1(ster,fnErr)
  }
  return 0   ; rc=0 OK , rc=1 KO
}
;-------------------------------------------------------------------------------------------------------------------------------
;versourc(x) VERify that the SOURCe of DOM contains x
;-------------------------------------------------------------------------------------------------------------------------------
versourc(x)
{
  global wher, fnErr, spring, st, fnl
  Source := sdom()
  ;FileAppend, %source%, %fnErr%
  IfNotInString, source, x
  {
    ster := wher " * Error : source does not contain " . x
    rc := err1(STER,fnErr)
    return 1		;rc=0 OK, rc=1 KO
  }
  return 0		;rc=0 OK, rc=1 KO
}
;-------------------------------------------------------------------------------------------------------------------------------
;verURL(x) VERify that the URL is x
;-------------------------------------------------------------------------------------------------------------------------------
verURL(x)
{
  global wher, fnErr, st, fnl, vURL
  vURL := retURL()
  If vURL = %x%
    return 0								;rc=0 OK, rc=1 KO
  Else
  {
    ster := wher " * Error : URL = " . vURL . "`n instead of " . x
    rc := err1(ster,fnErr)
    return 1								;rc=0 OK, rc=1 KO
  }
}
;-------------------------------------------------------------------------------------------------------------------------------
;retURL() RETurn URL
;-------------------------------------------------------------------------------------------------------------------------------
retURL()
{
  clipboard =							;Start off empty to allow ClipWait to detect when the text has arrived.
  Send, {ALT DOWN}{SHIFT DOWN}l{SHIFT UP}{ALT UP}
  errClipW(A_ThisFunc)						;ClipWait 10 s. with ErrorLevel processing
  Sleep, 100
  return clipboard						;URL
}
;-------------------------------------------------------------------------------------------------------------------------------
;URLcont(x) verify that the URL CONTains x
;-------------------------------------------------------------------------------------------------------------------------------
URLcont(x)
{
  global wher, fnErr, st, fnl
  vURL := retURL()
  IfInString, vURL, %x%
  return 0									;rc=0 OK, rc=1 KO
  Else
  {
    ster := wher " * Error : URL = " . vURL . "`n does not contain " . x
    rc := err1(ster,fnErr)
    return 1									;rc=0 OK, rc=1 KO
  }
}
;-------------------------------------------------------------------------------------------------------------------------------
;Dur(x) DURation of script
;-------------------------------------------------------------------------------------------------------------------------------
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 := " ??? "				;you see this if it has not been defined in the scriptst := " ... "				;nothing yet to put in normal 

log file
logdir = %A_ScriptDir%\Log\		;The full path of the directory where you put the  log files. Here the sub directory "Log" of the directory of AHK scripts
fnErr = %logdir%Err.log			;standard error log file : one should be defineddeb := A_Now				;start time used by dur(deb) at the 

bottom of script


nigelle
  • Members
  • 129 posts
  • Last active: Dec 28 2013 04:31 PM
  • Joined: 26 Sep 2008
To Michael@oz
-GOOGLE has done a very bad job on the code part : adding spaces, suppressing ", changing { to ( or } to ) I have abandonned the idea to correct it, and erased it from here : please take the code part from the French text !
-It seems that you have an english version of Keyconfig, (mine speaks French and I have not found how to change the language). Please check if the translation back to English of the fields between quote (") correspond to the English version of the extension in 1) and 2) ?
-after this I'll publish a bilingual version by adding En-US after Fr.
-For an unknown reason my last short-cut has disappeared from the original text, I'll add a bilingual version at the bottom of this post. I have also forgotten the "maximize to 3/4" because I have not yet used it.
============== Translation to check (any other can also check)
15/nov./2009 13:46
1) Define the necessary additional shortcuts to AHK.
Open Firefox, Tools tab, for me in the bottom choose "configure keys" Ctrl + Shift + F12, in the small screen that opens "new key" opens a small screen "identity" = key name field name: eg "AHK loading in progress": it helps to find them because the keys are listed alphabetically (hence the interest of the prefix AHK), click where is "code" which disappears and paste what is between "code" and the --- separator line used only for the clarity of my file, click "OK" then returns to the previous screen (for me "label"), go click in the first box at the bottom which is empty and will contain a combination
press any modifier keys (Ctrl Alt Shift etc.) then the letter (eg Alt and Ctrl then B), you see a combination (eg Alt + Ctrl + B) which is assigned to the shortcut, click "apply" then "close".

2) Modify an existing shortcut
Open Firefox, Ctrl + Shift + F12, in the small screen that opens, click the key you want to change, if it can be changed you see on the screen "edit this key", click, make changes (for example adding "AHK" before the name), "OK" then "Apply".

3) List of shortcuts
The line "---------------" is not part of the code : it is only there to separate shortcuts.
=======================
Alt Maj u
nom : AHK source DOM dans clipboard (<-Fr/En-US->) name : AHK DOM source into clipboard
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);
------------------------------------------------------------
Ctrl m (précédement la combinaison de Minimise(<-Fr/En-US->) the former combination of Minimize)
nom : AHK Maximise au 3 quarts (<-Fr/En-US->) name : AHK Maximize to 3 quarters
code :
window.resizeTo(window.screen.availWidth/4*3, window.screen.availHeight/4*3);
------------------------------------------------------------
Alt Maj l (lettre l pas chiffre un (<-Fr/En-US->) letter l not figure one)
nom : AHK URL dans clipboard (<-Fr/En-US->) name : AHK URL into clipboard
code :
var ClipboardHelper = Components.classes["@mozilla.org/widget/clipboardhelper;1"]
.getService(Components.interfaces.nsIClipboardHelper);

ClipboardHelper.copyString(gURLBar.value);
------------------------------------------------------------
-"trivial thing"
I agree but there are also other things to clean ! I have just pasted (without any modification) what I received in the Keyconfig forum see pages 73, 74, 75, 84 and 92.
I propose that we discuss all of this when you and others have gained a good experience.
-"reformatting my first post"
Your proposal in PM is very nice ! I'll integrate it in the forum when I have the time to check how I'll replace the old by yours.

It is a pleasure to work in cooperation with you !

nigelle
  • Members
  • 129 posts
  • Last active: Dec 28 2013 04:31 PM
  • Joined: 26 Sep 2008
To a_h_k
"Here is CommonX translated."
It seems that, as Michael@oz, you have been hurt by Google ! They have done a very bad job on the code part : changing or translating functions names (that should be standardized), adding spaces, etc. . I have abandonned the idea to correct it : please take the code part from the French text !
BTW, the names of the main functions are abbreviations choosen to have meaning in French and English : this help the coding of the script !
I am preparing a new bilingual edition CommonC with the French messages commented, their English versions (improved from the translation given) activated bellow, the meanings of functions names, a function max3q() to "Maximize to 3 quarters", an update to URLcont(x).
Do you see other improvements before I finish editing and minimal test ?
It is a pleasure to work in cooperation with you !

a_h_k
  • Members
  • 685 posts
  • Last active: Sep 28 2015 12:32 AM
  • Joined: 02 Feb 2008
Edited CommonX (translated)

nigelle
  • Members
  • 129 posts
  • Last active: Dec 28 2013 04:31 PM
  • Joined: 26 Sep 2008
This is a bilingual improved text on shortcuts. I have added reasons of choice of the keys and some personal comments.

WARNING : in the English parts of 1) and 2) the quoted expressions are the translations of their French counterparts and have not been checked with an English version of Keyconfig !
Please report ASAP any discrepancies.
02/02/2010, 06:26 PM Paris time = GMT+1
1.1Fr) Définir les raccourcis supplémentaire nécessaire à AHK.
Ouvrir Firefox, onglet outils, près du bas choisir "configurer les clés..." (ou utiliser 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 est attribuée au raccourci, cliquer sur "appliquer" puis "fermer". 
1.2En) Define the necessary additional shortcuts to AHK.
Open Firefox, select the Tools menu, near the bottom choose "Keyconfig..." (or use Ctrl + Shift + F12), in the Keyconfig window click "Add a new key", in the "Keyconfig - Key Editor" enter the name in the "Name" field, eg "AHK loading in progress" ( the prefix AHK helps to find them because the keys are listed alphabetically), Click the "/* CODE */" box which clears, then paste the coding which is between "code:" and the --- separator line (used only for clarity) in my file, Click "OK" which returns to the previous "Keyconfig - Key Editor" screen, Click in the field at the bottom which is empty but will contain the key combination you type, press any modifier keys (Ctrl Alt Shift etc.) then the letter/character key (e.g. Alt and Ctrl then b), you will see the combination (eg Alt+Ctrl+B) which is assigned to the shortcut, click "Apply" then "Close".

2.1Fr) Modifier un raccourci existant
Ouvrir Firefox, onglet outils, près du bas choisir "configurer les clés" (ou utiliser 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. Vous pouvez aussi éditer d'autres champs en double cliquant dessus, ceci ouvre l'éditeur de clé mais avec un nouveau nom de clé aléatoire que vous pouvez surcharger (cela crée une copie de la définition), vous pouvez alors éditer (ci nécessaire) le code et attribuer une combinaison de clés comme précédemment.
2.2En) Modify an existing shortcut
Open Firefox, select the Tools menu, near the bottom choose Keyconfig... (or use Ctrl+Shift+F12), in the Keyconfig screen that opens click the key you want to change, if it can be changed the button changes to "Edit this key", click it, make changes (for example adding "AHK" before the name), then "OK" and "Apply". You can also edit other entries by Double-Clicking the item, which opens the Keyconfig - Key Editor screen but with a new random key name which you can type over (i.e. it creates a copy of the definition), you can then edit the code and assign a key combination as above if required.

3.1Fr) Liste des raccourcis
La ligne de "---------------" ne fait pas partie du code : elle n'est là que pour séparer les raccourcis.
# introduit une ligne de commentaire.
3.2En) List of shortcuts
The line "---------------" is not part of the code : it is only there to separate shortcuts.
# introduces a comment line.
-------------------------------------------------------------------------------------------
Ctrl+Alt+b (b comme "Busy" : "NotBusy") (<-Fr/En-US->) (b as "Busy" : "NotBusy")
nom: AHK Chargement en cours (<-Fr/En-US->) name: AHK Loading in progress
code:
    var ClipboardHelper = Components.classes["@mozilla.org/widget/clipboardhelper;1"]
    .getService(Components.interfaces.nsIClipboardHelper);

    ClipboardHelper.copyString( gBrowser.mIsBusy ? "Busy" : "NotBusy" ); 
---------------------------------------------------------------------------------------------
Ctrl+Maj/Shift+F (Compagnon de Ctrl+f , f comme "found" : "not_found") (<-Fr/En-US->) (Companion of Ctrl+f , f as "found" : "not_found")
nom: AHK : resultat de Rechercher (<-Fr/En-US->) name: AHK result of Find
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"); 
-------------------------------------------------------------------------------------------------
Ctrl+Maj/Shift+U (Ctrl+U affiche la Source) (<-Fr/En-US->) (Ctrl+U shows the source)
nom: AHK Source clipboard (<-Fr/En-US->) name: AHK Source clipboard
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"));
-------------------------------------------------------------
Alt+Maj/Shift+u (Ctrl+U affiche la source) (<-Fr/En-US->) (Ctrl+U shows the source)
nom: AHK source DOM dans clipboard (<-Fr/En-US->) name: AHK DOM source into clipboard
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); 
-------------------------------------------------------------
Ctrl+Maj/Shift+M (m comme maximize() ) (<-Fr/En-US->) (m as maximize() )
#Maximise l'écran (<-Fr/En-US->) Maximize the window
nom: AHK Maximise (<-Fr/En-US->) name: AHK Maximize
code:
    window.maximize();  
-------------------------------------------------------------
?+?+?
#Minimiser l'écran (n'est utilisé par aucun script) (<-Fr/En-US->) #Minimize the window (not used by any script)
nom: AHK Minimise (<-Fr/En-US->) name: AHK Minimize
code:
    window.restore();  
-------------------------------------------------------------
Ctrl+m  (précédement la combinaison de Minimise) (<-Fr/En-US->) (the former combination of Minimize)
nom: AHK Maximise au 3 quarts (<-Fr/En-US->) name: AHK Maximize to 3 quarters
code :
    window.resizeTo(window.screen.availWidth/4*3, window.screen.availHeight/4*3); 
-------------------------------------------------------------
Ctrl+Q (ctrl+X trop dangereux, ctrl+p déjà utilisé, Q est proche de P) (<-Fr/En-US->) (ctrl+X too dangerous, ctrl+p already used, Q is near P)
#Xpath sélecte un tag html et clique dessus (<-Fr/En-US->) Xpath selects an html tag and click on it
nom: AHK Xpath (<-Fr/En-US->) name: AHK Xpath
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/Shift+l (lettre l pas chiffre un, equivalent ctrl+l + ctrl+c)) (<-Fr/En-US->) (letter l not figure one, equivalent ctrl+l + ctrl+c)
nom: AHK URL dans clipboard (<-Fr/En-US->) name: AHK URL into clipboard
code :
    var ClipboardHelper = Components.classes["@mozilla.org/widget/clipboardhelper;1"]
    .getService(Components.interfaces.nsIClipboardHelper);

    ClipboardHelper.copyString(gURLBar.value); 
-------------------------------------------------------------
The original text has been edited Jan 28th according the checking of English version of Keyconfig by Michael@oz and Jan 31 to use everywhere the format Ctrl+Alt+b and replace Maj the French engraving of the Shift key by Maj/Shift and Feb 2 to improve the format as requested by Michael@oz.

nigelle
  • Members
  • 129 posts
  • Last active: Dec 28 2013 04:31 PM
  • Joined: 26 Sep 2008
This is a bilingual (English oriented) improved version of my library now CommonC.ahk.
In the short explanations, the parts chosen to be the functions names are in upper cases. The max3q() has been added and some other functions slightly modified, comments improved and translated or bilingual.
To revert it to French : uncomment the French messages lines, comment the English messages lines.


WARNING : I have done a very small number of tests.
Please report ASAP any problems.

CommonC.ahk
;--------fini() means "loading FINIshed" (En) or "chargement FINI" (Fr)
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 "
			ster := wher " * Timeout loading " . ElapsedTime . " ms` n "
      rc := err1(ster,fnErr)
    }
;  MsgBox, , , temps de chargement %ElapsedTime% ms. %wher% ,4
;	MsgBox,, loading time %ElapsedTime% ms. %Wher%, 4
  return ElapsedTime ; >1
}
;--------slect(x) means "SeLECT" (En) or "SéLECTe" (Fr)
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 "
		ster := wher " * Error in slect(" . x . ") : not found. `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) means "Normal XPATH" (En & Fr)
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 "
		ster := wher " * Error in Xpat(" . x . ") `n " . clipboard . " `n "
    rc := err1(ster,fnErr)
  }
  Sleep, 100
  return rc   ; rc>1 OK
}
;---------rxpath(x) means "Recoverable XPATH" (En) or "XPATH Récupérable" (Fr)
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 "
	stertxp := wher " * Error in Xpat(" . x . ") `n " . clipboard . " `n "
  If clipboard = NotFound
  {
    return 0  ; rc=0 KO Recoverable/récupérable
  }else{
    rc := err1(stertxp,fnErr) ; KO non Recoverable/récupérable
    return rc  
  }
}
;---------WClipChange(x) means "Wait Clipboard Change" (En)
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 WClipChange " . ElapsedTime . " ms `n "
			ster := wher " * Timeout WClipChange " . ElapsedTime . " ms `n "
      rc := err1(ster,fnErr)
    }
  return ElapsedTime  ; If OK , rc > 1
}
;--------err1(ster,fnErr) normal error procedure : ster is written it to the error log and show it in a MsgBox. st is put in the normal log. (En)
;--------err1(ster,fnErr) procédure normale d'error : ster est écrit dans le log d'erreur et affiché dans une MsgBox. st est mis dans le log normal. (Fr)
err1(x,y)
{
  global st, fnl
  MsgBox %x%
  ster := "**** " . A_Now . " " .  A_ScriptName . "`n" . x . " `n "
  FileAppend, %ster%, %y%
  rc := Purgelog() ;st is put in the normal log
  Exit
  return 1   ; rc=0 OK , rc=1 KO
}
;--------err1s = err1 + log source
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) ClipWait 10 s. with ErrorLevel processing.(En) avec gestion d'ErrorLevel.(Fr)
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 "
		ster := wher " * Error ClipWait in function " . x . " `n "
    rc := err1(ster,fnErr)
  }
  return 1
}
;--------VerREMatch(x,y) VERify that RegExMatch has found (returned variable x not 0), pass y to the error message. (En)
;--------VerREMatch(x,y) VERifie que RegExMatch a trouvé (variable x retournée n'est pas 0), passe y au message d'erreur. (Fr)
VerREMatch(x,y)
{
	global wher, fnErr, st, fnl
	If x = 0
	{
		ErrREMatch(y)
	}
  Sleep, 100
  return 0   ; rc=0 OK , rc=1 KO
}
;--------ErrREMatch(x) ERRor procedure for RegExMatch. (En) procedure d'ERReur pour RegExMatch. (Fr)
ErrREMatch(x)
{
  global wher, fnErr, st, fnl
  ;ster := wher " * Erreur RegExMatch pour " . x . " : rien trouvé `n "
	ster := wher " * Error RegExMatch for " . x . " : nothing found `n "
  rc := err1s(ster,fnErr)
	return rc   ; rc=0 OK , rc=1 KO
}
;--------Purgelog() st is put in the normal log. (En) st est mis dans le log normal. (Fr)
Purgelog()
{
  global st, fnl
  st .= "`n **** Purge " . A_Now . " " .  A_ScriptName . "`n"
  FileAppend, %st%, %fnl%
  return 0   ; rc=0 OK , rc=1 KO
}
;--------sourc() return normal SOURCe (ctrl u).(En) retourne la SOURce normal (ctrl u).(Fr)
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 s. with ErrorLevel processing.(En) avec gestion d'ErrorLevel.(Fr)
  return clipboard ; source
}
;--------sdom() return Source of DOM.(En) retourne la Source du DOM.(Fr)
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 s. with ErrorLevel processing.(En) avec gestion d'ErrorLevel.(Fr)
  return clipboard ; source du DOM
}
;--------maxim() MAXIMise (<-Fr/En-US->) MAXIMize
maxim()
{
  Send, {CTRLDOWN}{SHIFTDOWN}m{SHIFTUP}{CTRLUP}
  Sleep, 200
  return 0
}
;--------max3q() MAXimise au 3 Quarts (<-Fr/En-US->) MAXimize to 3 Quarters
max3q()
{
  Send, {CTRLDOWN}m{CTRLUP}
  Sleep, 200
  return 0
}
;--------vertit(x) VERify that TITle contains x.(En) VERifie que le TITre contient x.(Fr)
vertit(x)
{
  global wher, fnErr, Title, st, fnl
  WinGetTitle, Title, A
  IfNotInString, Title, x
  {
    ;ster := wher " * Erreur titre = " . Title . " `n "
		ster := wher " * Error title = " . Title . " `n "
    rc := err1(ster,fnErr)
  }
  return 0   ; rc=0 OK , rc=1 KO
}
;--------versourc(x) VERify that the SOURCe of DOM contains x.(En) VERifie que la SOURCe du DOM contient x.(Fr)
versourc(x)
{
  global wher, fnErr, source, st, fnl
  source := sdom()
;    FileAppend, %source%, %fnErr%
  IfNotInString, source, x
  {
    ;ster := wher " * Erreur : source ne contient pas " . x
		ster := wher " * Error : source does not contains " . x
    rc := err1s(ster,fnErr)
    return 1   ; rc=0 OK , rc=1 KO
  }
  return 0   ; rc=0 OK , rc=1 KO
}
;--------verURL(x) VERify that the URL is x.(En) VERifie que l'URL est x.(Fr)
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
		ster := wher " * Error : URL = " . vURL . "`n instead of " . x
    rc := err1(ster,fnErr)
    return 1   ; rc=0 OK , rc=1 KO
  }
}
;--------retURL() RETurn URL.(En) RETourne l'URL.(Fr)
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 s. with ErrorLevel processing.(En) avec gestion d'ErrorLevel.(Fr)
  Sleep, 100
  return clipboard ; URL
}
;--------URLcont(x) verify that the URL CONTains x.(En) verifie que l'URL CONTient x.(Fr)
URLcont(x)
{
  global wher, fnErr, st, fnl, vURL
  vURL := retURL()
  IfInString, vURL, %x%
  return 0   ; rc=0 OK , rc=1 KO
  Else
  {
    ;ster := wher " * Erreur : URL = " . vURL . "`n ne contient pas " . x
		ster := wher " * Error : URL = " . vURL . "`n does not contains " . x
    rc := err1(ster,fnErr)
    return 1   ; rc=0 OK , rc=1 KO
  }
}
;--------Dur(x) DURation of script.(En) DURée du script.(Fr)
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%
}
;--------variables
; initialize always used variables.(En) Initialisation des variables toujours utilisées.(Fr) 
wher := " ??? " ; you see this if it has not been defined in the script.(En) Vous voyez ceci si ça n'a pas été défini dans le script.(Fr)
st := " ... " ; nothing yet to put in normal log file.(En) Rien encore à mettre dans le log.(Fr)
logdir = %A_ScriptDir%\Log\ ; The full path of the directory where you put the log files. Here the sub directory "Log" of the directory of AHK scripts..(En)
; Chemin complet du répertoire des logs. Ici le repertoire des scripts AHK suivi de Log..(Fr)
fnErr = %logdir%Err.log ; standard error log file : one should be defined.(En) Log standard pour les errreurs : il faut en définir un.(Fr)
deb := A_Now ; start time used by dur(deb) at the bottom of script.(En) Temps du début, utilisé par dur(deb) à la fin du script.(Fr)


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

-It seems that you have an english version of Keyconfig, (mine speaks French and I have not found how to change the language). Please check if the translation back to English of the fields between quote (") correspond to the English version of the extension in 1) and 2) ?


============== Translation Edited

1) Define the necessary additional shortcuts to AHK.
Open Firefox, select the Tools menu, near the bottom choose Keyconfig... (or use Ctrl + Shift + F12), in the Keyconfig window click Add a new key, in the Keyconfig - Key Editor enter the name in the Name field, eg "AHK loading in progress" ( the prefix AHK helps to find them because the keys are listed alphabetically), Click the /* CODE */ box which clears, then paste the Javascript which is between "code" and the --- separator line (used only for clarity) in my file, Click OK which returns to the previous Keyconfig - Key Editor screen, Click in the field at the bottom which is empty but will contain the key combination you type, press any modifier keys (Ctrl Alt Shift etc.) then the letter/character key (eg Alt and Ctrl then B), you will see the combination (eg Alt + Ctrl + B) which is assigned to the shortcut, click Apply then Close.

2) Modify an existing shortcut
Open Firefox, select the Tools menu, near the bottom choose Keyconfig... (or use Ctrl + Shift + F12), in the Keyconfig screen that opens click the key you want to change, if it can be changed the button changes to Edit this key, click it, make changes (for example adding "AHK" before the name), then OK and Apply. You can also edit other entries by Double-Clicking the item, which opens the Keyconfig - Key Editor screen but with a new random key name which you can type over (ie it creates a copy of the definition), you can then edit the code and assign a key code as above if required.

==========================
I've been digging into DOM and the xpath. I does certainly open Firefox wide open, particularly with a little javascript wrapper thrown in.

I'm after things like which tab is showing, how many tabs etc., I've seen the code in the Functions for Keyconfig FF extension which has some interesting titbits.

Anyone wanting a real easy intro to xpath see this