ndandy Posted April 19, 2010 Share Posted April 19, 2010 If I launch a program by a shortcut (.lnk), how can I retrieve the shortcut name? @scriptname return the .exe filename, not the .lnk Link to comment Share on other sites More sharing options...
blckpythn Posted April 19, 2010 Share Posted April 19, 2010 How are you running it without knowing the shortcut name to begin with? Link to comment Share on other sites More sharing options...
ndandy Posted April 19, 2010 Author Share Posted April 19, 2010 How are you running it without knowing the shortcut name to begin with?The user know the shortcut name, but the application no I need to retrieve the shortcut name that was used for launching the app. Link to comment Share on other sites More sharing options...
crashdemons Posted April 19, 2010 Share Posted April 19, 2010 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 More sharing options...
ndandy Posted April 20, 2010 Author Share Posted April 20, 2010 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 More sharing options...
99ojo Posted April 20, 2010 Share Posted April 20, 2010 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 More sharing options...
Makaule Posted April 20, 2010 Share Posted April 20, 2010 Why do you need it? As i know if you have Test.exe and create Shortcut, shortcut would just launch Test.exe and it would work from Test.exe dir. Shortcut is just a shorter way to your exe. Link to comment Share on other sites More sharing options...
ndandy Posted April 20, 2010 Author Share Posted April 20, 2010 Because with shortcut you can pass parameters to GUI app, but without have the shortcut name you cannot retrieve params with FileGetShortcut (probably). Link to comment Share on other sites More sharing options...
therks Posted April 20, 2010 Share Posted April 20, 2010 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). My AutoIt Stuff | My Github Link to comment Share on other sites More sharing options...
ndandy Posted April 20, 2010 Author Share Posted April 20, 2010 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 More sharing options...
therks Posted April 21, 2010 Share Posted April 21, 2010 (edited) 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 April 21, 2010 by RobSaunders My AutoIt Stuff | My Github Link to comment Share on other sites More sharing options...
ndandy Posted April 21, 2010 Author Share Posted April 21, 2010 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&#entry635423He seems to be handling the same issue you are, perhaps his tweak will help you?Ok, thanks to all! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now