Unable to click with IE 'Save As' dialog in unattended bot

@Palaniyappan It still fails, timeout has reached in the Activate activity.

If I’m at the UI then the robot able to detect the IE Notification bar and click Save as, but when I execute at the background then it fails

Fine
i think its not taking the simulate click property
kindly disable that and try with enabling send window message property in the click activity
Cheers @sam.lee

but it failed at the Activate activity, not the Click activity

Can I see the selector in the Activate activity?

Sure @caduque, here you go
image

The wildcard is to replace the Task number of the page, it is a generic value

Please try to refer to this conversation.

I already read through and tried from this thread. Still not working

Are you automating a browser or a window?

@caduque A browser

hi @sam.lee

I would suggest you try the following steps:

  1. use a “attach Window” rather than doing in a browser window
  2. use a “Click” activity and click on the IE notification bar (ensure you check the “SimulateClick” option)
  3. Use a “Type Into” activity and send the keys Tab+Tab+Down+Down+Enter (again, ensure that you set the Simulate Type

That works for me.

Hope this helps.

1 Like

Hi @sam.lee
Please try the below steps individually / one after the other.

  • Try to uncheck the simulate property for all the click activities.
  • Go to bot settings on the orchestrator and try to set and update the resolution to 1920 x 1080 (or whatever the resolution your machine has when you open the VM). Then run the robot.

Please let me know if this works.

1 Like

Appreciate for the ideas guys @santhoshreddy @autumnleaf. But I already have a workaround is that directly save the file and move it to the designated folder.

were u able to resolve this.I am stuck in same situation

I change it to clicking ‘Save’ instead. Then use a ‘Move File’ activity to move the file from ‘Downloads’ folder to a specific folder that I want.

Hi Folks,
If this tool allows executing C# script then kindly use the below code snippet, please note to add the required namespaces as well.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Collections;
using System.Windows.Automation;
using System.Windows.Automation.Provider;
using System.Diagnostics;
using System.IO;
using System.Runtime.InteropServices;

namespace WFA_SaveAs
{
public partial class Form1 : Form
{
[DllImport(“user32.dll”, SetLastError = true)]
//static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
public static extern IntPtr FindWindow(string className, string windowTitle);

    [DllImport("user32.dll")]
    static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);

    [DllImport("user32.dll", CharSet = CharSet.Auto)]
    static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, int wParam, string s);

    [DllImport("user32.dll", CharSet = CharSet.Auto)]
    static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, IntPtr lParam);

    [DllImport("user32.dll", EntryPoint = "SendMessageW")] // SendMessageW instead of SendMessage
    static extern void SendMessage(IntPtr windowHandle, UInt32 message, UInt32 wParam, [MarshalAs(UnmanagedType.LPWStr)] string msg);

    [DllImport("user32.dll", SetLastError = true)]
    public static extern IntPtr SetActiveWindow(IntPtr hWnd);

    [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
    public static extern bool SetWindowText(IntPtr hwnd, String lpString);

    [return: MarshalAs(UnmanagedType.Bool)]
    [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
    static extern bool PostMessage(IntPtr hWnd, uint Msg, int wParam, IntPtr lParam);

    public Form1()
    {
        InitializeComponent();
    }

    private void button1_Click(object sender, EventArgs e)
    {
        DownLoadFile("Download Microsoft® OLE DB Driver 18 for SQL Server® from Official Microsoft Download Center - Internet Explorer","save as");
    }

    public void DownLoadFile(string strWindowTitle,string btnToClick)
    {
        IntPtr TargetHandle = FindWindow("IEFrame", strWindowTitle);
        SetActiveWindow(TargetHandle);
        
        AutomationElementCollection ParentElements = AutomationElement.FromHandle(TargetHandle).FindAll(TreeScope.Children, Condition.TrueCondition);
        foreach (AutomationElement ParentElement in ParentElements)
        {
            // Identidfy Download Manager Window in Internet Explorer
            if (ParentElement.Current.ClassName == "Frame Notification Bar")
            {
                AutomationElementCollection ChildElements = ParentElement.FindAll(TreeScope.Children, Condition.TrueCondition);
                // Idenfify child window with the name Notification Bar or class name as DirectUIHWND 
                foreach (AutomationElement ChildElement in ChildElements)
                {
                    if (ChildElement.Current.Name == "Notification bar" || ChildElement.Current.ClassName == "DirectUIHWND")
                    {

                        AutomationElementCollection DownloadCtrls = ChildElement.FindAll(TreeScope.Children, Condition.TrueCondition);
                        foreach (AutomationElement ctrlButton in DownloadCtrls)
                        {
                            //Look for save button and then try to get its child control
                            if (ctrlButton.Current.Name.ToLower() == "save")
                            {
                                //Get its child control
                                AutomationElementCollection DownloadCtrls1 = ctrlButton.FindAll(TreeScope.Children, Condition.TrueCondition);
                                foreach (AutomationElement ctrlButton1 in DownloadCtrls1)
                                {
                                    //There will be only one child control here and that is dropdown button when clicked opens up another menu with button such as "save", "save as" and "save and run"
                                    if(ctrlButton1.Current.Name != "")
                                    {
                                         //The below 2 line of code will perform click on dropdown button
                                         var invokePattern = ctrlButton1.GetCurrentPattern(InvokePattern.Pattern) as InvokePattern;
                                         invokePattern.Invoke();

                                         //The window that contains button "save as" has class name called as #32768, with this we will be able to get window handle for it 
                                         var saveMenuHandle = FindWindow("#32768", "");
                                         SetActiveWindow(saveMenuHandle);
                                         //This code will get all child controls inside the above window whose class name is #32768
                                         var subMenuItems = AutomationElement.FromHandle(saveMenuHandle).FindAll(TreeScope.Children, Condition.TrueCondition);
                                         //This code will loop within child controls and see if any child control name is "save as" and perform a click on it
                                         foreach (AutomationElement item in subMenuItems)
                                         {
                                            if (item.Current.Name.ToLower() == btnToClick.ToLower())
                                            {
                                                var saveAsMenuItem = item.GetCurrentPattern(InvokePattern.Pattern) as InvokePattern;
                                                saveAsMenuItem.Invoke();
                                            }

                                        }
                                    }
                                   
                                }
                            }

                        }
                    }
                }


            }
        }
    }
}

}

Dear Sam,

please use send Hotkey

  1. Alt+N will focus on the Notification bar.
  2. Tab will move to Save.
  3. Press Down.
  4. Press “a”.
    it will 100% work

Thanks