faustf

Automate openfile dialog problem

10 posts in this topic

#1 ·  Posted

hi guys

i have pageweb , it , have a button for upload image , i click them and it open a dialog  file , i  analize them with , Autoit v3  info

>>>> Window <<<<
Title:  Choose File to Upload
Class:  #32770
Position:   115, 42
Size:   960, 489
Style:  0x96CC02C4
ExStyle:    0x00010101
Handle: 0x00221CFE

>>>> Control <<<<
Class:  
Instance:   
ClassnameNN:    
Name:   
Advanced (Class):   
ID: 
Text:   
Position:   
Size:   
ControlClick Coords:    
Style:  
ExStyle:    
Handle: 

>>>> Mouse <<<<
Position:   189, 500
Cursor ID:  0
Color:  0xD4D0C8

>>>> StatusBar <<<<

>>>> ToolsBar <<<<

>>>> Visible Text <<<<
Namespace Tree Control
Tree View
ShellView
File &name:
Files of &type:
All Files (*.*)
&Open
Cancel
Address: Libraries\Documents


>>>> Hidden Text <<<<
Namespace Tree Control
Shell Preview Extension Host
&Help

i write a code  like this

    If WinActive("[CLASS:#32770]") Then
        MsgBox(0,'','image is open ')
        EndIf

but not work , how is possible if i call a class correct???

thankz at all

 

Share this post


Link to post
Share on other sites



#2 ·  Posted

Does it work if you use the title instead of the class? Is the window actually active? Once again, you throw stuff out there without stating what you have done to troubleshoot the issue.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

sorry , yes  the windows is  active , and i just  tryed to use title  but , not have much expirience about use it

for test  title  i used  this  to  command

If WinActive("[Title:Choose File to Upload]") Then

and dont go

If WinActive("Choose File to Upload") Then

and dont go

also this but nothing

    If WinActive("[CLASS:Choose File to Upload]") Then

 

Edited by faustf

Share this post


Link to post
Share on other sites

#4 ·  Posted

1 hour ago, faustf said:

button for upload image

 

Share this post


Link to post
Share on other sites

#5 ·  Posted

i saw  but , i  dont understund so much , i , if you want test my all script

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.14.2
 Author:         faustf

 Script Function:
    Template AutoIt script.

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here



#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>
#include <File.au3>
#include <IE.au3>
#include <Array.au3>

Global $ISP_WEB = 0

_StartShpock()

