-
Notifications
You must be signed in to change notification settings - Fork 72
/
ShortcutExists.ahk
55 lines (41 loc) · 1.13 KB
/
ShortcutExists.ahk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
ShortcutExists()
{
; determines if a shortcut for the script exists
; MsgBox params: %params%
; declare local, global, static variables
Global ShortcutName
Try
{
; set default return value
fnShortcutExists := 0 ; initialise flag to assume shortcut not present
; validate parameters
; initialise variables
; find shortcut
ShortcutName := ""
Loop, Files, %A_Startup%\*.lnk, F ; loop through all shortcut files in Startup folder
{
FileGetShortcut, %A_LoopFileLongPath%, fnTargetFile ; get the name of the file that the shortcut points to
fnShortcutExists := % fnTargetFile = A_ScriptFullPath ? 1 : fnShortcutExists ; set fnShortcutExists to 1 if any shortcut file points to DAKS
If fnShortcutExists
{
ShortcutName := A_LoopFileLongPath
Break
}
}
}
Catch, ThrownValue
{
ReturnValue := !ReturnValue
CatchHandler(A_ThisFunc,ThrownValue.Message,ThrownValue.What,ThrownValue.Extra,ThrownValue.File,ThrownValue.Line,0,0,0)
}
Finally
{
}
; return
Return fnShortcutExists
}
/* ; testing
params := xxx
ReturnValue := ShortcutExists(params)
MsgBox, ShortcutExists`n`nReturnValue: %ReturnValue%
*/