Jump to content
nooneclose

[SOLVED] How to automate an opened File Explorer?

Recommended Posts

Posted (edited)

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
solved

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.")
    Sleep(500)

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

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

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

EndIf

 

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)
  Sleep(500)

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

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

EndIf

 

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 Langmeister
      I am once again asking for your experienced assistance. If I open a website that uses notifications I am asked to allow or block them for that website after a few seconds. This notification pops up every time the page gets navigated to, even tho you have clicked on allow for several times. I am explicitly not searching for smth to get rid of "Chrome is being controlled by automated test sw". Instead I am searching for a line of script to disable all notifications by default: like here chrome://settings/content/notifications. 
      This is code should give you an example of what notifications I am talking about:
      #include "wd_core.au3" #include "wd_helper.au3" Local $sDesiredCapabilities, $sSession, $sID _WD_Option("Driver", "C:\Program Files (x86)\AutoIt3\chromedriver.exe") _WD_Option('Port', 9515) _WD_Option('DriverParams', '--log-path="' & @ScriptDir & '\chrome.log"') $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true }}}}' _WD_Startup() $sSession = _WD_CreateSession($sDesiredCapabilities) _WD_Navigate($sSession, "https://webradio.planetradio.de/") _WD_LoadWait($sSession)  
    • By malicioussoap
      back when I was still doing autohotkey you could write (in code) spanisha::á
      and whenever you were in google docs or notepad you could type (in the document) spanisha  and it instantly turns it into á 
      I tried doing this in autoit, here's what I have so far (my entire code so if this language requires a main function or a return/exit to function properly please let me know):
      ;is this a proper comment? HotKeySet ( "spanisha" , "SendAltered" ) Func SendAltered() Send("á", flag = 0); EndFunc I assume that autoit follows a sort of contemporary hotkey pressing model where you have to hold all keys at the same time? which makes this impossible. So
      I'm wondering if anyone has a workaround for this? or maybe an alternative to HotKeySet()
      I have a vague memory of someone saying that doing something like spanisha:á would work. I don't know if I'm slightly off syntax but this doesn't work.
      Also I tried doing 
      ;is this a proper comment? ;HotKeySet ( "a" , "SendAltered" ) ;spanisha::á Func SendAltered() Send("á"); EndFunc just to try and debug,
      I'm also wondering if my approach is fundamentally wrong since HotKeySet() was made for something like !^A. Or if Send() is syntactically wrong.
      I'm also noticing on these forums that specifying installation is important so to whom it may concern I downloaded both installers, editor and main files. Although I'm about to be real mad if the editor installation makes a difference.
    • By Langmeister
      Hi, I need help performing actions in Salesforce using IE. I used to complete tasks via MouseMove/MouseClick etc. on the Chrome application of SF, but unfortunately this only works for me and not my colleagues due to different positions of things etc. Being unable to get Webdriver UDF or Chromedriver running to interact with the code directly, I chose to look into the IE UDF. ATM I'm trying to tick a specific checkbox in SF which simply allows me to "select all checkboxes" at the same time. Applying the following code on a random website with checkboxes works just fine for me: (in this case selecting cheese checkbox)
      #include <IE.au3> Local $oIE = _IECreate("http://www.echoecho.com/htmlforms09.htm") Local $oSubmit = _IEGetObjByName($oIE, "option3") _IEAction($oSubmit, "click") _IELoadWait($oIE) But applying it to the Salesforce website it does exactly nothing and responds with these warnings/errors:
      The script is exactly the same, except for website and the input name tag of the desired checkbox being different.
      #include <IE.au3> Local $oIE = _IECreate("Corporate Salesforce URL") Local $oSubmit = _IEGetObjByName($oIE, "myPage:myForm:oliListBlock:oliListTable:j_id36") _IEAction($oSubmit, "click") _IELoadWait($oIE) As its working with random websites my guess is that there has to be something done to get it work with SF.
      Hope the more experienced SF+AutoIt pros can help me out here. Thanks in advance!
    • By shelly
      I have to press tab to reach a selected button then double click on that
      Here's my script but its not working:
      WinActivate("Policy Decisions -- Webpage Dialog","")
      Sleep(3000)
      Send("{TAB}")
      Send("{TAB}")
      Send("{TAB}")                    // at this point its working according to my need  but double click is not working
      Mouseclick("Left",510, 320, 2, 0)

    • By TheDcoder
      See this thread for info:
×
×
  • Create New...