AutoHotkey Community

It is currently May 27th, 2012, 2:14 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 83 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6  Next
Author Message
 Post subject:
PostPosted: February 1st, 2010, 1:53 pm 
Offline

Joined: September 26th, 2008, 6:09 pm
Posts: 82
Location: France
To Michael@oz
Quote:
change ?+?+? line perhaps Ctrl Shift R to be consisten with minimize?

Ctrl+Shift+R is already assigned in the FF standard shortcuts to "Reload (override cache)" see :
http://support.mozilla.com/en-US/kb/Keyboard+shortcuts
It is used with this standard meaning in fini() which after 20 s. stop and reload to unlock some bad situations. We will have a severe conflict.
Please make an other proposal if you wish to use the minimize short-cut. For me, the result is too bad to be used !

I have seen in Keyconfig forum page 95 a new coding answer to "the only thing I need (for now) is to get single keys to switch tabs, preferrably "1" to scroll tabs left and "2" to scroll tabs to the right."
Take a look at it. I have not yet needed it but it may be useful for others ! Do we need to include it ? With which combinations of keys ?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 1st, 2010, 2:03 pm 
Offline

Joined: May 27th, 2007, 9:41 am
Posts: 4999
Once ready you should perhaps post a complete "how to" in the AutoHotkey wiki so it easier for you all to update/edit etc and keep this thread for discussion. Just a thought.

_________________
AHK FAQ
TF : Text files & strings lib, TF Forum


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Wiki
PostPosted: February 1st, 2010, 5:10 pm 
Offline

Joined: September 26th, 2008, 6:09 pm
Posts: 82
Location: France
To hugov
Good idea !
I am not yet ready : I have at least to finish a text on "How I code Xpath instruction" and to do an other on "How I code script".

I have not yet written in Wiki. How to do it ? Is somebody prepared to write for me using the texts I have already put in posts ?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 1st, 2010, 5:32 pm 
Offline

Joined: May 27th, 2007, 9:41 am
Posts: 4999
Re. wiki: I've setup a page you can simply edit and paste your text in, the format is plain text with some formatting options like here on the forum.

Go to http://www.autohotkey.com/wiki/index.ph ... te_FireFox and choose create account at the top left, now you return to this page and choose the edit button, paste your text and click SAVE or preview.

After that we can clean it up a bit by adding formatting and headings etc.

_________________
AHK FAQ
TF : Text files & strings lib, TF Forum


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 2nd, 2010, 9:15 am 
Offline

Joined: November 8th, 2009, 2:46 am
Posts: 234
Location: Canberra Oz
and then once it is a bit stable we can drop a note on the Scripts & Function forum


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 2nd, 2010, 9:38 am 
Offline

Joined: November 8th, 2009, 2:46 am
Posts: 234
Location: Canberra Oz
nigelle wrote:
To Michael@oz
Quote:
change ?+?+? line perhaps Ctrl Shift R to be consisten with minimize?

Ctrl+Shift+R is already assigned in the FF standard shortcuts to "Reload (override cache)"...
I'll get back to you after testing 'restore' via ahk, I imagine it works OK.

For now I will modify my script to handle the '?'.

Was there some issue with using ahk WinMaximize that caused you to want the Keyconfig maximize?

Quote:
I have seen in Keyconfig forum page 95 a new coding answer to "the only thing I need (for now) is to get single keys to switch tabs, preferrably "1" to scroll tabs left and "2" to scroll tabs to the right."
Take a look at it. I have not yet needed it but it may be useful for others ! Do we need to include it ? With which combinations of keys ?

I had seen the standard FF keyboard shortcuts for tab handling which should be enough for ahk to use with Send, {key}.

By the way my Tab related need which I think I am on to, is to detect info about tabs, not just to control them. For example, if the tab cannot go 'back' and it was a pop-up tab and you press 'back' then close the tab and switch back to the tab that opened it.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 2nd, 2010, 11:14 am 
Offline

Joined: September 26th, 2008, 6:09 pm
Posts: 82
Location: France
Quote:
Was there some issue with using ahk WinMaximize that caused you to want the Keyconfig maximize?

I have put the ahk WinMaximize command in my script on a window covering 3/4 of my monitor (hoping to go to full screen) but the size of the window did not change !
Quote:
I'll get back to you after testing 'restore' via ahk, I imagine it works OK.

At the beginning I defined a short-cut with "restore" code and tested it manually as usual : this did not raise any error but I obtained a window of 1 inch squared in most (not all) of the cases on my 20 " monitor : I have no use for this !


Report this post
Top
 Profile  
Reply with quote  
PostPosted: February 2nd, 2010, 4:54 pm 
Offline

