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
SoLong&Thx4AllTheFish
  • Members
  • 4999 posts
  • Last active:
  • Joined: 27 May 2007

.... I does certainly open Firefox wide open, particularly with a little javascript wrapper thrown in. ...

OT: you do know about MozRepl, see <!-- m -->http://www.autohotke...pic.php?t=46974<!-- m --> [sorry don't want to hijack this thread]

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

Please report ASAP any problems.

Note that I am not coding with this yet.

I offer a couple of translation tweaks.. changes bolded

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 in ClipWait function " . x . " `n "
rc := err1(ster,fnErr)
}
return 1

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 ;ie delete s
rc := err1s(ster,fnErr)
return 1 ; rc=0 OK , rc=1 KO
}
return 0 ; rc=0 OK , rc=1 KO
}

As above for URLcont(x)


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

.... I does certainly open Firefox wide open, particularly with a little javascript wrapper thrown in. ...

OT: you do know about MozRepl, see <!-- m -->http://www.autohotke...pic.php?t=46974<!-- m --> [sorry don't want to hijack this thread]


I agree with your post there;

I'm just going to pretend I understood everything you just said :-) (and in the meantime keep my fingers crossed hoping someone who actually does will provide noob friendly AHK functions), but I'll read what you wrote a few times more and maybe it will sink in :wink:


I think Nigelle's wrappers are a bit more user friendly and they don't taint ahk with javascript :wink:

A couple more functions for things like the status/info extracts like a list of the tabs etc is probably enough for basic ahk automation.

a_h_k
  • Members
  • 685 posts
  • Last active: Sep 28 2015 12:32 AM
  • Joined: 02 Feb 2008
Normalized my CommonX/C (english - untested) with nigelle's latest CommonC on 28/1/10

Michael@Oz
  • Members
  • 234 posts
  • Last active: Dec 30 2011 11:24 PM
  • Joined: 08 Nov 2009
Do you have issue with the bi-lingual version?

a_h_k
  • Members
  • 685 posts
  • Last active: Sep 28 2015 12:32 AM
  • Joined: 02 Feb 2008
No issue with it .. just that i did the CommonX translation before nigelle, and am simply keeping that thread's code "current" with his latest

My translation is almost the same, apart from:
- No (commented) french words in it
- Looks a bit simpler IMHO

Am toying with idea of a "translation system". Maybe have an INI file containing various sentence substitutions .. and a basic GUI (to select which Common_ file to generate - English (CommonE) or French (CommonF)). This way ONLY the language you want is in the Common_ file, and no need to go through 2 files every time an edit is made - just edit the CommonB (Both French & English) file --> then run the "translation system" script to recreate the specific Common files

nigelle
  • Members
  • 129 posts
  • Last active: Dec 28 2013 04:31 PM
  • Joined: 26 Sep 2008
To Michael@oz
Thanks for your help !
Are you sure that coding of short-cuts are done in Javascript ?
That is not the basic version of it that I know. Where is defined Object Javascript ?
Mozilla use other things as XUL, etc. .
In doubt, I have changed "Javascript" to "coding"...
I have also slightly changed the French text to put it more in line with your proposal.

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

Are you sure that coding of short-cuts are done in Javascript ?
That is not the basic version of it that I know. Where is defined Object Javascript ?
Mozilla use other things as XUL, etc. .

See this and this and this

As I said above it splits FF wide open (which is probably not news to others) and opens possibilities to get a bunch of other ahk and FF interaction.

For example, it would be relatively easy to have a clipboard based two-way interface paste something like;
<command>,<parameters which could include URLs>
Send one special keyconfig key to a Javascript which has code for all the commands and can return stuff in the clipboard like;
<result code>,<result set>Your implementation pointed the way, and I'm going to be using it, but being able to extend it will help with what I want to do, which is more user interface oriented.

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

This is a bilingual improved text on shortcuts...

Does your Keyconfig have a 'Global' checkbox at the end of the 'Name' field in the Keyconfig - Key Editor window?

Should this be checked or not?

nigelle
  • Members
  • 129 posts
  • Last active: Dec 28 2013 04:31 PM
  • Joined: 26 Sep 2008
You are too fast for me !

To hugov
I already had a short look to MozRepl that gives functions that do things (perhaps better or more) that are similar to my shortcuts.
I love in AHK all the powerful instructions that wrap around the simulation. I have not seen (perhaps my fault) the way to integrate them with MozRepl : can you help in this direction ?

To Michael@oz
1)

ster := wher " * Error ClipWait in function " . x . " `n "

the argument x of errClipW(x) is the name of the function that has called errClipW(x) ("errClipW(A_ThisFunc) ; ...") : the message says that there as been an error due to ClipWait in the function x e.g. sourc(), sdom(), etc. . I think that my text is right (but perhaps too short).
2) For versourc(x) and URLcont(x) you are right : I'll correct in next edition.
3)

