13

I would like to run a Power Automate flow by pressing a keyboard shortcut or alternatively calling it up from CMD or Powershell script.

The flow would simply start execution once the keyboard shortcut is pressed or a Powershell script is run.

As it is now; I need to start Power Automate and then click on play in order to start a specific flow. I am trying to avoid all that.

The ultimate goal is to, once the system is up (Windows 10) and I'm logged it, I press the shortcut key and go do something else and by the time I get back the flow is done. The flow itself works flawlessly. Please note that I am not looking for a solution which would involve smartphones and flow buttons on said phones, purely a Windows , PC, only solution or a way to a solution.

SystemWorks
  • 175
  • 1
  • 1
  • 9
  • Can you provide the code youve tried? – Abraham Zinala Mar 08 '21 at 02:22
  • There is no code. I have a simple flow, made with Power Automate, which opens a browser, logins into a website, and navigates to a certain page. I would love to start that flow by simply pressing a shortcut. What I did is I made a basic Powershell script to open and start the Power Automate but I do not know hot to tell it to start the flow from within the Power Automate. The shell script is very simple: – SystemWorks Mar 08 '21 at 02:30
  • Set-Location "C:\Program Files (x86)\Power Automate Desktop" Start-Process "C:\Program Files (x86)\Power Automate Desktop\PAD.Console.Host.exe" – SystemWorks Mar 08 '21 at 02:30
  • Well whats needed once the program is open? A username and password? A click of a yes button? – Abraham Zinala Mar 08 '21 at 02:34
  • Ah, I see, you click on the run icon of the flow you want to run. Nothing else is needed. – SystemWorks Mar 08 '21 at 02:46
  • related (according to a non-answer posted as an answer): https://learn.microsoft.com/en-us/power-automate/desktop-flows/run-desktop-flows-via-keyboard-shortcuts – starball Jun 29 '23 at 07:39

4 Answers4

9

Here is a picture to clarify what Lukas was describing as a workaround.

Create a loop and make sure that the index variable for the loop is 0 so that it will never stop looping. Then make sure to put a 'wait for shortcut key' inside of the loop with you desired shortcut. Below that action and still inside of the loop, put all of your actions.

Run the script and the script will enter the loop at the 'wait for shortcut action. When the shortcut is pressed it will run all of the actions and then loop back to the 'wait for shortcut action again. As long as the script is running in the background the shortcut can trigger it.

JonC
  • 978
  • 2
  • 7
  • 28
  • Thank you. I have accepted this as an answer as it provided clear and understandable explanation to my questions. I was away for awhile so it took some time. – SystemWorks Jun 19 '21 at 04:16
  • Great solution. I've added a different shortcut key and variable for easy exit from the loop. – András Mar 22 '23 at 09:13
4

Surprisingly, I do not think there is a way to do this. The best solution would probably be to use AutoIT to create a small automation to start your PAD flow.

As long as you're somewhat familiar with programming and even if you're not familiar with AutoIT, it shouldn't take you but a couple hours to write a script that is activatable via hotkey that opens PAD and starts the flow you want.

The AutoIT help file that you get when you install should be all the guidance you need.

(Depending on what your flow actually does, you might be better off just writing your whole automation in AutoIT)

Dustin Wyatt
  • 4,046
  • 5
  • 31
  • 60
2

You actually don't need to put everything in a loop, the loop is just from the end of the script to the top label. You just need a label at the top (if you want to be able to press the shortcut more than once), a wait for shortcut key event, and at the end a "go to the label" you created (in the image below it's 'start').

Then you can save the flow and start it. Nothing will happen until you press your shortcut key. Then the flow will execute, and return to the top, waiting for you to press your shortcut again.

You can even have errors go to the start label, instead of ending the script, so that the flow "stays alive".

enter image description here

Alteredorange
  • 556
  • 1
  • 6
  • 23
0

Just put label on top of your code and then "Wait for shortcut key" and at the end use "go to" function, that will loop the code. This works for me

Lukas
  • 21