Sign in to follow this  
Followers 0
paul1149

Pass a variable

7 posts in this topic

Hi,

I'd like to create a shell context menu command to create a desktop shortcut to a selected file. Here's what I have for an au3 script:

$target = "C:\users\paul\desktop\" & %1

FileCreateShortcut($target, %1)

And here's the command in the Registry:

"C:\utilities\AutoIt3\AutoIt3_x64.exe c:\systools\test.au3" %1

Win7 asks me what program I want to use to start the Selected file. Does anyone have a way to do this, or a better way to achieve what I want?

Thanks

p.

Share this post


Link to post
Share on other sites



Compile it and add this command in the Registry

"c:\systools\test.exe" "%1"


AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites

Hi paul1149,

$i_pos = StringInStr(StringReplace($CmdLineRaw, '"', ""), "\",0,-1)
$file = StringMid(StringReplace($CmdLineRaw, '"', ""), $i_pos + 1)
$rc = FileCreateShortcut(StringReplace($CmdLineRaw, '"', ""), @DesktopDir & "\" & StringTrimRight($file,3) & "lnk")

First two lines are used to find only the filename from the full path.

With "%1" as parameter it seems I have a quote at the beginning of the string but not at the end. Maybe I#m doing it wrong or there's a better way to do it at all. :unsure:

Alternatively to $CmdLineRaw you could use $CmdLine[1] or $CmdLine[$cmdLine[0]].


Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]

Share this post


Link to post
Share on other sites

Hi Hannes,

Thanks for that. I understand the string manipulation intuitively, but unfortunately, I'm not following the rest - specifically, how to get the file name into the $CmdLineRaw variable.

p.

Hi Paul,

The $CmdLineRaw and $CmdLine[x] variables / Constants are filled automatically when your script is started. You can look the helpfile under "Running Scripts" for further information.

:unsure:


Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]

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
Sign in to follow this  
Followers 0