Joined: September 26th, 2008, 6:09 pm
Posts: 82
Location: France
How I write an xpath instruction
First you need a basic knowledge of Xpath and Htlm. Read, at least once, documentation. I have found :
-for Xpath
https://developer.mozilla.org/En/XPath
http://www.w3.org/TR/xpath
http://www.w3schools.com/xpath/
-for Htlm
https://developer.mozilla.org/en/HTML/Element
https://developer.mozilla.org/en/HTML_E ... _Reference
http://htmlhelp.com/reference/html40/alist.html
http://htmlhelp.com/reference/html40/olist.html
http://www.w3.org/TR/html4/index/attributes.html
There are others that may be better for your tastes.
Now do not panic if you forget their big contents : If you find something in the source that looks like <input name="autologin" type="checkbox"> you may guess with confidence 99% that "input" (after the < it ends with >)is a tag, "name" and "type" (before =) are attributes and "autologin" and "checkbox" (between ") their content values even if you don't remember your lists !

When you define a character string to AHK or htlm, you have to use double-quote " around it, with the FF Xpath function you have the choice between double-quote " and simple-quote ' . You can test this on the iMacros demo page
http://www.iopus.com/imacros/demo/v6/pos/index.htm
by copying one of the following lines to your clipboard and use manually the ctrl+Q short-cut pasting somewhere the result ("Found") now in the clipboard :
nigelle;1;//input[@value='your E-mail here']
nigelle;1;//input[@value="your E-mail here"]
both will bring you in the Newsletter field in the upper right corner.
Now you have to write the AHK instruction calling the nxpath or rxpath functions adding " around it. It is : in the first case
rc := nxpath("nigelle;1;//input[@value='your E-mail here']")
in the second one
rc := nxpath("nigelle;1;//input[@value=""your E-mail here""]")
because you have to double each quote inside an AHK quoted string ! This is error prone and you cannot test easily your instruction by copying to your clipboard what is between the external quotes " of your instruction as I suggested in the text "Preparing to script". The source line you selected was
<input name="subscribe_email" type="text" class="txtbox" value="your E-mail here" />
So my advice is : use ' for strings inside xpath as in the first example.

The format of the parameter list of FF Xpath function is identifier;occurrence;XPath while for XPath most common are //tag[@attribute="value"] or //tag[contains(text(),"text content")] which is equivalent to my select() (with Ctrl+F) on the text part of the screen.
clarifications :
-the first field "identifier" is just a place holder and you can replace "nigelle" by any other string (but the same in shortcut and clipboard). We shall have in the future to decide if we keep "nigelle" (chosen by Dorando) which is good for my pride or replace it by something else e.g. AHK .
-the 2nd field "occurrence" is numeric [0-9] but can be greater than 9 e.g. 12.
-the 3rd field "XPath" : "tag" is the htlm tag without < and can be a td input or others ; "input" tag is used for the areas where you have to type entries e.g. user identifier, password, email, etc.. "a" (for anchor) tag is very common and has no special meaning.
-joker characters as * are not supported as in Imacros but you can use multiple checks like (all need to match): //input[@value="your E-mail here"][@name="subscribe_email"] .
-XPath 1.0 does not support case-insensitive matches.
-common attributes : "onclick" is frequently used when you click on an area that do some processing (e.g. Javascript function as in 'onclick="functionXx(...)' ), "href" introduce normally an URL with coding either relative to the domain or absolute but may also introduce Javascript function. With "input" tag you have very often a "name" attribute.

What syntax can I use to select ?
To define an attribute put @ before its name, its content value is between ' (if a default value is defined, it is shown in the @value attribute).
rc := nxpath("nigelle;1;//input[@name='username']") ; = means strictly equal, easy in many cases, very strict.
rc := nxpath("nigelle;1;//a[contains(@onclick,'return function_name')]") ; contains (note the s) is self explanatory, very easy but not very strict, generally sufficient.
rc := nxpath("nigelle;2;//a[starts-with(@onclick,'ClickFunc(')]") ; starts-with (note the s and -) is self explanatory, easy more strict.
rc := nxpath("nigelle;2;//a[ends-with(@onclick,'abcd)')]") ; ends-with (note the s and -) is self explanatory, easy more strict.
rc := nxpath("nigelle;1;//a[contains(text(),'some text')]") ;select "some text" in text part
I have found the examples given by
http://www.exampledepot.com/egs/org.w3c ... html?l=rel
"Finding Elements by Attributes in a DOM Document Using XPath"
(and others) very useful to understand what I do.

What element to choose ?
e.g. in the line used by AHKlogB.ahk script or the line prepared in one of the files defined in "Preparing to script"
<input class="post" name="username" size="25" maxlength="40" value="" type="text">
The principle is : something that is not commonly used in various places, that cause problem (e.g. need modifications) to the application if changed, is not used by the stylists to make the screen better looking.
With "input" tag the best candidate is often "name" attribute and its content : practically always the string 'name="its_content"' is unique in the source. This is due to the way your input data is transferred to (and used by) the application with method="post". As yo can see in the cited script other attributes as class, size, maxlength, value or type are used elsewhere and not a good choice. In other cases, "class" points to a small category and can be used.
Once you have chosen a candidate e.g. 'attribute="its_content"' you test your source see "Preparing to script" for the number of occurrences (hopefully 1) and choose an other if needed.

How to code ?
As usually it is easier to modify something already existing (see my Lxpath.txt file below). So you copy a model below your source line, correct it by pasting what is different in the source (e.g. attribute or its_content). I assume that you have now :
rc := nxpath("nigelle;1;//input[@name='username']")
you copy in your clipboard what is between the external " . It is :
nigelle;1;//input[@name='username']
go to the corresponding FF screen and use manually the ctrl+Q short-cut. Then paste the result now in the clipboard in the empty line below.
-If it is "Found" (and the FF cursor is in right field) that means success, you can go to the next action.
-If it is "NotFound" that means that the format of your instruction was right but that nothing has been selected. The error is probably in the occurrence value or some misspelling in attribute name or its content. Correct and try again !
-If it looks like
[Exception... "The expression is not a legal expression." code: "51" nsresult: "0x805b0033 (NS_ERROR_DOM_INVALID_EXPRESSION_ERR)" location: "chrome://browser/content/browser.xul Line: 8"]
that means that the format of your instruction was wrong. Check your ( " ; / [ @ ' ] ) and their pairing then correct and try again !

My Lxpath.txt file lists some xpath codings I have used : maintain a similar file (you may also add the corresponding source line).
rc := nxpath("nigelle;1;//input[@name='username']") ; go to the user field
rc := nxpath("nigelle;1;//a[contains(text(),'some text')]") ;select "some text" in text part
rc := nxpath("nigelle;1;//a[contains(text(),'Disconnect')]") ; click on "Disconnect" labelled button
rc := nxpath("nigelle;1;//input[@name='validate']") ; "validate" button
rc := nxpath("nigelle;1;//input[@class='login_valid']") ; OK button for login
If ! rctxp := rxpath("nigelle;1;//input[@class='special_box']") ; if the "special_box" exist, do some processing
rc := nxpath("nigelle;1;//a[contains(@href,'xxx.asp')]") ; click on a link
More elaborate examples
rc := nxpath("nigelle;1;//a[contains(@onclick,'return function_name')]") ; click on Javascript function_name by name only
rc := nxpath("nigelle;1;//a[contains(@href,'javascript:function(" . var . "')]") ; click on Javascript function by name and data previously extracted
rc := nxpath("nigelle;2;//a[contains(@onclick,'" . pp . "')]") ; click on Javascript function only by data previously extracted
Random, rand, 1, 6
rc := nxpath("nigelle;" . rand . ";//a[contains(@onclick,'BanClick')]") ; Randomly select an advertizing banner among 6 defined by function name in other cases something like ...//a[@class='banner']") may be used.


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Wiki
PostPosted: February 2nd, 2010, 6:00 pm 
Offline

Joined: September 26th, 2008, 6:09 pm
Posts: 82
Location: France
To hugov
I have entered a first text "Preparing to script : what I do. " but the formatting is awful : please give help for formatting headings and lists items.

After this, what have I to do? Enter my other texts ? In which order ?


Last edited by nigelle on February 2nd, 2010, 6:45 pm, edited 2 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject: short-cuts
PostPosted: February 2nd, 2010, 6:41 pm 
Offline

Joined: September 26th, 2008, 6:09 pm
Posts: 82
Location: France
To Michael@oz
"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.

Last edited by nigelle on Tue Feb 02, 2010 5:34 pm; edited 3 times in total"

I hope I have understood what you wish.
BTW I don't see the need to have 2 separated texts English (90% size) and French (90% size) instead of a bilingual text.


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Re: short-cuts
PostPosted: February 2nd, 2010, 10:16 pm 
Offline

Joined: November 8th, 2009, 2:46 am
Posts: 234
Location: Canberra Oz
nigelle wrote:
To Michael@oz
"The original text has been edited... to improve the format as requested by Michael@oz.
BTW I don't see the need to have 2 separated texts English (90% size) and French (90% size) instead of a bilingual text.

I have been looking at Functions for Keyconfig and at how it loads the definitions using an overlay. While I'm not promising anything but it may be possible to get the definitions loaded automatically rather than having to cut/paste each manually.
As I don't like doing things manually more than once I decided that as your definitions evolve it may be necessary to extract definitions in one language. Plus it was an interesting learning experience in ahk...
Hence my Keyconfig Parser:
Code:
; Parse the bilingual keyconfig file
;
; Structure
; # in column 1 is a comment line
; Bilingual instructions
; --------- (min 20 '-'s) indicates a new key definition
;
; Each definition has the following structure
; other than the lines after code:, lines may have '(<-Fr/En-US->)' to seperate the French and English text
;
;      the ---- line
;      <key definition> (discription)
;      nom: <french key name> <(<-Fr/En-US->) name: <english key name>
;      code:
;      <1-n lines of code>
;      the ---- line
;
; <key definition> can contain 'Alt', 'Maj'/'Shift', 'Ctrl' followed by one character
;               the modifiers can optionally be followed by a +, eg 'Alt+Ctrl+a'
;
;   to do   split #comment lines by language
;         split comments on key definition line
;
;   v0-2   Added support for Maj/Shift in key definition
;
#SingleInstance, Force
SetBatchLines, -1
SetWorkingDir %A_ScriptDir%
SendMode Input
PScript:="KcParser"
PLangFlag:="(<-Fr/En-US->)"
;
; Get input file
FileSelectFile, PInFile,1,%A_MyDocuments%, %PScript%: Select bilingual keyconfig file
If PInFile =
   ExitApp
;
FileSelectFile, POutFile,16,%A_MyDocuments%, %PScript%: Select keyconfig output file
If POutFile =
   ExitApp
Loop
{
   InputBox, PTrans, %PScript%, Type E or F to Extract English or French:
   If Errorlevel
      ExitApp
   StringUpper, PTrans, Ptrans
   if (PTrans="E" or PTrans="F")
      Break
}
POldLine:="start"
PThisLine:="start"
PMode:="start"
Loop, Read, %PInFile%, %POutFile%
{
   POldLine:=PThisLine
   PThisLine:=A_LoopReadLine
   ToolTip,%A_Index%`,%PMode%`,%PThisLine%
   Sleep 50
   if (Substr(A_LoopReadLine,1,1)="#") {            ; comment?
      if (PMode!="start") {
         FileAppend, %A_LoopReadLine%`n            ; keep comments if in definition sections
;         Pause
      }
      Continue                              ; skip to next line
   }
   if (PMode="start")
      if (SubStr(A_LoopReadLine,1,20)="--------------------")      ; indicates first key section
         PMode:="key1"
   if (PMode="key1") {                                    ; <key definition>
      if (SubStr(A_LoopReadLine,1,20)="--------------------")
         Continue                                    ; skip to next line
      ; must be first line of key definition - extract keycodes
      if (InStr(A_LoopReadLine,"("))
         PKeyDef:=SubStr(A_LoopReadLine,1,InStr(A_LoopReadLine,"(")-1)
;      else                                                    ; Ignore for now
;         ErrExit("Key Definition expected at line " . A_Index)
      PStandKey:=PExtractKey(PKeyDef,PTrans)
      FileAppend, %PStandKey%`n ; note this ignores the comments on the key def line
      PMode:="key2"
      Continue
   }
   if (Pmode="key2") {                                 ; nom/name line
      if (!(Instr(A_LoopReadLine,"nom:") or Instr(A_LoopReadLine,"nom :")) or !(Instr(A_LoopReadLine,"name:") or Instr(A_LoopReadLine,"name :")))
         ErrExit("nom/name line expected at line " . A_Index)
      if (!Instr(A_LoopReadLine,PLangFlag)) {
         Pause
         ErrExit("Expecting '" . PLangFlag . "' at line " . A_Index)
      }
      PLangText:=PExtractName(A_LoopReadLine,PTrans)
      FileAppend, %PLangText%`n
      PMode:="code1"
      Continue
   }
   if (PMode="code1") {
      If !(Instr(A_LoopReadLine,"code:") or Instr(A_LoopReadLine,"code :"))
         ErrExit("Expecting code: at line " . A_Index)
      FileAppend, %A_LoopReadLine%`n
      PMode:="code2"
      Continue
   }
   if (PMode="code2") {
      FileAppend, %A_LoopReadLine%`n
      if (SubStr(A_LoopReadLine,1,20)="--------------------")
         PMode:="key1"                                 ; Next line is another definition or EOF
      
   }
}
;
;Pause
ExitApp
;
;
PExtractKey(PKey,PT)
{
   if (PT="E")
      StringReplace, PKey, Pkey, Maj/,, all
   if (PT="F")
      StringReplace, PKey, Pkey, /Shift,, all
   Return PKey
}
;
;
PExtractName(PName,PT)
{
   Global PLangFlag
   PENStart:=(PT="F" ? Instr(PName,"nom:") : Instr(PName,"name:",false,Instr(PName,PLangFlag)))
   PENLen:=(PT="F" ? InStr(PName,PLangFlag)-1 : StrLen(SubStr(PName,PENStart)))
   Return (Substr(Pname,PENStart,PENLen))
}

;
ErrExit(PErrText)
{
   Global PScript
   MsgBox,,%PScript%, %PErrText%, 16
   Pause
   ExitApp
}
;

Still needs s bit of work but gets the job done.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 3rd, 2010, 10:47 am 
Offline

Joined: February 2nd, 2008, 4:35 am
Posts: 643
nigelle wrote:
BTW I don't see the need to have 2 separated texts English (90% size) and French (90% size) instead of a bilingual text

You can use this nigelle, is single & bilingual :)
Code:
/*
Translation system.ahk
Last editied by a_h_k on 3-2-10
*/


; Delete files if already exist (overwrite)
;
FileDelete, %A_ScriptDir%\CommonF.ahk
FileDelete, %A_ScriptDir%\CommonE.ahk


; Read the CommonB file
;
FileRead, file_contents, %A_ScriptDir%\CommonB.ahk
{
  line_num_Fr := 0   ,   line_num_En := 0

  StringSplit, file_lines, file_contents, `n, `r

  Loop, %file_lines0%
  {
    file_line := file_lines%A_Index%

    If ( Left(file_line,6) = ">>(Fr)" )
    {
      StringTrimLeft, file_line, file_line, 6      ;Rid leading ">>(Fr)"
      line_num_Fr++
      lines_Fr%line_num_Fr% := file_line
    }
    Else If ( Left(file_line,6) = ">>(En)" )
    {
      StringTrimLeft, file_line, file_line, 6      ;Rid leading ">>(En)"
      line_num_En++
      lines_En%line_num_En% := file_line
    }
    Else
    {
      ; Put in BOTH French & English files

      StringTrimLeft, file_line, file_line, 6      ;Rid leading "      "

      line_num_Fr++
      lines_Fr%line_num_Fr% := file_line

      line_num_En++
      lines_En%line_num_En% := file_line
    }
  }
}
num_lines_Fr := line_num_Fr
num_lines_En := line_num_En


; Combine array lines into single variable
;
Loop, %num_lines_Fr%
{
  line_Fr := lines_Fr%A_Index% . "`n"
  file_lines_Fr .= line_Fr
}
Loop, %num_lines_En%
{
  line_En := lines_En%A_Index% . "`n"
  file_lines_En .= line_En
}


; Write the data to files
;
FileAppend, %file_lines_Fr%, %A_ScriptDir%\CommonF.ahk
FileAppend, %file_lines_En%, %A_ScriptDir%\CommonE.ahk


ExitApp

Modify this CommonB.ahk
Code:
>>(Fr);--------fini() means "chargement FINI"
>>(En);--------fini() means "loading FINIshed"
      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
        {
>>(Fr)    ster := wher " * Dépassement temps de chargement " . ElapsedTime . " ms `n "
>>(En)    ster := wher " * Timeout loading " . ElapsedTime . " ms` n "
          rc := err1(ster,fnErr)
        }
>>(Fr)  ;MsgBox, , , temps de chargement %ElapsedTime% ms. %wher% ,4
>>(En)  ;MsgBox,, loading time %ElapsedTime% ms. %Wher%, 4
        return ElapsedTime ; >1
      }
>>(Fr);--------slect(x) means "SéLECTe"
>>(En);--------slect(x) means "SeLECT"
      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 {
>>(Fr)    ster := wher " * Erreur slect(" . x . ") : pas trouvé. `n "
>>(En)    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
      }
>>(Fr);--------nxpath(x) means "Normal XPATH"
>>(En);--------nxpath(x) means "Normal XPATH"
      nxpath(x)
      {
        global wher, fnErr, st, fnl
        clipboard := x
        Sleep, 100
        Send, {CTRLDOWN}q{CTRLUP}
        rc := WClipChange(x)
        If clipboard <> Found
        {
>>(Fr)    ster := wher " * Erreur Xpat(" . x . ") `n " . clipboard . " `n "
>>(En)    ster := wher " * Error in Xpat(" . x . ") `n " . clipboard . " `n "
          rc := err1(ster,fnErr)
        }
        Sleep, 100
        return rc   ; rc>1 OK
      }
>>(Fr);---------rxpath(x) means "XPATH Récupérable"
>>(En);---------rxpath(x) means "Recoverable XPATH"
      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
        }
>>(Fr)  stertxp := wher " * Erreur Xpat(" . x . ") `n " . clipboard . " `n "
>>(En)  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
        }
      }
