14

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.

6
  • Can you provide the code youve tried? Commented Mar 8, 2021 at 2: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: Commented Mar 8, 2021 at 2:30
  • Set-Location "C:\Program Files (x86)\Power Automate Desktop" Start-Process "C:\Program Files (x86)\Power Automate Desktop\PAD.Console.Host.exe" Commented Mar 8, 2021 at 2:30
  • Well whats needed once the program is open? A username and password? A click of a yes button? Commented Mar 8, 2021 at 2:34
  • Ah, I see, you click on the run icon of the flow you want to run. Nothing else is needed. Commented Mar 8, 2021 at 2:46

4 Answers 4

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.

Sign up to request clarification or add additional context in comments.

2 Comments

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.
Great solution. I've added a different shortcut key and variable for easy exit from the loop.
5

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)

Comments

3

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

Comments

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

2 Comments

Maybe you can elaborate more about that solution, could you put some code with essential parts of your solution.
Agree, you should explain the solution a bit more maybe with a code example.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.