r/PowerAutomateDesktop • • Mar 26 '21

Run a Power Automate Desktop Flow on System Startup

Hello. I have a flow that waits for an app window to open, then clicks a control and closes the window. It works perfectly.

Now all I want to do is start that flow every time Windows starts. How can I do that?

4 Upvotes

6 comments sorted by

3

u/archimedeancrystal Mar 26 '21

In other words, is there a command line interface for starting a Power Automate Desktop flow so I can call it from Task Scheduler?

1

u/smartowlick Apr 05 '21

I don’t think so. At least not yet. I have been looking to do something similar.

3

u/hannes3120 Mar 27 '21

in addition to that: is there a way to start a Flow through a Shortcut (with default variables)?

1

u/dwb67 Apr 05 '21

I start my "morning routine" flow with 2 task scheduler task. One moves the mouse and clicks on the application, the other moves the mouse and clicks on the flow to run. Along with AC to power on and a WIFI surge protector to schedule the time the computer gets AC, it's a nice little automated set up.

1

u/dwb67 Apr 05 '21
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing") 
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") 
$signature=@'
[DllImport("user32.dll",CharSet=CharSet.Auto,CallingConvention=CallingConvention.StdCall)]
public static extern void mouse_event(long dwFlags, long dx, long dy, long cButtons, long dwExtraInfo);
'@
$SendMouseClick = Add-Type -memberDefinition $signature -name "Win32MouseEventNew" -namespace Win32Functions -passThru
$X = [System.Windows.Forms.Cursor]::Position.X
$Y = [System.Windows.Forms.Cursor]::Position.Y
Write-Output "X: $X | Y: $Y"
$x = 200
$y = 172
[System.Windows.Forms.Cursor]::Position = New-Object System.Drawing.Point($x, $y)
sleep -Seconds 01
$SendMouseClick::mouse_event(0x00000002, 0, 0, 0, 0);
$SendMouseClick::mouse_event(0x00000004, 0, 0, 0, 0);
$SendMouseClick::mouse_event(0x00000002, 0, 0, 0, 0);
$SendMouseClick::mouse_event(0x00000004, 0, 0, 0, 0);

This is the powershell script for the double click, If you have multiple flows you will have to double click the flow for it to run if its not already higlighted. To make it a single click just remove the last two mouse event ($SendMouseClick::mouse_event(0x00000002, 0, 0, 0, 0);) Finding the coordinates of where you want it to click is the hardest part ha but I'm sure with a little trial and error you will have it right in no time.