>>(En);---------WClipChange(x) means "Wait for Clipboard Change"
      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
        {
>>(Fr)    ster := wher " * Dépassement temps WClipChange " . ElapsedTime . " ms `n "
>>(En)    ster := wher " * Timeout WClipChange " . ElapsedTime . " ms `n "
          rc := err1(ster,fnErr)
        }
        return ElapsedTime  ; If OK , rc > 1
      }
>>(En);---------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
>>(Fr);---------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
      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
      }
>>(Fr);---------errClipW(x) ClipWait 10 s. avec gestion d'ErrorLevel
>>(En);---------errClipW(x) ClipWait 10 s. with ErrorLevel processing
      errClipW(x)
      {
        global wher, fnErr, st, fnl
        ClipWait, 10  ; Wait for the clipboard to contain text.
        if ErrorLevel
        {
>>(Fr)    ster := wher " * Erreur ClipWait dans fonction " . x . " `n "
>>(En)    ster := wher " * Error ClipWait in function " . x . " `n "
          rc := err1(ster,fnErr)
        }
        return 1
      }
>>(En);---------VerREMatch(x,y) VERify that RegExMatch has found (returned variable x not 0), pass y to the error message
>>(Fr);---------VerREMatch(x,y) VERifie que RegExMatch a trouvé (variable x retournée n'est pas 0), passe y au message d'erreur
      VerREMatch(x,y)
      {
         global wher, fnErr, st, fnl
         If x = 0
         {
            ErrREMatch(y)
         }
        Sleep, 100
        return 0   ; rc=0 OK , rc=1 KO
      }
>>(Fr);---------ErrREMatch(x) procedure d'ERReur pour RegExMatch
>>(En);---------ErrREMatch(x) ERRor procedure for RegExMatch
      ErrREMatch(x)
      {
        global wher, fnErr, st, fnl
>>(Fr)  ster := wher " * Erreur RegExMatch pour " . x . " : rien trouvé `n "
>>(En)  ster := wher " * Error RegExMatch for " . x . " : nothing found `n "
        rc := err1s(ster,fnErr)
         return rc   ; rc=0 OK , rc=1 KO
      }
>>(Fr);---------Purgelog() st est mis dans le log normal
>>(En);---------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
      }
