gmalone

Running a script from the Desktop

15 posts in this topic

#1 ·  Posted (edited)

Please forgive this AutoIt newbie issue...

I've studied the Help docos and tried many methods, but when I place a .au3 script on the Desktop (Win 10), it doesn't execute.  But when I run it, say, in the AutoIt/Examples folder, it runs just fine.

I considered the possibility that the #include <Constants.au3> wasn't in the Path from the Desktop (for some unknown reason), so tried putting a fully qualified path, e.g. #include <C:\Program Files (x86)\AutoIt3\Include\Constants.au3> -- didn't work.

I created a shortcut on the Desktop that points back to the source .au3 file in Examples, but it doesn't work.

I've compiled .exe and .a3x versions -- no go.

I installed the full version of AutoIt.  All my script does is send a key sequence (to activate a macro elsewhere).  Like I said, works from Examples folder, but not from Desktop.  I must be missing something.

#include <Constants.au3>
Send("^W")

Could anyone kindly assist me?   Much appreciation.

Edited by gmalone

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

What is the error you are getting?  Scripts should run fine from anywhere.  Perhaps desktop is something that needs #requireadmin in win10.

 

Also, if your script just sends Ctrl + W, it'll never work, as no window will have focus when you double click an au3.  Use Msgbox instead to verify its working.

Edited by kaisies

Share this post


Link to post
Share on other sites

Thanks for the suggestions.

The #requireadmin is not required, though I tested with it at your suggestion, and it (as before) works withing the Programs\AutoIt\Examples folder, but not on the desktop.

Ditto for using a MsgBox to provide a focus.

The thing about sending Ctrl-W as the only function of the script is that it activates a global AutoKeys macro, regardless of focus -- in normal use, and even w/ the AutoIt script -> but not from the Desktop.  My intention is to setup AutoIt with a variety of 'touch' desktop icons-macros activated on the Surface Pro 4 when the keyboard is not attached.

Again, the acid test is that the AutoIt scripts I'm writing do work -- but not when copied and pasted to the desktop.   There is surely a straightforward issue that's being missed by me here.  :)

Other thoughts?  Anyone?

 

 

Share this post


Link to post
Share on other sites

As kaisies asked, what error are you receiving when you run a simple MsgBox script from the desktop? "It doesn't work" doesn't help us a lot on troubleshooting ;)


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

There's no error message.  I should've mentioned that from the start.  Is there an AutoIt error log somewhere?  Would be glad to look.  The script simply doesn't execute.

Maybe this will help.  A video clip demo'ing what's happening.  Starts in the AutoIt>Examples folder.  The script "workspace.au3" works fine there, evidenced by all windows lining up on the desktop (executes an FastKeys/AutoText macro being run via Ctrl-Shift-w).   I copy the AutoIt script to the Desktop, and it doesn't execute the macro from there.   Have a look, only a few seconds long:  https://youtu.be/QKtqD-53GRk

Thanks again.

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Thanks Mr. Rushdie.  :)

I tried your suggestion.  But that's not the issue.  Because I used ^W  with the W capitalized, it is treated as a shift-w.  And remember, this exact script runs fine... except on the Desktop.  Thx!

Edited by gmalone

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

I should mention that I'm running Win10 in 64-bit mode, though lots of 32-bit stuff runs on top of it, of course.  I found in Help a reference to 64-bit vs 32-bit, and a suggestion of adding this to the script:

#include <WinAPIFiles.au3>
_WinAPI_Wow64EnableWow64FsRedirection(True)

... which I tried adding.  It didn't change the results, i.e. no script execution from the Desktop.

Gonna keep digging.

----- UPDATE -----

It occurs to me that when clicking the .au3 script icon on the Desktop it actually *does* do something... the MsgBox pops up (thank you @kaisies) ... it's only the sending of the key codes that don't activate the FastKeys macro.  I think this is a break in the case... will pursue.

--- UPDATE to the UPDATE ---

Ok, I've determined that I've framed the issue incorrectly, AutoIt scripts do execute on my desktop.  I tried others and their fine.  It's this particular one that isn't working which happened to be my first AutoIt script -- i.e. AutoIt isn't activating the FastKeys macro to clean up my desktop windows when the AutoIt script is run from the desktop.  I now believe the problem lies somewhere w/ the FastKeys and AutoIt.  Like I've always said, but not always applied soon enough, check your assumptions when debugging something.

Once I've figured it out completely, I'll post what I found for anyone else that may have the same issue in the future.

 

Edited by gmalone

Share this post


Link to post
Share on other sites

Ah hah, JohnOne.  You're onto something.  What happens when I manually execute the macro by pressing the key combination when the Desktop is in focus is.... NOTHING.  It seems there must be a window in focus for it to kick off from an AutoIt script!  And, of course, if the AutoIt script icon is setting on the Desktop, and I click it, I'm also taking focus away from a window and onto the Desktop.  Sheesh.  Thank you.  I'll see if I can make the FastKeys macro put a window in focus before doing its cleanup.  This fits what I've learned that if I click on the self-same AutoIt icon that sits on the desktop from inside a File Explorer window, it works!  I feel kinda bad taking up your time, but thanks.

Share this post


Link to post
Share on other sites

Last update:

Thanks JohnOne for helping me discover that having the desktop in focus was the source of the problem -- and it wasn't related to AutoIt at all, rather it was a FastKeys macro script being called by Autoit that was the issue.  I added a simple Send !{Tab} (= alt tab) to the FastKeys script at the very start of the script, thus bringing the most recent active window back into focus, and the rest executes as expected.

Case closed.  Thanks to all who offered suggestions.  Now I can get with the original plan of creating touch icons on the desktop and task bar that allow me to activate various macros when a keyboard is not attached to the Surface Pro 4.

images?q=tbn:ANd9GcQB6XddH2J-6QqUkgCQRft

 

Share this post


Link to post
Share on other sites

Thanks for the Winactivate tip.  Still digging into AutoIt docs.  I see that Winmove and a variety of other nice functions are available too.  Not to mention the tons of example scripts to study.  Right on.

Share this post


Link to post
Share on other sites

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