Does your Keyconfig have a 'Global' checkbox at the end of the 'Name' file in the Keyconfig - Key Editor window?


Yes I have but I have not cheked it and it works. I don't know what it does...
4)

paste something like;
<command>,<parameters which could include URLs>
Send one special keyconfig key to a Javascript which has code for all the commands and can return stuff in the clipboard like;
<result code>,<result set>

The Xpath shortcut is a simplified version of this : it has only 1 command !
You should post in Keyconfig to verify that a shortcut has no limitation in size of its coding ! Your Javascript may be rather long... Else you may have to transfer the call to your code in an other location but Mozilla has become strict with 3.5 and 3.6 to additions of code !
You have to understand that I am a complete new-be in coding Mozilla : all of "my" shortcuts have been coded by Dorando. So there are ideas than I cannot have or think possible. You seems to be an expert in coding, so please, implement your ideas...
5)

A couple more functions for things like the status/info extracts like a list of the tabs etc is probably enough for basic ahk automation.

IMacros has a way to shift from a tab to an other. I already do some basic management of tab/FFX with AHK instructions :
- with "run URL,max" ;I start the connection to the application in a new instance of FFX (this may depend of my choice of options).
- with SetTitleMatchMode 2
;WinClose [, WinTitle, WinText, SecondsToWait, ExcludeTitle, ExcludeText]
WinClose , Firefox, ,0 , The_application_screen_I_wait_for_Title, ;I close an advertisement screen.
-with SetTitleMatchMode 2
WinClose , Firefox, ,0 ;I close (at the end of the script) the instance of FFX opened by run.
Does this cover your needs ?

To a_h_k

Am toying with idea of a "translation system". Maybe have an INI file containing various sentence substitutions .. and a basic GUI (to select which Common_ file to generate - English (CommonE) or French (CommonF)). This way ONLY the language you want is in the Common_ file, and no need to go through 2 files every time an edit is made - just edit the CommonB (Both French & English) file --> then run the "translation system" script to recreate the specific Common files

I was thinking to a set of languages files (to be #include) defining variables used to build the messages e.g. to cover fini() I'll in the French file have :
ll1 := " * D├ępassement temps de chargement " ; for sterr
ll2 := "temps de chargement " ; for commented MsgBox
I'll in the English file have :
ll1 := " * Timeout loading "
ll2 := "loading time "
and put variables ll1 and ll2 in the messages of the library. We perhaps need spare empty variables for languages as German that change the order of words in the sentence... Each country can build its language file...

To All of you (and new comers) :
I am open to new suggestions : I do not suffer from the N(ot) I(nvented) H(ere) disease...
My experience shows that when 2 work together, they have more than twice the good ideas of 1 : each improves the ideas of the other.
If you have new needs explain them here. If there is a known solution, we'll give it to you. We may also improve or generalize your requirements...
If you do not understand what I have done or disagree with it, explain : I may have made a mistake or not seen a point.
You seems to have written far more posts than I : you have more experience and perhaps your direct entries in the development teams of AHK or FFX, please share these with the others.



SoLong&Thx4AllTheFish
  • Members
  • 4999 posts
  • Last active:
  • Joined: 27 May 2007

To hugov
I already had a short look to MozRepl that gives functions that do things (perhaps better or more) that are similar to my shortcuts.
I love in AHK all the powerful instructions that wrap around the simulation. I have not seen (perhaps my fault) the way to integrate them with MozRepl : can you help in this direction ?

Sure, to get it working:

a) Install MozRepl <!-- m -->http://wiki.github.com/bard/mozrepl/<!-- m -->
B) Make sure it is running, in the Tools menu there is now a mozrepl submenu where you can check that
c) download the Winsock library here <!-- m -->http://www.autohotke...topic35575.html<!-- m -->
d) now you can try my sample library (very basic) and script here <!-- m -->http://www.autohotke... ... 920#294920<!-- m -->

It will open a tab, duplicate a tab etc by directly instructing FF to do so.

As you can see with the autoit library FF.au3 <!-- m -->http://english.docum... ... illert.de/<!-- m --> you can make pretty functions that take care of the nasty stuff :-)

So opening a new tab is as simple as:
FF_AddTab("http://www.autohotkey.com/forum/")
and should be very reliable (and easy to share code with other people as they only need the library + mozrepl addon and doesn't require any configuration.

You can see a MozRepl movie here <!-- m --><!-- m -->

Now "all" that needs done is to translate the FF.au3 to AutoHotkey code but the AutoIt code looks like French to me + I don't know much about javascript either so it is a bit out of my league

Try my demo script listed at d) and see how smooth it works (at least it does for me)

Again, sorry don't want to hijack your thread.