>>(Fr);---------sourc() retourne la SOURce normal (ctrl u)
>>(En);---------sourc() return normal SOURCe (ctrl u)
      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
      }
>>(Fr);---------sdom() retourne la Source du DOM
>>(En);---------sdom() return Source of DOM
      sdom()
      {
        clipboard =  ; Start off empty to allow ClipWait to detect when the text has arrived.
        Send, {ALTDOWN}{SHIFTDOWN}u{SHIFTUP}{ALTUP}
>>(Fr)  errClipW(A_ThisFunc) ; ClipWait 10 s. avec gestion d'ErrorLevel
>>(En)  errClipW(A_ThisFunc) ; ClipWait 10 s. with ErrorLevel processing
        return clipboard ; source du DOM
      }
>>(Fr);---------maxim() MAXIMise
>>(En);---------maxim() MAXIMize
      maxim()
      {
        Send, {CTRLDOWN}{SHIFTDOWN}m{SHIFTUP}{CTRLUP}
        Sleep, 200
        return 0
      }
>>(Fr);---------max3q() MAXimise au 3 Quarts
>>(En);---------max3q() MAXimize to 3 Quarters
      max3q()
      {
        Send, {CTRLDOWN}m{CTRLUP}
        Sleep, 200
        return 0
      }
>>(Fr);---------vertit(x) VERifie que le TITre contient x
>>(En);---------vertit(x) VERify that TITle contains x
      vertit(x)
      {
        global wher, fnErr, Title, st, fnl
        WinGetTitle, Title, A
        IfNotInString, Title, x
        {
>>(Fr)    ster := wher " * Erreur titre = " . Title . " `n "
>>(En)    ster := wher " * Error title = " . Title . " `n "
          rc := err1(ster,fnErr)
        }
        return 0   ; rc=0 OK , rc=1 KO
   }
