Sign in to follow this  
Followers 0
xnbyte

plz help to target shortcut by context menu

4 posts in this topic

#1 ·  Posted (edited)

I know the Windows Explorer.exe has a Command-Line Option "select,". It could target a shortcut to its exact folder and file. And the article is here. http://support.microsoft.com/kb/314853/en-us

So I could target the shortcut in AutoIt as below:

$NotepadLnk = FileGetShortcut(@DesktopDir & "\Notepad.lnk");I suppose there is a Notepad shortcut in the desktop
Run("Explorer.exe" & " /select, " & $NotepadLnk[0])oÝ÷ Ù8^vvö§qëayÊzÚ-j¸µ©ò²+µË­o(­±Ê'µìméîêÞËayÊy«­¢+Ø9½QÉå%½¸()I]É¥Ñ ÅÕ½Ðí!-
HÀäÈí±¹­¥±ÀäÈíÍ¡±°ÀäÈíQÉÑ1¹¬ÅÕ½Ðì°ÅÕ½ÐìÅÕ½Ðì°ÅÕ½ÐíI}MhÅÕ½Ðì°ÅÕ½ÐíQÉй±¹¬ÅÕ½Ðì¤)I]É¥Ñ ÅÕ½Ðí!-
HÀäÈí±¹­¥±ÀäÈíÍ¡±°ÀäÈíQÉÑ1¹¬ÀäÈí½µµ¹ÅÕ½Ðì°ÅÕ½ÐìÅÕ½Ðì°ÅÕ½ÐíI}MhÅÕ½Ðì°ÌäìÅÕ½ÐíáÁ±½ÉȹáÅÕ½ÐìÌäìµÀìÅÕ½Ðì½Í±Ð°ÅÕ½ÐìµÀìÕ±±AÑ  ÅÕ½ÐìÄÅÕ½Ð줤()Õ¹Õ±±AÑ  ÀÌØí1¹­¥±¤(ÀÌØíô¥±ÑM¡½ÉÑÕÐ ÀÌØí1¹­¥±¤(%ÉÑÕɸ ÀÌØílÁt¤)¹Õ¹

However, there is a error of "Subscript used with non-Array variable." in Line 8. Then I don't know how to fix it. Does someone have an idea? Thanks.

Edited by xnbyte

Share this post


Link to post
Share on other sites



However, there is a error of "Subscript used with non-Array variable." in Line 8. Then I don't know how to fix it. Does someone have an idea? Thanks.

I would say that you are getting the error as the shortcut does not exist.

I am unsure of your direction of this by using RegWrite() and other functions but if it involves simply running a shortcut or document, then perhaps ShellExecute() or ShellExecuteWait() maybe easier to use?

Open a shortcut like this

ShellExecute(@DesktopDir & '\notepad.lnk')oÝ÷ Úè¥éÚv.éí)¶¬jëh×6ShellExecute(@DesktopDir & '\test.txt')

:whistle:

Share this post


Link to post
Share on other sites

I am unsure of your direction of this by using RegWrite() and other functions but if it involves simply running a shortcut or document, then perhaps ShellExecute() or ShellExecuteWait() maybe easier to use?

Thank MHz for your reply. But all I want is to target instead execute the shortcut.

Share this post


Link to post
Share on other sites

Thank MHz for your reply. But all I want is to target instead execute the shortcut.

This example will return the path stored in the shortcut.

$value = FullPath(@DesktopDir & '\notepad.lnk')
If Not @error Then
    MsgBox(0x40000, 'value =', $value)
EndIf

Exit

Func FullPath($LnkFile)
    ; Return a path from a shortcut
    Local $array
    If FileExists($LnkFile) Then
        $array = FileGetShortcut($LnkFile)
        If Not @error And IsArray($array) Then
            Return $array[0]
        Else
            Return SetError(1, 0, '')
        EndIf
    EndIf
EndFunc

:whistle:

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