Jump to content

Recommended Posts

Posted

Real simple script. Just want to fire up a Power Automate flow.

Run("C:\Program Files (x86)\Power Automate Desktop\PAD.Console.Host.exe")
WinWaitActive("Power Automate", "", 10)
WinMove("Power Automate","",0,0)
WinSetState("Power Automate","", @SW_MAXIMIZE)
MouseClick("left",571,253,1)
Exit

It worked fine on my laptop.

Then when I tried it on my desktop (Win 10), it opens the file and does nothing after (doesn't maximize let alone left click).

Where do I begin?

Posted

As already recommended by @Nine  :

Local $PID, $hHandle, $iResult

$PID = Run("C:\Program Files (x86)\Power Automate Desktop\PAD.Console.Host.exe")
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $PID = ' & $PID & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console

$hHandle = WinWaitActive("Power Automate", "", 10)
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $hHandle = ' & $hHandle & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console

$hHandle = WinMove("Power Automate","",0,0)
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $hHandle = ' & $hHandle & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console

$iResult = WinSetState("Power Automate","", @SW_MAXIMIZE)
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $iResult = ' & $iResult & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console

$iResult = MouseClick("left",571,253,1)
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $iResult = ' & $iResult & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console

Exit

 

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Posted

I just tested it again on my laptop which is a work laptop and far more locked down admin wise. My desktop has no such restrictions. File is in a normal spot too. 

Posted

To be 100% clear, I used the code suggested above in SciTE-Lite and tried compile/build.

Oddly enough, I purposely misspelled one of the function names and it still returned that Exit code message on the right pane. I am new to this software so I apologize ahead of time if I'm missing something completely obvious. 

image.thumb.png.7ed053114b1b6689c3884d9f8eab9eaa.png

Posted

I put the script on my C drive but still no luck.

It literally opens up Power Automate but then just does nothing after that.

I am logged in as Admin. I've tried running the script a few different ways (x64) vs. (x86). I think my desktop is x64 whereas my laptop is x86 (and that's where it works fine).

Posted (edited)

You mention your Desktop is Windows 10, but what is your laptop? I've seen program names change (slightly) between windows versions before. — Just a thought.

 

Edit, not a fix, but you may want to put quotes around the file path for Run? Run doesn't like paths with spaces. Like this.

Local $PID, $hHandle, $iResult

ConsoleWrite("ScriptBegin" & @CRLF)

$PID = Run('"C:\Program Files (x86)\Power Automate Desktop\PAD.Console.Host.exe"')
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $PID = ' & $PID & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console

$hHandle = WinWaitActive("Power Automate", "", 10)
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $hHandle = ' & $hHandle & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console

$hHandle = WinMove("Power Automate","",0,0)
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $hHandle = ' & $hHandle & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console

$iResult = WinSetState("Power Automate","", @SW_MAXIMIZE)
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $iResult = ' & $iResult & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console

$iResult = MouseClick("left",571,253,1)
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $iResult = ' & $iResult & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console

Exit
Edited by donnyh13

LibreOffice UDF  ; Scite4AutoIt Spell-Checker Using LibreOffice

Spoiler

"Life is chiefly made up, not of great sacrifices and wonderful achievements, but of little things. It is oftenest through the little things which seem so unworthy of notice that great good or evil is brought into our lives. It is through our failure to endure the tests that come to us in little things, that the habits are molded, the character misshaped; and when the greater tests come, they find us unready. Only by acting upon principle in the tests of daily life can we acquire power to stand firm and faithful in the most dangerous and most difficult positions."

 

Posted (edited)

You running the same OS on both computers?

Have you put this at the top of your script --> #RequireAdmin

A script on my windows 7 would not work on windows 10 do that not being there.

Edited by Somerset

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...