>>(Fr);---------versourc(x) VERifie que la SOURCe du DOM contient x
>>(En);---------versourc(x) VERify that the SOURCe of DOM contains x
      versourc(x)
      {
        global wher, fnErr, source, st, fnl
        source := sdom()
      ;    FileAppend, %source%, %fnErr%
        IfNotInString, source, x
        {
>>(Fr)    ster := wher " * Erreur : source ne contient pas " . x
>>(En)    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
      }
>>(Fr);---------verURL(x) VERifie que l'URL est x
>>(En);---------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
        {
>>(Fr)    ster := wher " * Erreur : URL = " . vURL . "`n au lieu de " . x
>>(En)    ster := wher " * Error : URL = " . vURL . "`n instead of " . x
          rc := err1(ster,fnErr)
          return 1   ; rc=0 OK , rc=1 KO
        }
      }
>>(Fr);---------retURL() RETourne l'URL
>>(En);---------retURL() RETurn URL
      retURL()
      {
        clipboard =  ; Start off empty to allow ClipWait to detect when the text has arrived.
        Send, {ALTDOWN}{SHIFTDOWN}l{SHIFTUP}{ALTUP}
>>(Fr)  errClipW(A_ThisFunc) ; ClipWait 10 s. avec gestion d'ErrorLevel
>>(En)  errClipW(A_ThisFunc) ; ClipWait 10 s. with ErrorLevel processing
        Sleep, 100
        return clipboard ; URL
      }
