Jump to content

[SOLVED] How to automate an opened File Explorer?

Recommended Posts

I want wanting to run multiple tests on my company website. Sadly the process I want to automate requires opening a File Explorer to add an attachment. Is there a way in to automate a Chrome opened File Explorer?

(I am using webdriver to automate the other 99% of the process just fine. But when I have it click on attach file and chrome opens a file explorer I do not know how to handle it.) 

Any help would be greatly appreciated. 

Edited by nooneclose

Share this post

Link to post
Share on other sites

It is a simple #32770 class window.  Use Win* functions and Control* functions to automate it.  If you need more help, provide a runable snippet of a web site with attachment.

Share this post

Link to post
Share on other sites

@Nine Do I need to send an enter? after sending a path or file name? Or should this work?

If WinActive("[CLASS:DirectUIHWND1]") Then ; Check if File Explorer is currently active.
    ConsoleWrite("WinActive" & @CRLF & "File Explorer is active.")

    ; Send File Path
    ControlSend("[CLASS:ToolbarWindow32]", "", "ToolbarWindow323", $PoAttachPath)

    ; Send File Name
    ControlSend("[CLASS:Edit]", "", "Edit1", $rdArray[$i][7])

    ; Click 'OPEN'
    ControlClick("[CLASS:Button]", "", "Button1")



Share this post

Link to post
Share on other sites

I don't have Chrome on Win10, but this is working fine with Edge :

Local $PoAttachPath = @ScriptDir
Local $sFileName = "Temp1.au3"

If WinExists("[CLASS:#32770]") Then  ; Check if File Explorer exists
  Local $hWnd = WinActivate("[CLASS:#32770]")
  ConsoleWrite($hWnd & " / File Explorer is NOW active." & @CRLF)

  ; Send File Name
  ConsoleWrite(ControlSetText($hWnd, "", "Edit1", $PoAttachPath & "\" & $sFileName) & @CRLF)

  ; Click 'OPEN'
  ControlClick($hWnd, "", "Button1")



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

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By DJ143
      I have a autoit exe file which is used in upload/browse file functionality.  This has been integrated with selenium framework and I am invoking the autoit exe using Java process and runtime. 
      Now the issue is when I run the scripts and invoke the autoit exe in local it works perfectly.  But when I use selenium grid or jenkins to run the scripts in another windows server it is not working.
      Can anyone please suggest any solution for this?
    • By meety
      My au3 script program needs administrator privileges on win10 to be executed correctly, because it needs to be added to the boot---Script code:RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", @ScriptName, "REG_SZ", @ScriptFullPath)
      I need to let the program automatically get administrator privileges, so I use a function of #RequireAdmin. Although the program can be added to the boot, but does not execute after system boot up? why is that?
      What should I do?
      I found that after using the #RequireAdmin function, the program cannot be executed after system boot up.
      An example is given below. after it is compiled, it will not be executed after system boot up in the following two ways.
      1. C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp\
      2. RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", @ScriptName, "REG_SZ", @ScriptFullPath)
      why is that?
      #include <MsgBoxConstants.au3>
      Func test()
          MsgBox(0, "", "this is test message")
      EndFunc   ;==>test
    • By meety
      Hello everyone
      I found some problems when using au3info to get the visible text: as shown in the attachment.
      Why is that? What do I need to do to get the visible text content?
    • By PeterVerbeek
      This topic give you access to an AutoIt functions library I maintain which is called PAL, Peter's AutoIt Library. The latest version 1.25 contains 212 functions divided into these topics:
      window, desktop and monitor GUI, mouse and color GUI controls including graphical buttons (jpg, png) logics and mathematics include constants string, xml string and file string dialogues and progress bars data lists: lists, stacks, shift registers and key maps (a.ka. dictionaries) miscellaneous: logging/debugging, process and system info Change log and files section  on the PAL website (SourceForge).
      A lot of these functions were created in the development of Peace, Peter's Equalizer APO Configuration Extension, which is a user interface for the system-wide audio driver called Equalizer APO.
    • By goku200
      I'm having some issues with my script that's not grabbing the id from the cell and appending it to the url test that I have in my script.
      Here is my script:
      #Include "wd_core.au3" #Include "wd_helper.au3" #Include "wd_core.au3" #Include "File.au3" #Include "Array.au3" #Include "Excel.au3" #Include "INet.au3" Local $sDesiredCapabilities, $sSession _WD_Startup() $Ssession = _WD_CreateSession($sDesiredCapabilities) _WD_Navigate($sSession, "");session is created. When tabed on browser it will populate url _WD_LoadWait($sSession) $someUser = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@name='username']") _WD_SetElementValue($sSession, $someUser, "test") $somePassword = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@name='password']") _WD_SetElementValue($sSession, $somePassword, "test") Local $aVar[1] _ArrayAdd ($aVar,_WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@type='submit'][@value='Sign in']")) _WD_ElementAction($sSession, $aVar[1], 'click') _WD_LoadWait($sSession) Local $oExcel = _Excel_Open() Local $oWorkbook = _Excel_BookOpen($oExcel, "C:\Users\<Username>\Downloads\test.xlsx") Local $aArray1 = _Excel_RangeRead($oExcel, 1) _ArrayDisplay($aArray1, "Vertical") For $i = 0 To UBound($aArray) - 1 WinActivate("[Class:Chrome]") $testLink = "" _WD_Navigate($sSession, $testLink) $aArray1 = ClipGet() _WD_NewTab($Ssession, clipPut($testLink), True) Send("{ENTER}") Local $test = InetGet($testLink + $aArray1, "C:\Users\<username>\Downloads\Test" & ".html") Send ("!s");save webpage as html Next Func SetupChrome() _WD_Option('Driver', 'chromedriver.exe') _WD_Option('Port', 9515) _WD_Option('DriverParams', '--log-path="' & @ScriptDir & '\chrome.log"') $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["start-maximized","disable-infobars"]}}}}' EndFunc ;==>SetupChrome What I'm having issues is looping through the id column in the excel spreadsheet and adding 1 to the url address when its tabbed by using _WD_NewTab. When it goes to the browser I'm wanting it to display: press Enter and save the file as 1.html and so forth for the others. Not sure what I'm doing wrong here. 
  • Create New...