Func _StartShpock()

    If ProcessExists("iexplore.exe") Then ; Check if the internet esplorer process is running.
        ProcessClose("iexplore.exe")
    EndIf
    #cs
        Local $oIE = _IECreate ("https://it.shpock.com/my/signup/")

        Local $oForm = _IEFormGetCollection($oIE, 0)
        Local $username = _IEFormElementGetCollection ($oForm, 1)
        Local $password = _IEFormElementGetCollection ($oForm, 2)

        _IEFormElementSetValue ($username, "USER")
        _IEFormElementSetValue ($password, "PASS")

        _IEFormSubmit($oForm)
    #ce
    ;#cs
    Global $oIE = _IECreate("https://it.shpock.com/my/signup/", 0, 1, 1, 1) ; <--- 0011 invisible explorer  <--- 0111 visible explorer
    _IELoadWait($oIE)
    Local $oBtns = $oIE.document.GetElementsByTagName("input")
    For $oBtn In $oBtns
        $classname = String($oBtn.classname())
        $placehold = String($oBtn.placeholder())
        ;ConsoleWrite($classname & @CRLF)
        If $classname = "password" Then
            _IEAction($oBtn, "click")
            _IEFormElementSetValue($oBtn, "kronos123")
        EndIf
        If $placehold = "Indirizzo email" Then
            _IEAction($oBtn, "click")
            _IEFormElementSetValue($oBtn, "stfn77@gmail.com")
        EndIf
        If $placehold = "login" Then
            _IEAction($oBtn, "click")
        EndIf
    Next
    ;   #ce

    ; clic botton login
    Local $oBtns = $oIE.document.GetElementsByTagName("input")
    For $oBtn In $oBtns
        $classname = String($oBtn.value())
        ;ConsoleWrite($classname & @CRLF)
        If $classname = "Login" Then
            _IEAction($oBtn, "click")
        EndIf
    Next

    _IENavigate($oIE, "https://it.shpock.com/my/sell/") ; vendi

    Local $oLprice = _IEGetObjByName($oIE, "price")
    _IEAction($oLprice, "focus")
    _IEAction($oLprice, "Click")
    _IEFormElementSetValue($oLprice, "12") ; prezzo prodotto

    Local $oLprice = _IEGetObjByName($oIE, "location")
    _IEAction($oLprice, "focus")
    _IEAction($oLprice, "Click")
    _IEFormElementSetValue($oLprice, "via curtatone e montanare 19") ; indirizzo e civico

    Local $oBtns = $oIE.document.GetElementsByTagName("")
    For $oBtn In $oBtns
        $classname = String($oBtn.class())
        ;ConsoleWrite($classname & @CRLF)
        If $classname = "opener category" Then
            _IEAction($oBtn, "click")
        EndIf
    Next

    ;seleziona categoria
    Local $oBtns = _IELinkGetCollection($oIE)
    For $oBtn In $oBtns
        $classname = String($oBtn.classname())
        ;ConsoleWrite($classname & @CRLF)
        If $classname = "opener category" Then
            ;ConsoleWrite("Found it" & @CRLF)
            _IEAction($oBtn, "click")
        EndIf
    Next
    Sleep(2000)
    Local $oBtns = $oIE.document.GetElementsByTagName("span")
    Local $iLPushLimit = 0
    For $oBtn In $oBtns
        $classname = String($oBtn.classname())
        ;ConsoleWrite($classname & @CRLF)
        If $classname = "cat fa" Then
            If $iLPushLimit = 2 Then
                _IEAction($oBtn, "click")
            EndIf
            $iLPushLimit += 1
        EndIf
    Next

    ; descrizione

    Local $oBtns = $oIE.document.GetElementsByTagName("textarea")
    For $oBtn In $oBtns
        $classname = String($oBtn.name())
        ;ConsoleWrite($classname & @CRLF)
        If $classname = "description" Then
            _IEAction($oBtn, "click")
            _IEFormElementSetValue($oBtn, "descrizione massimo 500 caratteri") ; descrizione massimo 500 caratteri
        EndIf
    Next

    ; titolo inserzione

    Local $oLprice = _IEGetObjByName($oIE, "title")
    _IEAction($oLprice, "focus")
    _IEAction($oLprice, "Click")
    _IEFormElementSetValue($oLprice, "Bikini mare donna") ;  titolo inserzione

    ;foto load

    Local $oLprice = _IEGetObjByName($oIE, "media")
    _IEAction($oLprice, "focus")
    _IEAction($oLprice, "Click")
    Sleep (1000)
  ControlClick("[CLASS:#32770]", "Choose File to Upload", "[CLASS:ToolbarWindow32; INSTANCE:2]")

    If WinActive("[CLASS:Choose File to Upload]") Then
        MsgBox(0,'','è aperto l upload immagini ')
        EndIf





    #cs
        Local $oBtns = $oIE.document.GetElementsByTagName("input")
        For $oBtn In $oBtns
        $classname = String($oBtn.placeholder())
        ConsoleWrite($classname & @CRLF)
        If $classname = "Indirizzo email" Then
        ;MsgBox(0, 'menubar', $classname)
        ConsoleWrite("Found it" & @CRLF)
        MsgBox(0, 'de', $oBtn)
        _IEAction ($oBtn, "click")
        _IEFormElementSetValue($oBtn, "passeraword")
        ;$cliccata += 1
        ;MsgBox (0,'','estrae quello che deve estrarre')
        ;_IENavigate ($oIE,$get_url)
        EndIf
        Next
    #ce
    #cs
        $oCorrectObj = ""

        $tags = $oIE.document.GetElementsByTagName("div")
        For $tag in $tags
        $class_value = $tag.GetAttribute("class")
        If string($class_value) = "password" Then
        $oCorrectObj = $tag

        MsgBox(0, "Level: ", "Level found :)")
        ExitLoop

        EndIf
        Next

        If IsObj ( $oCorrectObj ) Then

        _IEAction ($oCorrectObj, "click")


        EndIF
    #ce
EndFunc   ;==>_StartShpock


Func _IEGetObjByClass(ByRef $o_object, $s_Class, $i_index = 0)
    If Not IsObj($o_object) Then
        __IEConsoleWriteError("Error", "_IEGetObjByClass", "$_IEStatus_InvalidDataType")
        SetError($_IEStatus_InvalidDataType, 1)
        Return 0
    EndIf
    ;
    If Not __IEIsObjType($o_object, "browserdom") Then
        __IEConsoleWriteError("Error", "_IEGetObjByClass", "$_IEStatus_InvalidObjectType")
        SetError($_IEStatus_InvalidObjectType, 1)
        Return 0
    EndIf
    ;
    Local $i_found = 0
    ;
    $o_tags = _IETagNameAllGetCollection($o_object)
    For $o_tag In $o_tags
        If String($o_tag.className) = $s_Class Then
            If ($i_found = $i_index) Then
                SetError($_IEStatus_Success)
                Return $o_tag
            Else
                $i_found += 1
            EndIf
        EndIf
    Next
    ;
    __IEConsoleWriteError("Warning", "_IEGetObjByClass", "$_IEStatus_NoMatch", $s_Class)
    SetError($_IEStatus_NoMatch, 2)
    Return 0
