Jump to content

launch an application using it's shortcut key


Recommended Posts

I want to run an application in Windows 10 by using it's shortcut key. More precisely:

In the Properties of a shortcut ("Anaconda Prompt (anaconda3).lnk"), I inserted "CTRL + ALT + P" as Shortcut key. Now, I would like to run this shortcut by my autoit script.

#RequireAdmin 

Send("{{LCTRL down}")
Send("{{ALT down}")
Send("{{P}")
Send("{{LCTRL up}")
Send("{{ALT up}")

This key combination works fine using the according keys on my keyboard, but nothing happens when I run my script.

Could somebody please tell me the correct way to do this?

 

Additional Info:

  • Name of : Anaconda Prompt (anaconda3)
  • Shortcut Location: C:\Users\username\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Anaconda3 (64-bit)
  • Target: %windir%\System32\cmd.exe "/K" C:\Users\username\anaconda3\Scripts\activate.bat C:\Users\username\anaconda3
  • Start in: %HOMEPATH%

It's supposed to run as administrator.

Link to comment
Share on other sites

You've doubled up all the leading opening brackets braces. Also, if you know where the shortcut is, why don't you just ShellExecute it?

Edited by seadoggie01

All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.

Spoiler

My Humble Contributions:
Personal Function Documentation - A personal HelpFile for your functions
Acro.au3 UDF - Automating Acrobat Pro
ToDo Finder - Find #ToDo: lines in your scripts
UI-SimpleWrappers UDF - Use UI Automation more Simply-er
KeePass UDF - Automate KeePass, a password manager
InputBoxes - Simple Input boxes for various variable types

Link to comment
Share on other sites

Removing one of the opening braces does the trick: the application opens.

But it also leads to the next problem: the Alt- and/or the the LCTRL-key get stuck. I can monitor this using the windows On Screen Keyboard. Following this link CTRL key get stuck after using Send I tried

ControlSend("", "", "", "text", 0)

without any luck. I manage to unstuck one of the two keys within the script, but only manual pressing the second locked key on the keyboard resolves the problem.

 

Using Shellexecute was my first attempt. But the application calls the C:\Windows\System32\cmd.exe with a set of parameters (see my original post: "Additional Info"). These would have to be set as the Parameters of the ShellExecute command. But I do not manage to get the syntax right. This is why I went for the "CTRL + ALT +P" in the first place.

 

Once I have successfully opened the shell, I use ControlSend to send commands.

Edited by dejhost
grammar correction
Link to comment
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
 Share

  • Recently Browsing   0 members

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