>>(Fr);---------URLcont(x) verifie que l'URL CONTient x
>>(En);---------URLcont(x) verify that the URL CONTains x
      URLcont(x)
      {
        global wher, fnErr, st, fnl, vURL
        vURL := retURL()
        IfInString, vURL, %x%
        return 0   ; rc=0 OK , rc=1 KO
        Else
        {
>>(Fr)    ster := wher " * Erreur : URL = " . vURL . "`n ne contient pas " . x
>>(En)    ster := wher " * Error : URL = " . vURL . "`n does not contains " . x
          rc := err1(ster,fnErr)
          return 1   ; rc=0 OK , rc=1 KO
        }
      }
>>(Fr);---------Dur(x) DURée du script
>>(En);---------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%
      }
   ;--------variables
>>(Fr); Initialisation des variables toujours utilisées
>>(Fr)   wher := " ??? " ; Vous voyez ceci si ça n'a pas été défini dans le script
>>(Fr)   st := " ... " ; Rien encore à mettre dans le log
>>(Fr); Chemin complet du répertoire des logs. Ici le repertoire des scripts AHK suivi de Log
>>(Fr)   fnErr = %logdir%Err.log ; Log standard pour les errreurs : il faut en définir un
>>(Fr)   deb := A_Now ; Temps du début, utilisé par dur(deb) à la fin du script