EndFunc   ;==>_IEGetObjByClass

 

Share this post


Link to post
Share on other sites

#6 ·  Posted

you can find Answer in my signature.


Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2017-06-04

Share this post


Link to post
Share on other sites

#7 ·  Posted

where ???

Share this post


Link to post
Share on other sites

#8 ·  Posted

@mlipok  but where  i find a solution ??' sginature?? what is this??? 

i dont understund a sense

Share this post


Link to post
Share on other sites

#9 ·  Posted

I think your case is exactly the same as here:

 Why isn't Autoit able to click a Javascript Dialog? 


Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2017-06-04

Share this post


Link to post
Share on other sites

#10 ·  Posted

i trye to use , this  but not  work , i use windows 10 , soon test the script in windows 7  and   tell you 

this is a script total 

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.14.2
 Author:         faustf

 Script Function:
    Template AutoIt script.

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here



#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>
#include <File.au3>
#include <IE.au3>
#include <Array.au3>

Global $ISP_WEB = 0

_StartShpock()

Func _StartShpock()

    If ProcessExists("iexplore.exe") Then ; Check if the internet esplorer process is running.
        ProcessClose("iexplore.exe")
    EndIf
    #cs
        Local $oIE = _IECreate ("https://it.shpock.com/my/signup/")

        Local $oForm = _IEFormGetCollection($oIE, 0)
        Local $username = _IEFormElementGetCollection ($oForm, 1)
        Local $password = _IEFormElementGetCollection ($oForm, 2)

        _IEFormElementSetValue ($username, "USER")
        _IEFormElementSetValue ($password, "PASSW")

        _IEFormSubmit($oForm)
    #ce
    ;#cs
    Global $oIE = _IECreate("https://it.shpock.com/my/signup/", 0, 1, 1, 1) ; <--- 0011 invisible explorer  <--- 0111 visible explorer
    _IELoadWait($oIE)
    Local $oBtns = $oIE.document.GetElementsByTagName("input")
    For $oBtn In $oBtns
        $classname = String($oBtn.classname())
        $placehold = String($oBtn.placeholder())
        ;ConsoleWrite($classname & @CRLF)
        If $classname = "password" Then
            _IEAction($oBtn, "click")
            _IEFormElementSetValue($oBtn, "PASSW")
        EndIf
        If $placehold = "Indirizzo email" Then
            _IEAction($oBtn, "click")
            _IEFormElementSetValue($oBtn, "USER")
        EndIf
        If $placehold = "login" Then
            _IEAction($oBtn, "click")
        EndIf
    Next
    ;   #ce

    ; clic botton login
    Local $oBtns = $oIE.document.GetElementsByTagName("input")
    For $oBtn In $oBtns
        $classname = String($oBtn.value())
        ;ConsoleWrite($classname & @CRLF)
        If $classname = "Login" Then
            _IEAction($oBtn, "click")
        EndIf
    Next

    _IENavigate($oIE, "https://it.shpock.com/my/sell/") ; vendi

    Local $oLprice = _IEGetObjByName($oIE, "price")
    _IEAction($oLprice, "focus")
    _IEAction($oLprice, "Click")
    _IEFormElementSetValue($oLprice, "12") ; prezzo prodotto

    Local $oLprice = _IEGetObjByName($oIE, "location")
    _IEAction($oLprice, "focus")
    _IEAction($oLprice, "Click")
    _IEFormElementSetValue($oLprice, "via curtatone e montanare 19") ; indirizzo e civico

    Local $oBtns = $oIE.document.GetElementsByTagName("")
    For $oBtn In $oBtns
        $classname = String($oBtn.class())
        ;ConsoleWrite($classname & @CRLF)
        If $classname = "opener category" Then
            _IEAction($oBtn, "click")
        EndIf
    Next

    ;seleziona categoria
    Local $oBtns = _IELinkGetCollection($oIE)
    For $oBtn In $oBtns
        $classname = String($oBtn.classname())
        ;ConsoleWrite($classname & @CRLF)
        If $classname = "opener category" Then
            ;ConsoleWrite("Found it" & @CRLF)
            _IEAction($oBtn, "click")
        EndIf
    Next
    Sleep(2000)
    Local $oBtns = $oIE.document.GetElementsByTagName("span")
    Local $iLPushLimit = 0
    For $oBtn In $oBtns
        $classname = String($oBtn.classname())
        ;ConsoleWrite($classname & @CRLF)
        If $classname = "cat fa" Then
            If $iLPushLimit = 2 Then
                _IEAction($oBtn, "click")
            EndIf
            $iLPushLimit += 1
        EndIf
    Next

    ; descrizione

    Local $oBtns = $oIE.document.GetElementsByTagName("textarea")
    For $oBtn In $oBtns
        $classname = String($oBtn.name())
        ;ConsoleWrite($classname & @CRLF)
        If $classname = "description" Then
            _IEAction($oBtn, "click")
            _IEFormElementSetValue($oBtn, "descrizione massimo 500 caratteri") ; descrizione massimo 500 caratteri
        EndIf
    Next

    ; titolo inserzione

    Local $oLprice = _IEGetObjByName($oIE, "title")
    _IEAction($oLprice, "focus")
    _IEAction($oLprice, "Click")
    _IEFormElementSetValue($oLprice, "Bikini mare donna") ;  titolo inserzione

    ;foto load

    Local $oLprice = _IEGetObjByName($oIE, "media")
    _IEAction($oLprice, "focus")
    _IEAction($oLprice, "Click")
    #cs
    Sleep (1000)
  ControlClick("[CLASS:#32770]", "Choose File to Upload", "[CLASS:ToolbarWindow32; INSTANCE:2]")

    If WinActive("[CLASS:Choose File to Upload]") Then
        MsgBox(0,'','è aperto l upload immagini ')
        EndIf
