Jump to content

How to retrieve shortcut name?


Recommended Posts

I'm not aware of an *easy* way to do what you are asking...

What are you seeking to accomplish in your program?

If you want to associate different actions of the same program between different shortcuts you can use "Command Line Parameters" in your shortcuts.

For example: a shortcut to "C:\pathto\program.exe" /dosomething

And in the script you can check $CmdLineRaw or $CmdLine[element]. See "Running Scripts" in the AutoIt Help File.

My Projects - WindowDarken (Darken except the active window) Yahsmosis Chat Client (Discontinued) StarShooter Game (Red alert! All hands to battlestations!) YMSG Protocol Support (Discontinued) Circular Keyboard and OSK example. (aka Iris KB) Target Screensaver Drive Toolbar Thingy Rollup Pro (Minimize-to-Titlebar & More!) 2D Launcher physics example Ascii Screenshot AutoIt3 Quine Example ("Is a Quine" is a Quine.) USB Lock (Another system keydrive - with a toast.)

Link to comment
Share on other sites

Yes, this is the main problem!

I tried to use $CmdLineRaw, but probably it is for CUI, with my app(GUI) it returns

/AutoIt3ExecuteScript "filename.exe"

and I don't see params passed.

So I need to use the FileGetShortcut function to get params, but I need to know the .lnk filename

FileGetShortcut ( "lnk" )

Link to comment
Share on other sites

Hi,

you might use your app to let the user choose the LNK, and then launch it.

;only needed for _ArrayDisplay
#include <array.au3>
;Open Dialog with lnk filter
$lnk = FileOpenDialog ("Select Shortcut to run", @DesktopDir, "LNK (*.lnk)")
If $lnk <> "" Then
    ;if you need properties
    $arlnkprop = FileGetShortcut ($lnk)
    ;show properties
    _ArrayDisplay ($arlnkprop)
    ;Execute lnk
    ShellExecute ($lnk)
EndIf
Link to comment
Share on other sites

I'm pretty sure what you're asking for specifically can't be done.

Try this. Compile this script:

MsgBox(0, '', $CmdLineRaw)

Then run it from a shortcut with the target set as such ["c:\whatever the path to the file is\compiled.exe" "this is a parameter"]

The message box should say "this is a parameter" (including quotation marks).

Link to comment
Share on other sites

Ok, with your support I found the problem.

I used the AutoItErrorHandler_UDF, so when I include it $CmdLineRaw is:

/AutoIt3ExecuteScript "filename.exe"

instead without it, $CmdLineRaw returns the correct parameters.

Do I have to disable AutoItErrorHandler_UDF in order to read parameters?

Link to comment
Share on other sites

It's possible, I'm not familiar with the AutoItErrorHandler_UDF.

*Edit: Although with a quick search I found this post: http://www.autoitscript.com/forum/index.php?showtopic=88420&st=0&p=635423&hl=AutoItErrorHandler_UDF%20&fromsearch=1&#entry635423

He seems to be handling the same issue you are, perhaps his tweak will help you?

Edited by RobSaunders
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...