>>(En); initialize always used variables
>>(En)   wher := " ??? " ; you see this if it has not been defined in the script
>>(En)   st := " ... " ; nothing yet to put in normal log file
>>(En)   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)   fnErr = %logdir%Err.log ; standard error log file : one should be defined
>>(En)   deb := A_Now ; start time used by dur(deb) at the bottom of script


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Localization
PostPosted: February 3rd, 2010, 2:02 pm 
Offline

Joined: September 26th, 2008, 6:09 pm
Posts: 82
Location: France
To Michael@oz and a_h_k (by order of posting !)
I see that you are as lazy as I am : first times you do it manually, then you write something that does it automatically...

First a general question : do we need localization in other (than Fr and En) languages ?
Historically I wrote in French (keeping English comments when I pasted instructions from the AHK doc.) because I am French and I added En/Us to ease discussions in the forum and use. If we have to add a dozen languages, my bilingual provisional solution become difficult to manage in a hierarchical way and we shall have to shift to the federal solution of multiples files (each country is responsible for his own) and to include indexed pieces of the chosen one in the messages. This is what other programs do.

Where do we put library, short-cuts and example scripts ? I think that the Wiki can be modified by everyone, so a malicious "editor" can transform our work to a complete mess ! Do you have better ideas ?

I have found "Functions for Keyconfig" in the AMO before I discovered "Keyconfig" through the link in the former extension. As far as I know, its keys are also defined in standard "Keyconfig". The most lazy solution is to negotiate with Dorando the inclusion of "our" (in fact the true author is Dorando) dozen of short-cuts in the standard "Keyconfig". It has already a localization system to which we can contribute the French and English text. Dorando is already aware of AHK and its documentation but I am not sure that he practise it. By having AHK referenced in "Keyconfig", we gain that our work will be better known by many others and new users avoid the step of short-cuts entry... I plan to send a PM to Dorando as soon are we are stabilized : he may be interested to know what we have done with his short-cuts.


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Re: Localization
PostPosted: February 3rd, 2010, 10:30 pm 
Offline

Joined: November 8th, 2009, 2:46 am
Posts: 234
Location: Canberra Oz
nigelle wrote:
To Michael@oz and a_h_k (by order of posting !)
I see that you are as lazy as I am
perhaps more so...
Quote:
First a general question : do we need localization in other (than Fr and En) languages ?
I think other longer term ahk'ers may be better placed to comment, but from my browsing here it does seem english focused, there are two aspects, your playback scripting with logging and error messages, my more user interface automation need.

