Jump to content
Sign in to follow this  
faustf

open choice and automate folder dialog is possible?

Recommended Posts

faustf

hi guy  , i  have  a  questions 

i try  to do a  robot ,  for  automate some task ,  when  click over  button , in  page  of  site  , the  site  open  filefolder ,  i must choice  a   folder  and  after some foto  and  click ok , for upload

how  could  do this  ?? i dont have  idea , some one  can  give me some  example  or  tell  me  the  command  ?

thankz  at  all

 

Share this post


Link to post
Share on other sites
faustf

i try  to use  this  code  but not  go some one  can  help me??

 

ControlClick("Choose File to Upload","","ToolbarWindow323")
WinWaitActive("#32770", "Choose File to Upload",10)
    WinFlash("Choose File to Upload","", 4, 500) ; Just to Flash the window
    ControlSetText("Choose File to Upload", "", "[CLASS:Edit; INSTANCE:1]", "C:\_DSC0075_01_bw.jpg")
    ControlClick("Choose File to Upload","","[CLASS:Edit; INSTANCE:1]")

 

Edited by faustf

Share this post


Link to post
Share on other sites
Shane0000

Does the ControlSetText work?

Is your ControlClick supposed to be targeting the edit control or some other button?

Share this post


Link to post
Share on other sites
faustf

yea  i think  yes 
work  good

