AutoHotkey Community

It is currently May 27th, 2012, 6:57 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: October 6th, 2011, 1:32 am 
Offline

Joined: September 30th, 2011, 6:02 pm
Posts: 1
Location: Québec
Code:
;  Updated[2]: 2012-01
;################################################################################
;
; The utility of "Rig.ahk" is to help picture's collector in their Internet research,
; particularly with "Google Images Research" (GIR).
;
;=============
; In four steps:
;    (Supposed the program "Rig.ahk" is in the "RIG" directory,
;     only pictures directory in RIG will be part of the summary)
;
; 1- Create or choose in RIG a directory having your question as name;
;    - RIG\Question
;    - the first question in "Questions.rig" will be the same.
; 2- You add or choose a question you want to treat.
;    - if you add a question, you will have to select or create the collection
;      that is concern 
; 3- INSIDE YOUR INTERNET NAVIGATOR AND WITH THE MACROS:
;    - change page (first, preceding, following and page X)
;    - pick up the address of the pictures you want on these pages.
;    - if a lot of pictures with the same address differs only by the ending
;      number and are consecutive
;      - the use of Numpad- will active rig_Number, then follow the Gui;
;      - the addresses will be sent to Clipboard;
;      - the use of Numpad+ will send Clipboard to the file "Images.rig"
; 4- finally download your pictures (automaticaly in "RIG\Question"
;    - if the download is discontinued, you have to:
;      - check the pictures downloaded and clean the file "Images.rig"
;      - transfert the pictures in the subdirectory "RIG\Question\Images"
;      - close the program and reopen it.
;    - if some pictures concern a second subject
;      - let them alone in "RIG\Question"
;      - <Ins> and rig_Name wil rename and renumber them.
;
; n.b.: some pictures can be:
;         - a partial download,
;         - a html message saying the picture will not be found,
;         - a gif picture (bmp or pgn),
;         - no answer, impossible to download.
;       limit of pictures by collection = 999 (pay attention):
;         - "name of collection"_001  to  "name of collection"_999
;       recommanded: to make a copy of the file "Images.rig" when the pick-up
;         of the addresses is finish; for a picture's identification purpouse                   
;=============
;
; You pick up the address of pictures without visiting the owner site; better security.
;
; You can change the parameters of the research for better results.  (Size, format, etc...).
; The program can be extended to other picture's bank similar to Google as "Yahoo"...
; The program can be extended to a navigator different of "iExplore.exe".
;
; The problem with Internet research is the limited answer; never more than 1000 answers
; (50 page of 20 answers); and the possibilities can be several millions.
; To overpass the problem, changing the question in any ways.
;
; And GIR is a surprise box; you can ask a very concise question; but the answer,
; every time, will have a caotic part and does'nt seem to have a ponderated order as in the past.
; They do'nt furnish and objective answer; I think they serve their own clients first.
; A capitalist ponderation.
;
; Have nice collects...
; D4Pro
;
;###############################################################################

;*****  Sommaire  **************************************************************
;
;     RIG  (Recherche d'images Google) 
;          (Google Image Research) and other site.
;
;     Edited by: D4Pro      (2012-01-11)  For a 56k modem (slowly but surely)
;     French notes are in phonetical code (H94) for french speaking
;     frèn¢  not_âr_in    fônéticel  cod  (H94) for frèn¢  spikiñ
;
;     Continuation of PhotoPhorcer  /  PhotoDownloader
;     Published by: Rowo    (2007-09-16)
;
;               Version: 3.2
;               Windows: XP Pro
;            AutoHotKey: Version 1.0.48.00
;                Editor: PSPad
;     Internet Explorer: Version 8.0
;
;     Possible problem: different format for a different language (to t¢èk)
;     Other problem: I don't know how to stop manualy the downloading Loop
;                   I used MsgBox to avoyed it;
;                   In Delphi there is: Application.ProcessMessages.
;
;-------------------------------------------------------------------------------
;
; See file format at the end...
;
; In the directory of the picture's collection    =  %rigDir1%
;
; - Directory of pictures downloaded              =  Images
; - List file name of pictures to download        =  Images.rig
; - List of request captured on the run           =  Questions.rig
;
; In the directory of the program                 =  %rigDir0%
;
; - The last pictures directory visited
;   and a summary of the work to do               =  Rig.Inf
; - All directory of picture's collection
;
;-----  Macros  ----------------------------------------------------------------
;
; ^Down::       ; Current page   / Google's image research      / rig_PageX(rigQuestion,rigPage)
; ^Ins          : Rename pictures in %rigDir1%                  / rig_Name()
; ^Left::       ; Preceding page / Google's image research      / rig_PageBefore()
; ^NumpadAdd::  ; Clipboard append to "Images.rig"              / rig_GetClipboardUrl()
; ^NumpadSub::  ; Automatic numbering append to Clipboard       / rig_Number()
; ^Right::      ; Following page / Google's image research      / rig_PageAfter()
; ^Up::         ; Page selection / Google's image research      / rig_PageXInput()
;
; For the two following macros...
; the URL is sended to clipboard, showed with MsgBox
; and on confirmation appended to "Images.rig"
;
; ^PgDn::  ; URL extracted of the task-bar ( iExplorer ) When it's only address    / rig_GetUrl
; ^PgUp::  ; URL extracted of the task-bar ( iExplorer ) Google's image research   / rig_GetUrlG()
; ^LButton::   ; Same as ^PgUp
;
;-----  Procédures  ------------------------------------------------------------
;
;  rig_Close()           ; Close the application
;  rig_DownloadImg()     ; Download of "Images.rig"
;                        ; Clean "Images.rig" before to close the program,
;                        ; for having an updated summary in "Rig.inf"
;  rig_EachSide( String, Text, Result )
;                        ; abcxyzdef --> abc, def
;  rig_GetClipboardUrl   ; Add Clipboard to "Images.rig"
;  rig_GetUrl()          ; If task-bar is only url (<> RIG))
;  rig_GetUrlG()         ; url extracted of the task-bar for RIG
;  rig_Number()          ; auto-number consecutive pictures in Clipboard
;  rig_PageAfter         ; Next pictures page on "RIG"
;  rig_Pagebefore        ; Preceding pictures page on "RIG"
;  rig_PageX( q, x )     ; Get pictures page X on "RIG"
;  rig_PageXInput()
;  rig_SetBetween( String1, String2, String3, ByRef Text )
;                        ; abcxyzdef --> abcXYZdef
;  rig_Summary()         ; furnish in "Rig.inf" the page (<50) of all questions
;                        ; and the number of pictures to download
;                        ; for all pictures directory contained in "RIG".
;
;-----  Fonctions  -------------------------------------------------------------
;
;  rig_GetAfter(   String , Text   )          ; abcxyz --> xyz
;  rig_GetBetween( String1, String2, Text )   ; abcxyzdef --> xyz
;  rig_Zero(       ch     , n      )          ; Left side completed with zeros
;
;*****  Auto-exécutable  *******************************************************

   #NoEnv
   SendMode Input

   ; variabl glôbal
   rig1        =                ; adrès cöplèt du fi¢yé "rig.inf"
   rigAdr1     =                ; adrès URL de l'imaj sûrs
   rigAdr2     =                ; nö cöplè de l'imaj d'arivé 
   rigCol      =                ; nö de côlècsyö dôné a l'imaj
   rigDat1     =                ; variyabl de sêrvis
   rigDat2     =                ; variyabl de sêrvis
   rigDir0     = %A_ScriptDir%  ; répêrtwâr du prôgram
   rigDir1     =                ; répêrtwâr d_la list d'imaj "Images.rig"
   rigDr       = 0              ; drapo (= 1 si ë télé¢arjemë,
                                ;        = 2 pûr_arèté le télé¢arjemë)
   rigI1       = 1              ; rä a dôné a la prô¢èn_imaj d_la côlècsyö
;  rigI2..rigIx                 ; cötyï ¢aq_imaj de "Images.rig"
   rigImg      = Images.rig     ; nö d_la list d'imaj_a télé¢arjé (présédé de %rigDir1%)
   rigMod      = 0              ; = 1 si - "rigDir1" è môdifyé
                                ;        - un_adrès_imaj_èt_ajûté a %rigImg%
                                ;        - un qèstyö èt_ajûté a %rigQst%
                                ;        - la qèstyö cûrät_é ¢äjé     
   rigNip      = 20             ; nöbre d'imaj par paj
   rigNom      =                ; rëplas "rigCol" dä "rigDir1" pûr lé nö d'imaj
   rigPage     = 0              ; paj d'imajèt (1 a 49)
   rigQ1       = 3              ; rä d_la qèstyö cûrät
;  rigQ2..rigQx                 ; cötyï ¢aq qèstyö de "Questions.rig"
   rigQst      = Questions.rig  ; list dé qèstyö sur le sujè (présédé de %rigDir1%)
   rigQuestion =                ; re¢èr¢ cûrät
   rigRangC    = 1              ; rä a dôné a la prô¢èn_imaj d_la côlècsyö (= rigI1)
   rigRangI    = 1              ; rä dä la côlècsyö a dôné a l'imaj cûrät
   rigRangQ    = 3              ; rä d_la qèstyö cûrät (= rigQ1)

   ; activ le navigater ( iExplore.exe )
   IfWinExist ahk_Class IEFrame
      WinActivate ahk_Class IEFrame
   Else
      Run iExplore.exe About:Blank
   WinWait ahk_Class IEFrame
   Sleep 500

   rig1 = %rigDir0%\Rig.inf
   rig_IniRead()
   rig_Gui()
Return  ;< Auto-exécutable >

;*****  Macros  ****************************************************************

;===============================================================================
; renôm léz_imaj de %rigDir1%
;-------------------------------------------------------------------------------

^Ins::rig_Name()

;===============================================================================
; ajû d'adrès_o prês-papyé &
; ajû du prês-papyé a %rigImg%
;-------------------------------------------------------------------------------

^NumpadSub::rig_Number()   

^NumpadAdd::rig_GetClipboardUrl()   

;===============================================================================
; pûr_acsédé a un paj qèlcöq d_la re¢èr¢ d'imaj Google
; (la bâr d'adrès dwa référé a un paj > 1)
;-------------------------------------------------------------------------------

; paj X
^Up::rig_PageXInput()   

; paj cûrät
^Down::rig_PageX( rigQuestion, rigPage )

; paj présédët
^Left::rig_PageBefore()

; paj suivät
^Right::rig_PageAfter()

;===============================================================================
; èxtracsyö URL de la bâr de t⢠( iExplorer )
;-------------------------------------------------------------------------------

^PgDn::rig_GetUrl()

;===============================================================================
; èxtracsyö URL de la bâr de t⢠( iExplorer ) re¢èr¢_imaj Google
;-------------------------------------------------------------------------------

^PgUp::rig_GetUrlG()

^LButton::rig_GetUrlG()

;*****  Procédures  ************************************************************

;===============================================================================
; fêrmetur du prôgram
;-------------------------------------------------------------------------------

rig_Close()
{
   ExitApp
   Return
}  ;< rig_Close() >

;===============================================================================
; démaraj du télé¢arjemë
;-------------------------------------------------------------------------------

rig_DownloadImg()   
{
   Global
   Local  m, r1, v1, v2
   ; inisyalizasyö
   MsgBox 0, Info, Téléchargement commencé!, 1
   ; télé¢arjemë
   i = 2
   Loop
   {
      Loop Parse, rigI%i%, %a_Tab%
         v%a_Index% := a_LoopField
      rigRangI := v1
      rigAdr1  := v2
      v1 := i-1
      v2 := rigI0-1
      r1 := rig_Zero( rigRangI, 3 )
      GuiControl 99:, vGBtel, %a2%4 - Le téléchargement: (%r1% = %v1%/%v2%)%a2%
      rigAdr2  := rigDir1 . "\" . rigCol . "_" r1 . ".jpg"
gt1:
      UrlDownloadToFile %rigAdr1%, %rigAdr2%     ; ErrorLevel = 0   si réusi
      IfNotExist %rigAdr2%
      {
         If m<3
         {
             m++
            GoTo gt1
         }
         Else m = 0
      }
      If m=1
         MsgBox 0, Téléchargement réussi, %rigAdr2%, 1
      Else
         MsgBox 0, Téléchargement échoué, %rigAdr2%, 1
      i ++
      If  (i>rigI0)Or(dr=2)
         Break
      Else
      {
         MsgBox 4100, RIG, Voulez-vous interrompre le téléchargement?, 3
         IfMsgBox Yes
            Break
      }
   }
   MsgBox 0, Info, Téléchargement %rigCol% terminé!, 2
   GuiControl 99:, vTel, Démarrer
   Return
}  ;< rig_DownloadImg() >

;===============================================================================
; Result = Quoted value
; rig_EachSide( "123", "Left123Right", "Res" )
; after call: Res1 = "Left"
;             Res2 = "Right"
;-------------------------------------------------------------------------------

rig_EachSide( String, Text,  Result ) 
{
   Local a1, a2, p1
   a1 := StrLen( String )
   a2 := StrLen( Text )
   p1 := InStr( Text, String )
   %Result%1 := SubStr( Text, 1, p1-1 )
   %Result%2 := SubStr( Text, p1+a1, a2 )
   Return
}  ;< rig_EachSide() >

;===============================================================================
; ajût le cötnu du prês-papié o fi¢yé %rigImg%
;-------------------------------------------------------------------------------

rig_GetClipboardUrl()
{
   rigI0++
   rigI%rigI0% = %rigRangC%%a_Tab%%lien%
   rigRangC++
   rigI1 := rigRangC
   GuiControl 99:, vRng, %a3%%a3%Rang:  %rigRangC%
   rigMod = 1
   Return  ;< rig_GetClipboardUrl() >


;===============================================================================
; èxtracsyö URL de la bâr de t⢠( iExplorer ) sit <> Google
;-------------------------------------------------------------------------------

rig_GetUrl()
{
   Local lien, wt
   WinGetActiveTitle wt
   ControlGetText lien, msctls_StatusBar321, %wt%
   MsgBox 4100, Ajouter l'adresse?, %lien%, 3   
   IfMsgBox Yes
   {
      rigI0++
      rigI%rigI0% = %rigRangC%%a_Tab%%lien%
      rigRangC++
      rigI1 := rigRangC
      GuiControl 99:, vRng, %a3%%a3%Rang:  %rigRangC%
      rigMod = 1
   }
   Return
}  ;< rig_GetUrl() >

;===============================================================================
; èxtracsyö URL de la bâr de t⢠( iExplorer ) re¢èr¢_imaj Google
;-------------------------------------------------------------------------------
;   fôrmô de l'adrès_imaj Google a la fï
;-------------------------------------------------------------------------------

rig_GetUrlG()
{
   Local lien, wt
   WinGetActiveTitle wt
   ControlGetText lien, msctls_StatusBar321, %wt%
   lien :=       rig_GetBetween( "?imgurl="   , "&imgrefurl=", lien )
   lien := RegExReplace( lien, "%25", "%" )                                ; (*)
   lien := RegExReplace( lien, "%20", " " )
;  lien := RegExReplace( lien, "%22", """ )
   lien := RegExReplace( lien, "%26", "&" )
   lien := RegExReplace( lien, "%2B", "+" )
   lien := RegExReplace( lien, "%2F", "/" )
   lien := RegExReplace( lien, "%3A", ":" )
   lien := RegExReplace( lien, "%3D", "=" )
   lien := RegExReplace( lien, "%3F", "?" )
   lien := RegExReplace( lien, "%A9", "é" )
   MsgBox 4100, Ajouter l'adresse?, %lien%, 3
   IfMsgBox Yes
   {
      rigI0++
      rigI%rigI0% = %rigRangC%%a_Tab%%lien%
      rigRangC++
      rigI1 := rigRangC
      GuiControl 99:, vRng, %a3%%a3%Rang:  %rigRangC%
      rigMod = 1
   }
   Return
}  ;< rig_GetUrlG() >

; (*): avä le télé¢arjemë, vérifyé s'il ne rèst pâ d'otr côd (%) a cövêrtir;

;===============================================================================
; l'ïtêrfas vizuèl du prôgram
;-------------------------------------------------------------------------------
; èxcluä la manipulasyö de "iExplore.exe" qi se fè par macro
;-------------------------------------------------------------------------------

rig_Gui()
{
   Global
   Local a2, a3, a4, rc, u, v, w, x
   Critical
   a2 := "  "
   a3 := "   "
   a4 := "    "
   dr := 0  ; drapo = 1 si télé¢arjemë, = 0 otremë

   Gui 99: Font, S9 cDefault w900, Courier new
   Gui 99: Add, GroupBox, x6   y10  w350 h90                     , 1 - Le répertoire:
   Gui 99: Add, Button  , x16  y30  w330 h20 +Center       ggChR , %a3%Choix d'un répertoire
   Gui 99: Add, Text    , x31  y55  w315 h20       vvCol
   Gui 99: Add, Text    , x31  y75  w315 h20       vvRng
   GuiControl 99:, vCol, Collection:  %rigCol%
   GuiControl 99:, vRng, %a3%%a3%Rang:  %rigRangC%
   
   Gui 99: Add, GroupBox, x6   y110 w350 h115                    , 2 - La question:                   
   Gui 99: Add, Button  , x16  y130 w330 h20 +Center       ggChQ , %a3%Choix d'une question
   Gui 99: Add, Button  , x16  y155 w330 h20 +Center       ggAjQ , %a3%Ajout d'une question
   Gui 99: Add, Text    , x31  y180 w315 h20       vvQst
   Gui 99: Add, Text    , x31  y200 w315 h20       vvPaj
   GuiControl 99:, vQst, Question:  %rigQuestion%
   GuiControl 99:, vPaj, %a4%Page:  %rigPage%
   
   Gui 99: Add, GroupBox, x6   y235 w350 h185                    , 3 - Les images:  (Focus sur iExplore.exe)
   Gui 99: Add, Text    , x16  y255 w330 h20                     , <Clic>  +  Oui  =  Saisi Googles Images = <PH>
   Gui 99: Add, Text    , x16  y275 w330 h20                     , <PB>    +  Oui  =  Saisi des autres sites
   Gui 99: Add, Text    , x16  y295 w330 h20                     , <N->  =  Auto-numérotation (--> Presse-papier)
   Gui 99: Add, Text    , x16  y315 w330 h20                     , <N+>  =  Presse-papier (--> Images.rig)
   Gui 99: Add, Text    , x16  y335 w330 h20                     , <FB>  =  Page courante
   Gui 99: Add, Text    , x16  y355 w330 h20                     , <FD>  =  Page suivante
   Gui 99: Add, Text    , x16  y375 w330 h20                     , <FG>  =  Page précédente
   Gui 99: Add, Text    , x16  y395 w330 h20                     , <FH>  =  Page X (de 1 à 50)

   Gui 99: Add, GroupBox, x6   y430 w350 h50         vvGBtel     , 4 - Le téléchargement:
   Gui 99: Add, Button  , x16  y450 w330 h20 +Center vvTel ggTel , Démarrer
   
   Gui 99: Show         ,           w365 h490 +Center            , Recherche d'Images Googles (jpg)
   Return
;-------------------------------------------------------------------------------
   gAjQ:
      u =
      InputBox u, Question à ajouter,,,, 105
      If  u<>
      {
;[1]
         Clipboard = %u%  ; to use for creating a new collection
         FileSelectFolder v, %rigDir0%, 1, Choix (ou création) du répertoire`nqui contiendra la QUESTION.
         If  (ErrorLevel=1)Or(rigDir= )
            Return
;[2]
         w = %v%\Images.rig
         IfNotExist  %w%
            FileAppend 1`n, %w%
;[3]
         w = %v%\Questions.rig
         StringSplit x, v, \
         rc := x%x0%
         IfNotExist  %w%
            FileAppend 2`n%rc%%a_Tab%1`n, %w%
         Else
         {         
            FileAppend %u%%a_Tab%1`n, %w%
            If  v=%rigDir1%
            {
               rigQ0++
               rigQ%rigQ0% := u . a_Tab . "1"
            }
         }
;[4]
         IfNotExist %v%\Images
            FileCreateDir %v%\Images
         rigMod = 1
      }
   Return
;-------------------------------------------------------------------------------
   gChR:
      If  dr=1
         Return
      rig_Save()
;[1]
      FileSelectFolder rigDir1, %rigDir0%, 1, Choix (ou création) du répertoire`nqui contiendra la COLLECTION.
      If  (ErrorLevel=1)Or(rigDir= )
         Return  ; GoTo  aChR
      FileDelete %rig1%
      FileAppend %rigDir1%, %rig1%
;[2]
      rigImg = %rigDir1%\Images.rig
      IfNotExist  %rigImg%
         FileAppend 1`n, %rigImg%
;[3]
      rigQst = %rigDir1%\Questions.rig
      StringSplit u, rigDir1, \
      rigCol := u%u0%
      IfNotExist  %rigQst%
         FileAppend 2`n%rigCol%%a_Tab%1`n, %rigQst%
;[4]
      IfNotExist %rigDir1%\Images
         FileCreateDir %rigDir1%\Images
;[5]
      rig_IniRead()
      GuiControl 99:, vCol, Collection:  %rigCol%
      GuiControl 99:, vRng, %a3%%a3%Rang:  %rigRangC%
      GuiControl 99:, vQst, Question:  %rigQuestion%
      GuiControl 99:, vPaj, %a4%Page:  %rigPage%
      rigMod = 1
   Return
;-------------------------------------------------------------------------------
   gChQ:
      If  dr=1
         Return
      rig_Save()
      vLst := rigQ2
      Loop
      {
         u := a_Index+2
         If  u<=%rigQ0%
            vLst := vLst . "|" . rigQ%u%
         Else
            Break
      }
      Gui 98: Add, ListBox, x6   y6   w200 h400 +AltSubmit vvRgLst, %vLst%
      Gui 98: Add, Button , x6   y410 w95  h20  +Center    ggOK   , OK
      Gui 98: Add, Button , x112 y410 w95  h20  +Center    ggKO   , KO
      Gui 98: Show        ,           w210 h435 +Center           , Question à choisir
   Return
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
   gKO:
      Gui 98: Destroy
   Return
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
   gOK:
      Gui 98: Submit
      rigRangQ := vRgLst+1
      rigQ1 := rigRangQ
      u := rigQ%rigRangQ%
      StringSplit u, u, %a_Tab%
      rigQuestion := u1
      rigPage := u2       
      GuiControl 99:, vQst, Question:  %rigQuestion%
      GuiControl 99:, vPaj, %a4%Page:  %rigPage%
      rigMod = 1
      Gui 98: Destroy
   Return
;-------------------------------------------------------------------------------
   gTel:
      If  dr=1
         Return
      GuiControl 99:, vTel, Téléchargement en cours
      rig_Save()
      rig_DownloadImg()
      dr = 0
   Return
;-------------------------------------------------------------------------------
   99GuiClose:
      rig_Save()
      rig_Close()
   Return
;-------------------------------------------------------------------------------
}  ;< rig_Gui() >

;===============================================================================
; inisyalizasyö / lècture dè fi¢yé rig.inf, Images.rig & Questions.rig
;-------------------------------------------------------------------------------

rig_IniRead()
{
   Global
   Local u
;[1]
   FileReadLine, rigDir1, %rig1%, 1
   rigImg = %rigDir1%\Images.rig
   rigQst  = %rigDir1%\Questions.rig
   StringSplit u, rigDir1, \
   rigCol := u%u0%
;[2]
   Loop Read, %rigQst%
   {
      rigQ%a_Index% = %a_LoopReadLine%
      rigQ0 = %a_Index%
   }
   rigRangQ := rigQ1
   u := rigQ%rigRangQ%
   StringSplit u, u, %a_Tab%
   rigQuestion := u1
   rigPage := u2
;[3]
   Loop Read, %rigImg%
   {
      rigI%a_Index% = %a_LoopReadLine%
      rigI0 = %a_Index%
   }
   rigRangC := rigI1
   Return
}  ;< rig_IniRead() > 

;===============================================================================
; renôm %rigNom% lèz_imaj du répêrtwâr %rigDir1% & lè renumérôt
;-------------------------------------------------------------------------------

rig_Name()
{
   Global
   Local a, b, u, v, w, x

   InputBox rigNom, Quel nom s.v.p.?,,,, 105
   a  = %rigDir1%\%rigCol%_
   b  = %rigDir1%\%rigNom%_
   w := rigRangC-1
   x  = 1
   Loop  %w%
   {
      u := a . rig_Zero( a_Index, 3 ) . ".jpg"
      IfExist  %u%
      {
         v := b . rig_Zero( x, 3 ) . ".jpg"
         FileMove %u%, %v%
         x++
      }   
   }
}  ;< rig_Name() >

;===============================================================================
; otomatiz la numérôtasyö d'imaj sûrs cösécutiv (dä_l_ prês-papyé),
; utilizé <N+> pûr_ajûté a "Images.rig"
;-------------------------------------------------------------------------------

rig_Number()
{
   Global
   Local u = 1, v = 1, w

   Gui 97: Font, S9 cDefault w900, Courier new
   Gui 97: Add, GroupBox, x10  y10  w350 h160                , Répartition
   Gui 97: Add, Text    , x20  y30  w330 h20                 , Répertoire
   Gui 97: Add, Edit    , x20  y50  w330 h20  vvRep
   Gui 97: Add, Text    , x20  y75  w155 h20                 , Rang source
   Gui 97: Add, Edit    , x20  y95  w155 h20  vvRgS
   Gui 97: Add, Text    , x195 y75  w155 h20                 , Rang destination
   Gui 97: Add, Edit    , x195 y95  w155 h20  vvRgD
   Gui 97: Add, Text    , x20  y120 w155 h20                 , Nombre d'itération
   Gui 97: Add, Edit    , x20  y140 w155 h20  vvIte
   Gui 97: Add, GroupBox, x10  y175 w350 h100                , Types source
   Gui 97: Add, Radio   , x20  y200 w330 h20  vvTyp   checked, 1- 2 chiffres / 00..99
   Gui 97: Add, Radio   , x20  y225 w330 h20                 , 2- 3 chiffres / 000..999
   Gui 97: Add, Radio   , x20  y250 w330 h20                 , 3- variables  / 0..9, 10..99, 100..999
   Gui 97: Add, Button  , x30  y285 w330 h20  +Center ggExe  , Exécuter
   Gui 97: Show         ,           w370 h315 +Center        , Recherche d'Images Googles (jpg)
   Gui 97: Submit, noHide
Return

;-------------------------------------------------------------------------------
   gExe:
      Gui 97: Submit
      Clipboard =
      Loop %vIte%
      {
         u := vRgS + a_Index - 1
         If  vTyp=1
            u := rig_Zero( u, 2 )
         Else If  vTyp=2
            u := rig_Zero( u, 3 )       
         v := vRgD + a_Index - 1
         w = %vRep%%u%.jpg%a_Tab%%v%`r`n
         Clipboard = %Clipboard%%w%
         v++   
      }
      Gui 97: Destroy
   Return
;-------------------------------------------------------------------------------
   97GuiClose:
      Gui 97: Destroy
   Return
;-------------------------------------------------------------------------------
}  ;< rig_Number() >

;===============================================================================
; pûr_acsédé a la paj suivät d_la re¢èr¢ d'imaj Google
;-------------------------------------------------------------------------------

rig_PageAfter()
{
   Global
   If (rigPage < 49)
   {
      rigPage++
      rig_PageX( rigQuestion, rigPage )
   }
   Return         
}  ;< rig_PageAfter() >

;===============================================================================
; pûr_acsédé a la paj présédët d_la re¢èr¢ d'imaj Google
;-------------------------------------------------------------------------------

rig_PageBefore()
{
   Global
   If (rigPage > 1)
   {
      rigPage--
      rig_PageX( rigQuestion, rigPage )
   }
   Return         
}  ;< rig_PageBefore() >

;===============================================================================
; pûr_acsédé a un paj qèlcöq d_la re¢èr¢ d'imaj Google (ë paramêtr)
;-------------------------------------------------------------------------------

rig_PageX( q, x )   
{
   Global
   Local ab, p, r, s, st, wt
   WinGetActiveTitle wt
   st := rigNip*(x-1)
   p := "http://images.google.ca/images?imgsz=m&as_st=y&hl=fr&safe=off&rlz=1T4RNWE_frCA310CA310&q="
   r := "&sa=N&start="
   s := "&ndsp=20"
   ab := p . q . r . st . s   ; ab = address bar
   ControlSetText Edit1, %ab%, %wt%
   ControlFocus Edit1, %wt%
   sleep 200
   Send {Enter}
   rigQ%rigRangQ% = %rigQuestion%%a_Tab%%rigPage%
   GuiControl 99:, vPaj, %a4%Page:  %rigPage%
   rigMod := 1
   Return
}  ;< rig_PageX() >

;===============================================================================
; pûr_acsédé a un paj qèlcöq d_la re¢èr¢ d'imaj Google (ë sèzi)
;-------------------------------------------------------------------------------

rig_PageXInput()   
{
   Global
   InputBox rigPage, Quelle page s.v.p.?,,,, 105
   rig_PageX( rigQuestion, rigPage )
   Return
} ;< rig_PageXInput() >

;===============================================================================
; miz-a-jûr dé fi¢yé "Rig.inf", "Images.rig" & "Questions.rig"
;-------------------------------------------------------------------------------

rig_Save()
{
   Global
   Local u
;[1]
   FileDelete %rig1%
   FileAppend %rigDir1%, %rig1%
   If  rigMod=0
      GoTo  aFin
;[2]
   FileDelete %rigImg%
   Loop %rigI0%
   {
      u := rigI%a_Index%
      u  = %u%`n
      FileAppend %u%, %rigImg%
   }
;[3]
   FileDelete %rigQst%
   Loop %rigQ0%
   {
      u := rigQ%a_Index%
      u  = %u%`n
      FileAppend %u%, %rigQst%
   }

aFin:
;[4]
   rig_Summary()
   rigMod = 0
   Return
}  ;< rig_Save() >

;===============================================================================

rig_SetBetween( String1, String2, String3, ByRef Text )
{
   Local a1, a2, p2, p3, r2, r3
   a1 := StrLen( Text )
   a2 := StrLen( String2 )
   p2 := InStr( Text, String2 )+a2-1
   p3 := a1-InStr( Text, String3 )+1
   StringLeft  r2, Text, p2
   StringRight r3, Text, p3
   Text := r2 . String1 . r3
   Return
}  ;< rig_SetBetween() >

;===============================================================================
; ajût_a "Rig.inf" la paj (<50) de tût lé qèstyö &
;                  le nöbre d'imaj_a télé¢arjé (>0)
;-------------------------------------------------------------------------------

rig_Summary()
{
   Global
   Local u
   Loop %rigDir0%\*, 2, 0
   {
;[1]
      Loop Read, %rigDir0%\%a_LoopFileName%\Images.rig
         u := a_Index-1
      FileAppend `n`n<%u%>%a_Tab%%a_LoopFileName%`n, %rig1%
;[2]
      Loop Read, %rigDir0%\%a_LoopFileName%\Questions.rig
      {
         If  a_Index>1
         {
            StringSplit u, a_LoopReadLine, %a_Tab%
            If  u2<50
               FileAppend %a_Tab%%a_LoopReadLine%`n, %rig1%
         }
      }
   }
   Return
}  ;< rig_Summary() >

;*****  Fonctions  *************************************************************

;===============================================================================

rig_GetAfter( String, Text )
{
   Local a, b, p, r
   a := StrLen( String )
   b := StrLen( Text )
   p := InStr( Text, String )
   StringRight r, Text, (b-a-p+1)
   Return  r
}  ;< rig_GetAfter() >

;===============================================================================

rig_GetBetween( String1, String2, Text )
{
   Local a1, a2, p1, p2
   a1 := StrLen( String1 )
   a2 := StrLen( String2 )
   p1 := InStr( Text, String1 )
   p2 := InStr( Text, String2 )
   Return SubStr( Text, a1+p1, p2-a1-p1 )
}  ;< rig_GetBetween() >

;===============================================================================
; cöplèt_o débu par dé zéro un ¢ên pûr q'èl swa de löger "n"
;-------------------------------------------------------------------------------

rig_Zero( ch, n )
{
   Local k, v
   k := StrLen(ch)
   v := ""
   k := n - k
   If k>0
      Loop %k%
         v := v . "0"
   Return v . ch
}  ;< rig_Zero() >

;*****  Fin du programme  ******************************************************

;################################################################################

;*****  Formats  ***************************************************************
;
;-------------------------------------------------------------------------------
;     File format of "Rig.inf"
;-------------------------------------------------------------------------------
;
; The first line: the last picture's directory used (= rigDir1)
;
; The string following the last "\"
; give the collection name (= rigCol)
; Ex.: Z:\123\456\abcd\efgh  -->  efgh
;
; This directory contains "Questions.rig" and "Images.rig" files;
; a summary of these files is added at the end of Rig.inf, but
; not use by the program, just for the user's overview.
;
;-------------------------------------------------------------------------------
;     File format of "Questions.rig"
;-------------------------------------------------------------------------------
;
; Line-1: rank of the last question used (= rigRangQ)
; Line-2 and subsequent =
; Line-x: question-x + Tab + page-x
;    question-x = x-th question
;        page-x = last page used for question-x
;
; If line-x is the current line:
;    rigQuestion = question-x
;        rigPage = page-x
;
;-------------------------------------------------------------------------------
;     File format of "Images.rig"
;-------------------------------------------------------------------------------
;
; Line-1: collection-rank of the next picture to add in the file (= rigRangC)
; Line-2 and subsequent =
; Line-x: adress-x + Tab + rank-x
;    adress-x = complete adress of picture-x
;      rank-x = rank of picutre-x in collection after download
;
; n.b.: the file is not cleaned automaticaly, because sometimes
;       the download is incomplete and we have to retry the operation
;
;*******************************************************************************
;
;-------------------------------------------------------------------------------
;     Format du fichier "Rig.inf"
;-------------------------------------------------------------------------------
;
; La première ligne:  l'adresse du dernier répertoire d'imajes utilisé (= rigDir1)
;
; La chaîne de caractères suivant le dernier "\"
; fourni le nom de collection (= rigCol)
; Ex.: Z:\123\456\abcd\efgh  -->  efgh
;
; Ce répertoire contient les fichiers "Questions.rig" et "Images.rig".  Un
; sommaire de ceux-ci est ajouté à la suite du fichier Rig.ing; il est
; non-utilisé par le programme, seulement pour faciliter le contrôle par
; l'utilisateur.
;
;-------------------------------------------------------------------------------
;     Format du fichier "Questions.rig"
;-------------------------------------------------------------------------------
;
; Ligne-1: rang de la dernière question utilisée (= rigRangQ)
; Ligne-2 et ultérieure =
; Ligne-x: question-x + Tab + page-x
;    question-x = x-ième question
;        page-x = dernière page consultée pour la question-x
;
; Si ligne-x est la ligne courante:
;    rigQuestion = question-x
;        rigPage = page-x
;
;-------------------------------------------------------------------------------
;     Format du fichier "Images.rig"
;-------------------------------------------------------------------------------
;
; Ligne-1: rang-collection  de la prochaine image a ajouter au fichier (= rigRangC)
; Ligne-2 et ultérieure =
; Ligne-x: adresse-x + Tab + rang-x
;    adresse-x = adresse complète de l'image-x
;       rang-x = rang que prendra l'image dans la collection une fois téléchargée
;
; n.b.: les images auraient pu être éliminées du fichier après téléchargement,
;       mais... régulièrement le téléchargement est incomplet et doit être repris;
;       le nettoyage doit donc être fait manuellement.
;
;*******************************************************************************
;
;-------------------------------------------------------------------------------
; fôrmô de l'adrès paj (page 13 pûr_ilustré):
;-------------------------------------------------------------------------------
;
;              http://images.google.ca/images
; ?hl        = fr                                      ; language
; &safe      = off                                     ; security
; &rlz       = 1T4RNWE_frCA310CA310                    ; releaze
;              ; French canadian writing
; &q         = %22m%C3%A9duse+g%C3%A9ante%22           ; question
;              ; "méduse+géante"
; &sa        = N
; &start     = 240                                     ; starting image rank
; &ndsp      = 20                                      ; number of tumbnail displayed by page
;
; start := ndsp*(paj-1)                                ; relation between values
;
;-------------------------------------------------------------------------------
; fôrmô de l'adrès_imaj:
;-------------------------------------------------------------------------------
;
;              http://images.google.ca/imgres
; ?imgurl    = http://www.berlol.net/jlr20090428.jpg   ; image url          <---                           
; &imgrefurl = http://www.berlol.net/jlr200904.htm     ; web site url       <---
; &usg       = __5B2wz6nFGqBC9kxh0uA_JWJgQVE=
; &h         = 600                                     ; height             <---     
; &w         = 450                                     ; width              <---
; &sz        = 64                                      ; file size                                         
; &hl        = fr                                      ; language
; &start     = 164                                     ; rank of the first image of the page
; &tbn id    = el6mEHx6nBY9IM:                         ; tumbnail id
; &tbn h     = 135                                     ; tumbnail height
; &tbn w     = 101                                     ; tumbnail width
; &prev      = /images
;              %3F q       %3D %2522m%25C3%25A9duse%2Bg%25C3%25A9ante%2522   ; question
;                              ; "méduse+géante"
;              %26 ndsp    %3D 20                      ; number of tumbnail displayed by page
;              %26 hl      %3D fr                      ; language
;              %26 safe    %3D off                     ; security
;              %26 rlz     %3D 1T4RNWE_frCA310CA310    ; releaze
;              %26 sa      %3D N                       ;
;              %26 start   %3D 160                     ; starting image rank
;
;-------------------------------------------------------------------------------
; le côd:
;-------------------------------------------------------------------------------
;
; 20 = {Espace}
; 22 = "
; 25 = %
; 26 = &
; 2B = +
; 2F = /
; 3A = :
; 3D = =
; 3F = ?
; A9 = é
; C3 =                    ?????????
;
;----------------------------------------------------------------------------------------------
; Illustration du format question (Illustration of format question)
;----------------------------------------------------------------------------------------------
;
; La première page affichée (First page = 1):
;
; http://images.google.ca/images?as_q=danseur+salsa&hl=fr&rlz=1T4RNWE_frCA310CA310&btnG=Recherche+Google&as_epq=&as_oq=&as_eq=&imgtype=&imgsz=m&imgw=&imgh=&imgar=&as_filetype=jpg&imgc=&as_sitesearch=&as_rights=&safe=off&as_st=y
;
; http://images.google.ca/images
; ?as_q          = danseur+salsa
; &hl            = fr
; &rlz           = 1T4RNWE_frCA310CA310
; &btnG          = Recherche+Google
; &as_epq        =
; &as_oq         =
; &as_eq         =
; &imgtype       =
; &imgsz         = m
; &imgw          =
; &imgh          =
; &imgar         =
; &as_filetype   = jpg
; &imgc          =
; &as_sitesearch =
; &as_rights     =
; &safe          = off
; &as_st         = y
;
;----------------------------------------------------------------------------------------------
;
; Les pages suivantes (Following page > 1):
;
; http://images.google.ca/images?imgsz=m&as_st=y&hl=fr&safe=off&rlz=1T4RNWE_frCA310CA310&q=danseur+salsa+filetype:jpg&sa=N&start=20&ndsp=20
;
; http://images.google.ca/images
; ?imgsz = m
; &as_st = y
; &hl    = fr
; &safe  = off
; &rlz   = 1T4RNWE_frCA310CA310
; &q     = danseur+salsa+filetype:jpg
; &sa    = N
; &start = 20
; &ndsp  = 20
;
;----------------------------------------------------------------------------------------------
;
; http://images.google.ca/images
;   ?as_q=anna-nicole+smith       ; Tous les mots            ; All words
;   &as_epq=anna-nicole+smith     ; Cette expression exacte  ; Exact expression
;   &as_oq=anna-nicole+smith      ; Au moins un mot          ; At least one word
;   &as_eq=exception              ; Sans le mot              ; Except the word
; &imgtbs=zf&hl=fr&rlz=1T4RNWE_frCA310CA310&btnG=Recherche+Google&as_epq=&as_oq=&as_eq=&imgtype=&imgsz=m&imgw=&imgh=&imgar=&as_filetype=jpg&imgc=&as_sitesearch=&as_rights=&safe=off&as_st=y
;
;----------------------------------------------------------------------------------------------
;
; http://images.google.ca/images?as_q=&imgtbs=zf&hl=fr&rlz=1T4RNWE_frCA310CA310&btnG=Recherche+Google&as_epq=anna-nicole+smith&as_oq=&as_eq=&imgtype=
; &imgsz=                         ; Toutes les tailles       ; All sizes
;       =m                        ; Moyennes                 ; Medium
;       =l                        ; Grandes                  ; Large
; &imgw=&imgh=&imgar=&as_filetype=jpg&imgc=&as_sitesearch=&as_rights=&safe=off&as_st=y
;
;----------------------------------------------------------------------------------------------
;
; http://images.google.ca/images?as_q=&imgtbs=zf&hl=fr&rlz=1T4RNWE_frCA310CA310&btnG=Recherche+Google&as_epq=anna-nicole+smith&as_oq=&as_eq=&imgtype=&imgsz=m&imgw=&imgh=&imgar=
; &as_filetype=                   ; Tous les formats         ; All formats
;             =jpg                ; Format jpg               ; jpg format
;             =bmp                ; Format bmp               ; bmp format
; &imgc=&as_sitesearch=&as_rights=&safe=off&as_st=y
;
;----------------------------------------------------------------------------------------------
;
;################################################################################


Last edited by D4Pro on January 11th, 2012, 6:42 pm, edited 2 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 6th, 2011, 4:33 pm 
Offline

Joined: August 23rd, 2004, 10:06 pm
Posts: 276
Location: East Bay, California USA
thanks! i'll give it a try later

_________________
----------------------------
Wingfool you fat! I mean, Wingfat you fool!
Line from Woody Allen's movie "What's Up Tiger Lilly?"
-----------------------------


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 6th, 2011, 4:36 pm 
Offline

Joined: August 23rd, 2004, 10:06 pm
Posts: 276
Location: East Bay, California USA
umm.. program isnt in english.. maybe my goolge trans will fix it.

_________________
----------------------------
Wingfool you fat! I mean, Wingfat you fool!
Line from Woody Allen's movie "What's Up Tiger Lilly?"
-----------------------------


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users 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