For your use, do you share the logged results/errors with other non-ahk and/or non-English literate people? If not, there is probably little need for other languages??
Quote:
Where do we put library, short-cuts and example scripts ? Do you have better ideas ?
Have you seen this?

Quote:
I have found "Functions for Keyconfig" in the AMO before... its keys are also defined in standard "Keyconfig"
I'm not sure whether you mean;the process of defining is based on standard Keyconfig; or, the functions are included in standard Keyconfig?
If you mean the second, they were not in Keyconfig that I downloaded; perhaps there is some other file?
I mentioned FFK because it manages to load it's code and key definitions via FF extension, ie
    <?xml version="1.0"?>

    <overlay id="functions_for_keyconfig_overlay"
    xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">

    <script type="application/x-javascript" src="chrome://functions_for_keyconfig/content/f4kc_utils.js" />
    <script type="application/x-javascript" src="chrome://functions_for_keyconfig/content/f4kc_FocusNextFrame.js" />
    <script type="application/x-javascript" src="chrome://functions_for_keyconfig/content/f4kc_UpperDirectory.js" />
    <script type="application/x-javascript" src="chrome://functions_for_keyconfig/content/f4kc_ToggleCheckBox.js" />
    <script type="application/x-javascript" src="chrome://functions_for_keyconfig/content/f4kc_CanonizeURL.js" />
    <script type="application/x-javascript" src="chrome://functions_for_keyconfig/content/f4kc_misc.js" />

    <window id="viewSource">
    <keyset id="viewSourceKeys">
    <key id="f4kc_Back" oncommand="f4kc_Back();" key="q" modifiers="meta,alt" />
    <key id="f4kc_Back2" oncommand="f4kc_Back();" key="p" modifiers="meta,alt" />
    <key id="f4kc_BookmarkThisPage" oncommand="f4kc_BookmarkThisPage();" key="a" modifiers="meta,alt" />
    <key id="f4kc_CompleteURL_com" oncommand="f4kc_CanonizeURL();" key="c" modifiers="accel,shift,meta,alt" />
    <key id="f4kc_CompleteURL_net" oncommand="f4kc_CanonizeURL('.net/');" key="n" modifiers="accel,shift,meta,alt" />
    <key id="f4kc_CompleteURL_org" oncommand="f4kc_CanonizeURL('.org/');" key="o" modifiers="accel,shift,meta,alt" />
    <key id="f4kc_ClearHTTPAuth" oncommand="f4kc_ClearHTTPAuth();" key="c" modifiers="shift,meta,alt" />
    <key id="f4kc_ClearJSConsole" oncommand="f4kc_ClearJSConsole();" key="c" modifiers="meta,alt" />
    <key id="f4kc_CopyCurrentTitle" oncommand="f4kc_CopyCurrentTitle();" key="t" modifiers="meta,alt" />
    <key id="f4kc_CopyCurrentURI" oncommand="f4kc_CopyCurrentURI();" key="y" modifiers="meta,alt" />
    ...
I'm still learning as I go, but it seems it may be relatively easy to define your/Dorando's code this was too. It may take me some time, but I'm going to try this.
Quote:
The most lazy solution is to negotiate with Dorando the inclusion of "our" (in fact the true author is Dorando) dozen of short-cuts in the standard "Keyconfig".
Whatever's easiest...[/url]


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 4th, 2010, 2:37 pm 
Offline

Joined: September 26th, 2008, 6:09 pm
Posts: 82
Location: France
Quote:
Have you seen this?

I was not aware of www.autohotkey.net , now I am registered to it. If I upload a file, who has the rights to
-modify it ?
-read and download it ?
I have not found this information on the site.

Quote:
they were not in Keyconfig that I downloaded

It seem that presently you are right ! But first time I installed Keyconfig, I remember that I have seen "f4kc_" in some definitions : I may be wrong...
What does functions_for_keyconfig does when I just want to modify a key which is already defined ?

Quote:
I think other longer term ahk'ers may be better placed to comment, but from my browsing here it does seem english focused, there are two aspects, your playback scripting with logging and error messages, my more user interface automation need.

I have found that www.autohotkey.net proposes the AHK documentation in more than half a dozen languages. Let us wait that the readers ask for more translations !
When you post, you use the English forum, if you understand English, because the great majority of people read and post in it...
I agree that each of us has different needs, that my experience can help you or others and that your experience can help me or the other members of AHK community...
Presently I share my scripts only with my children that speak French. But the library of functions may be shared with (and improved by) others...


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 83 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], Google Feedfetcher, nimda, poserpro, rbrtryn, sjc1000, Yahoo [Bot] and 16 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group