but  when i try  to point  in pop up  openfolder  dont  go  :(

Share this post


Link to post
Share on other sites
Shane0000

Are you familiar with Au3Info.exe?

This tool (installed w/ full Autoit & SciTe) [AutoIt Window Info] will give you the information on the other controls.

I imagine there is a "submit" or "ok" button you should be clicking to start the upload

Share this post


Link to post
Share on other sites
faustf

little  bit  ,  i used 

before  click ok i want  give  a  path  in address  line  , and  after  insert a name of  foto and  after click ok 

i attacch my  dump  with  autoit info

Untitled.jpg

Share this post


Link to post
Share on other sites
Shane0000

Ok now use the "Finder Tool" to get the Control Info for the "OK" button and use ControlClick()
You should see something like : [CLASS:Button; INSTANCE:1]

ControlClick("Choose File to Upload","","[CLASS:Button; INSTANCE:1]")

If that does not work you can try :

ControlSend("Choose File to Upload","","[CLASS:Edit; INSTANCE:1]", @CRLF)
    
    ;OR
    
    ControlSend("Choose File to Upload","","[CLASS:Edit; INSTANCE:1]", "{ENTER}")

 

Share this post


Link to post
Share on other sites
Shane0000

If the attached image is the window you are automating then "Choose File to Upload" is not the window title and would not work correctly.

 

The window title is "File Upload" as show in the Autoit Window info tool.

 

Add some testing in your script to see what errors you are getting: (put this below each line)

If @error Then consolewrite(@ScriptLineNumber & " : Error" & @error & " Extended: " & @extended & @CRLF)

This will give you an error # you can look up in the help file

Share this post


Link to post
Share on other sites
faustf

i write  in this  mode  and  dont  go and  dont  have  log  in console

;WinWaitActive("#32770", "Choose File to Upload", 10)
    ;WinFlash("Choose File to Upload", "", 4, 500) ; Just to Flash the window
    ;ControlSetText("Choose File to Upload", "", "[CLASS:Edit; INSTANCE:1]", "C:\_DSC0075_01_bw.jpg")
    ;ControlClick("Choose File to Upload", "", "[CLASS:Edit; INSTANCE:1]")
    ControlSend("Choose File to Upload","","[CLASS:Edit; INSTANCE:1]", "{ENTER}")
ControlClick("Choose File to Upload","","[CLASS:Button; INSTANCE:1]")
If @error Then consolewrite(@ScriptLineNumber & " : Error" & @error & " Extended: " & @extended & @CRLF)

 

Share this post


Link to post
Share on other sites
Shane0000

One thing I can think is that you commented out your cose that sets a path in the edit box.

Perhaps pressing OK/Enter does nothing while this box is empty.

other than that, if there are no errors reported I dont know the answer.

ControlSend("Choose File to Upload","","[CLASS:Edit; INSTANCE:1]", "{ENTER}")
If @error Then consolewrite(@ScriptLineNumber & " : Error" & @error & " Extended: " & @extended & @CRLF)
ControlClick("Choose File to Upload","","[CLASS:Button; INSTANCE:1]")
If @error Then consolewrite(@ScriptLineNumber & " : Error" & @error & " Extended: " & @extended & @CRLF)

 

Share this post


Link to post
Share on other sites
Shane0000

you could go to the lowest point with mouseclick() since this is a static size window (controls always in same place)

Set the MouseCoordMode for the mouse to client (2) and do the same in AutoIt Windo Info Tool

Share this post


Link to post
Share on other sites
Shane0000

When all else fails, MouseClick() , see above post

Share this post


Link to post
Share on other sites
TheSpannish

maeby add some

sleep()

or  

WinWaitActive()

:P

Edited by TheSpannish

Codding its just my life!  :thumbsup: 

Share this post


Link to post
Share on other sites
faustf
Func _kijiji_popola()
    #cs
        $PREZZO = $PREZZO_letto
        $descrizione = $descrizione_letto
        ;$location_foto= "C:\Users\Stefano\Pictures\Nikon Transfer\001\"
        $location_foto = "C:\Users\e-Office\Desktop\ridotte"
        ;   $FILE_FOTO = '"_DSC0001_01.NEF" "_DSC0001_01.JPG"'
        $FILE_FOTO = '"_DSC0011.JPG"'
        _entra_kijiji_it()

        ;_IENavigate($oIE, "https://www.kijiji.it/pubblica-annuncio")
        ;_IELoadWait($oIE)
    #ce

    $oIE = _IECreate("https://www.kijiji.it/pubblica-annuncio", 0, 1, 1, 1)
    Local $oForm = _IEFormGetObjByName($oIE, "syi_create")

    ; INSERIMENTO CATEGORIA
    $oForm = _IEFormGetObjByName($oIE, "syi_create") ;<<<<<<<<<<<
    $oSelect = _IEFormElementGetObjByName($oForm, "categoria")
    _IEAction($oSelect, "focus")
    _IEAction($oSelect, "Click")

    Send("" & $categoria & ""); lancio il nome della categoria che mi serve
    Sleep(1000)

    ; INSERIMENTO IN SOTTOCATEGORIA
    $oForm = _IEFormGetObjByName($oIE, "syi_create") ;<<<<<<<<<<<
    $oSelect = _IEFormElementGetObjByName($oForm, "Sottocategoria")
    _IEFormElementOptionSelect($oSelect, $sottocategoria, 1, "byText")

    ;COMUNE
    Local $Form_comune = _IEFormElementGetObjByName($oForm, "26c94607a042f60ae63ffe67170682524a22bd4adf97b0d3a3ea98362fbc180e")
    _IEFormElementSetValue($Form_comune, $comune)
    ;INDIRIZZO
    Local $Form_indirizzo = _IEFormElementGetObjByName($oForm, "4a56322312e85ae059450f33a1e4d85af8839689f8ab5e26fdb55ddff8b99f30")
    _IEFormElementSetValue($Form_indirizzo, "via dei mille");$aItem[7])
    ;TITOLO OGGETTO
    Local $Form_titolo = _IEFormElementGetObjByName($oForm, "2dd9d2670294523b13864726beba16b04fbbb39c0e48b0d480e2ffe357393f75")
    _IEFormElementSetValue($Form_titolo, $Titolo)
    ;PREZZO
    Local $Form_titolo = _IEFormElementGetObjByName($oForm, "935f7bceac69d8eff44d9e6a2b5335e8fa1c44c9d1a2555386807e694b6d7442")
    _IEFormElementSetValue($Form_titolo, $PREZZO_letto)
    ;DESCRIZIONE
    Local $Form_titolo = _IEFormElementGetObjByName($oForm, "3e1fa0d752a4ed6c4ab395eda30ba184dad89d6258f24fe1a9e4ea45509bdc81")
    _IEFormElementSetValue($Form_titolo, $descrizione_letto)
    ;EMAIL OBBLIGO
    Local $Form_titolo = _IEFormElementGetObjByName($oForm, "1d743d7d69c04b952978431c6aff8385f9f5f1d8e1b68691a7728351ef5a6515")
    _IEFormElementSetValue($Form_titolo, $mail)

    ;NOME FACOLTATIVO
    Local $Form_titolo = _IEFormElementGetObjByName($oForm, "c27cfe08513d577b9349cc013cec597e7bbc33d3d71ceea03c52e7b2dc19c520")
    _IEFormElementSetValue($Form_titolo, "demetrio volcic");$aItem[2])

    If $hide_numebr = '1' Then
        ;TELEFONO FACOLTATIVO
        Local $Form_titolo = _IEFormElementGetObjByName($oForm, "6092aa107408126873cd765d762fac2f525b46cf2a67fe048665d8e0f8632f2c")
        _IEFormElementSetValue($Form_titolo, $numero_hide)
    EndIf

    ; OFFRO CERCO
    Local $Form_titolo = _IEFormElementGetObjByName($oForm, "d9b024bd35b68d610baa726a1cb4a9de11d93cce580777b7fd7282a2f0ad43aa")
    _IEAction($Form_titolo, "focus")
    ;_IEFormElementSetValue($Form_titolo,
    _IEFormElementRadioSelect($Form_titolo, "2", "d9b024bd35b68d610baa726a1cb4a9de11d93cce580777b7fd7282a2f0ad43aa", 1, "byValue")

    #cs
        Local $sHTML = _IEBodyReadHTML($oIE)
        Local $oBtns = _IELinkGetCollection($oIE)
        local   $par_control = 1
        For $oBtn In $oBtns
        $classname = String($oBtn.classname())
        If $classname = "qq-upload-button btn" Then
        If $par_control = 2 Then
        _IEAction($oBtn, "Focus")
        $B = _IEAction($oBtn, "Click")
        _IELoadWait($oIE)
        Sleep(5000)
        EndIf
        $par_control += 1
        EndIf
        Next
        Local $oChk = _IEGetObjById($oIE, "file")
        _IEAction($oChk, "click")
    #ce
    ; APERTURA IMMAGINI UPLOAD
    Local $oForm = _IEFormGetObjByName($oIE, "syi_create")
    Local $oQuery = _IEFormElementGetObjByName($oForm, "file")
    _IEAction($oQuery, "focus")
    _IEAction($oQuery, "Click")

    ;WinWaitActive("#32770", "Choose File to Upload", 10)
    ;WinFlash("Choose File to Upload", "", 4, 500) ; Just to Flash the window
    ;ControlSetText("Choose File to Upload", "", "[CLASS:Edit; INSTANCE:1]", "C:\_DSC0075_01_bw.jpg")
    ;ControlClick("Choose File to Upload", "", "[CLASS:Edit; INSTANCE:1]")
    ControlSend("Choose File to Upload","","[CLASS:Edit; INSTANCE:1]", "{ENTER}")
If @error Then consolewrite(@ScriptLineNumber & " : Error" & @error & " Extended: " & @extended & @CRLF)
ControlClick("Choose File to Upload","","[CLASS:Button; INSTANCE:1]")
If @error Then consolewrite(@ScriptLineNumber & " : Error" & @error & " Extended: " & @extended & @CRLF)
EndFunc   ;==>_kijiji_popola

 

Share this post


Link to post
Share on other sites
Rockerfeller
"C:\Users\Public\Auto\delete.au3"(24,23) : warning: $categoria: possibly used before declaration.
    Send("" & $categoria &
    ~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\Public\Auto\delete.au3"(30,54) : warning: $sottocategoria: possibly used before declaration.
    _IEFormElementOptionSelect($oSelect, $sottocategoria,
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\Public\Auto\delete.au3"(34,46) : warning: $comune: possibly used before declaration.
    _IEFormElementSetValue($Form_comune, $comune)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\Public\Auto\delete.au3"(40,46) : warning: $Titolo: possibly used before declaration.
    _IEFormElementSetValue($Form_titolo, $Titolo)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\Public\Auto\delete.au3"(43,52) : warning: $PREZZO_letto: possibly used before declaration.
    _IEFormElementSetValue($Form_titolo, $PREZZO_letto)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\Public\Auto\delete.au3"(46,57) : warning: $descrizione_letto: possibly used before declaration.
    _IEFormElementSetValue($Form_titolo, $descrizione_letto)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\Public\Auto\delete.au3"(49,44) : warning: $mail: possibly used before declaration.
    _IEFormElementSetValue($Form_titolo, $mail)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\Public\Auto\delete.au3"(55,18) : warning: $hide_numebr: possibly used before declaration.
    If $hide_numebr =
    ~~~~~~~~~~~~~~~~^
"C:\Users\Public\Auto\delete.au3"(58,52) : warning: $numero_hide: possibly used before declaration.
        _IEFormElementSetValue($Form_titolo, $numero_hide)
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\Public\Auto\delete.au3"(24,23) : error: $categoria: undeclared global variable.
    Send("" & $categoria &
    ~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\Public\Auto\delete.au3"(30,54) : error: $sottocategoria: undeclared global variable.
    _IEFormElementOptionSelect($oSelect, $sottocategoria,
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\Public\Auto\delete.au3"(34,46) : error: $comune: undeclared global variable.
    _IEFormElementSetValue($Form_comune, $comune)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\Public\Auto\delete.au3"(40,46) : error: $Titolo: undeclared global variable.
    _IEFormElementSetValue($Form_titolo, $Titolo)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\Public\Auto\delete.au3"(43,52) : error: $PREZZO_letto: undeclared global variable.
    _IEFormElementSetValue($Form_titolo, $PREZZO_letto)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\Public\Auto\delete.au3"(46,57) : error: $descrizione_letto: undeclared global variable.
    _IEFormElementSetValue($Form_titolo, $descrizione_letto)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\Public\Auto\delete.au3"(49,44) : error: $mail: undeclared global variable.
    _IEFormElementSetValue($Form_titolo, $mail)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\Public\Auto\delete.au3"(55,18) : error: $hide_numebr: undeclared global variable.
    If $hide_numebr =
    ~~~~~~~~~~~~~~~~^
"C:\Users\Public\Auto\delete.au3"(58,52) : error: $numero_hide: undeclared global variable.
        _IEFormElementSetValue($Form_titolo, $numero_hide)
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\Public\Auto\delete.au3"(15,72) : error: _IECreate(): undefined function.
    $oIE = _IECreate("https://www.kijiji.it/pubblica-annuncio", 0, 1, 1, 1)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\Public\Auto\delete.au3"(16,55) : error: _IEFormGetObjByName(): undefined function.
    Local $oForm = _IEFormGetObjByName($oIE, "syi_create")
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\Public\Auto\delete.au3"(20,59) : error: _IEFormElementGetObjByName(): undefined function.
    $oSelect = _IEFormElementGetObjByName($oForm, "categoria")
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\Public\Auto\delete.au3"(21,29) : error: _IEAction(): undefined function.
    _IEAction($oSelect, "focus")
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\Public\Auto\delete.au3"(30,67) : error: _IEFormElementOptionSelect(): undefined function.
    _IEFormElementOptionSelect($oSelect, $sottocategoria, 1, "byText")
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\Public\Auto\delete.au3"(34,46) : error: _IEFormElementSetValue(): undefined function.
    _IEFormElementSetValue($Form_comune, $comune)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\Public\Auto\delete.au3"(65,127) : error: _IEFormElementRadioSelect(): undefined function.
    _IEFormElementRadioSelect($Form_titolo, "2", "d9b024bd35b68d610baa726a1cb4a9de11d93cce580777b7fd7282a2f0ad43aa", 1, "byValue")
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×