#ce

$oForm=_IEFormGetObjByName($oIE, "uploadfile")
$oInputFile=_IEFormElementGetObjByName($oForm, "photo_upload")
_IEAction($oInputFile, "click")
Sleep(2000)

_ExecuteInBackground()

    #cs
        Local $oBtns = $oIE.document.GetElementsByTagName("input")
        For $oBtn In $oBtns
        $classname = String($oBtn.placeholder())
        ConsoleWrite($classname & @CRLF)
        If $classname = "Indirizzo email" Then
        ;MsgBox(0, 'menubar', $classname)
        ConsoleWrite("Found it" & @CRLF)
        MsgBox(0, 'de', $oBtn)
        _IEAction ($oBtn, "click")
        _IEFormElementSetValue($oBtn, "passeraword")
        ;$cliccata += 1
        ;MsgBox (0,'','estrae quello che deve estrarre')
        ;_IENavigate ($oIE,$get_url)
        EndIf
        Next
    #ce
    #cs
        $oCorrectObj = ""

        $tags = $oIE.document.GetElementsByTagName("div")
        For $tag in $tags
        $class_value = $tag.GetAttribute("class")
        If string($class_value) = "password" Then
        $oCorrectObj = $tag

        MsgBox(0, "Level: ", "Level found :)")
        ExitLoop

        EndIf
        Next

        If IsObj ( $oCorrectObj ) Then

        _IEAction ($oCorrectObj, "click")


        EndIF
    #ce
EndFunc   ;==>_StartShpock


Func _IEGetObjByClass(ByRef $o_object, $s_Class, $i_index = 0)
    If Not IsObj($o_object) Then
        __IEConsoleWriteError("Error", "_IEGetObjByClass", "$_IEStatus_InvalidDataType")
        SetError($_IEStatus_InvalidDataType, 1)
        Return 0
    EndIf
    ;
    If Not __IEIsObjType($o_object, "browserdom") Then
        __IEConsoleWriteError("Error", "_IEGetObjByClass", "$_IEStatus_InvalidObjectType")
        SetError($_IEStatus_InvalidObjectType, 1)
        Return 0
    EndIf
    ;
    Local $i_found = 0
    ;
    $o_tags = _IETagNameAllGetCollection($o_object)
    For $o_tag In $o_tags
        If String($o_tag.className) = $s_Class Then
            If ($i_found = $i_index) Then
                SetError($_IEStatus_Success)
                Return $o_tag
            Else
                $i_found += 1
            EndIf
        EndIf
    Next
    ;
    __IEConsoleWriteError("Warning", "_IEGetObjByClass", "$_IEStatus_NoMatch", $s_Class)
    SetError($_IEStatus_NoMatch, 2)
    Return 0
EndFunc   ;==>_IEGetObjByClass

Func _ExecuteInBackground()
    Local $sCommand = _
            'Local ' & _
            '$Dummy1 = WinWaitActive("[CLASS:#32770]", "Selezionare il file da caricare"), ' & _
            '$Dummy2 = Sleep(1000), ' & _
            '$Dummy3 = ControlClick("[CLASS:#32770]", "Selezionare il file da caricare", "[CLASS:Edit; INSTANCE:1]") ' & _
            ''

    $sCommand = '"' & StringReplace($sCommand, '"', '""') & '"'
    ConsoleWrite($sCommand & @CRLF)
    Run(@AutoItExe & ' /AutoIt3ExecuteLine ' & $sCommand)
EndFunc   ;==>_ExecuteInBackground

 

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