web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Focus window not worki...
Power Automate
Answered

Focus window not working properly in unattended mode

(0) ShareShare
ReportReport
Posted on by 32

Hi,

My flow is working fine in attended mode, but when I try to run this in unattended mode, the Focus on window is not working properly. 

So my flow includes open Excel -> Open Browser -> Focus window on browser instance -> sign in - > etc.


I'm receiving the error below, sometimes when I hit resubmit it will work, but sometimes it wasn't 

any idea why this is happening?

Problem while executing action 'FocusByInstanceOrHandle'. Window wasn't found

Microsoft.PowerPlatform.PowerAutomate.Desktop.Actions.SDK.ActionException: Window wasn't found ---> Microsoft.Flow.RPA.Desktop.Modules.UIAutomation.Common.Exceptions.WindowNotFoundException: Exception of type 'Microsoft.Flow.RPA.Desktop.Modules.UIAutomation.Common.Exceptions.WindowNotFoundException' was thrown. ---> System.Exception: Failed to access the supplied window instance using window handle '0'
at Microsoft.Flow.RPA.Desktop.Modules.UIAutomation.Common.WindowContainers.GetInstanceWithSanityChecks(IntPtr windowHandle)
at Microsoft.Flow.RPA.Desktop.Modules.UIAutomation.Common.Window.WindowsActions.FindWindowByRetractionMode(String windowSelector, String childWindowSelector, IntPtr handle, String windowTitle, String windowClass, UIWindowRetractionModeEnum uiWindowRetractionMode, Int32 automationImpl)
--- End of inner exception stack trace ---
at Microsoft.Flow.RPA.Desktop.Modules.UIAutomation.Common.Window.WindowsActions.FindWindowByRetractionMode(String windowSelector, String childWindowSelector, IntPtr handle, String windowTitle, String windowClass, UIWindowRetractionModeEnum uiWindowRetractionMode, Int32 automationImpl)
at Microsoft.Flow.RPA.Desktop.Modules.UIAutomation.Common.Window.WindowsActions.FocusWindow(String windowSelector, String childWindowSelector, IntPtr handle, String windowTitle, String windowClass, Int32 uiWindowRetractionMode, Int32 automationImpl)
at Microsoft.Flow.RPA.Desktop.Modules.UIAutomation.Common.Proxy.LocalAutomationRuntime.FocusWindow(UIRuntimeElement window, IntPtr handle, String windowTitle, String windowClass, FindWindowBy windowMode)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.Flow.RPA.Desktop.Modules.UIAutomation.Common.Proxy.UIAutomationRuntimeRouter.Invoke(MethodInfo targetMethod, Object[] args)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Reflection.DispatchProxyGenerator.Invoke(Object[] args)
--- End of remote exception stack trace ---
at Microsoft.Flow.RPA.Desktop.Modules.UIAutomation.Common.Proxy.RemoteAutomationRuntimeProxy.Invoke(MethodInfo targetMethod, Object[] args)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Reflection.DispatchProxyGenerator.Invoke(Object[] args)
at Microsoft.Flow.RPA.Desktop.Modules.UIAutomation.Actions.FocusWindowBase.<Execute>b__21_1(IAutomationRuntime r, UIRuntimeElement e)
at Microsoft.Flow.RPA.Desktop.Modules.UIAutomation.Common.UIAutomationActionBase.PerformLocalAutomation(Action`2 action, UIControl control, Boolean logAction)
at Microsoft.Flow.RPA.Desktop.Modules.UIAutomation.Actions.FocusWindowBase.Execute(ActionContext context)
--- End of inner exception stack trace ---
at Microsoft.Flow.RPA.Desktop.Modules.UIAutomation.Actions.FocusWindowBase.Execute(ActionContext context)
at Microsoft.Flow.RPA.Desktop.Robin.Engine.Execution.ActionRunner.Run(IActionStatement statement, Dictionary`2 inputArguments, Dictionary`2 outputArguments)

I have the same question (0)
  • Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    Can you please share a screenshot of your flow?

  • IamNadaa Profile Picture
    32 on at

    since I'm running this in unattended mode, my workaround here is to retry the flow up to 10 times, until the flow work successfully.

    IamNadaa_0-1689947634551.png

     

  • Verified answer
    Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    The %Browser% variable stores a browser instance and not a window instance. You would need to use the Get window action first to get a window instance variable. Instead, you can try to use Focus window using the window title and class, instead of the handle. That should also work.

    -------------------------------------------------------------------------
    If I have answered your question, please mark it as the preferred solution. If you like my response, please give it a Thumbs Up.

    I also provide paid consultancy and development services using Power Automate. If you're interested, DM me and we can discuss it.

  • IamNadaa Profile Picture
    32 on at

    That's fast! 

    Thank you so much, I will try it and will accept this as a solution if it works!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 262 Super User 2026 Season 1

#2
11manish Profile Picture

11manish 167

#3
Haque Profile Picture

Haque 154

Last 30 days Overall leaderboard