-
Notifications
You must be signed in to change notification settings - Fork 72
/
ShortcutCreate.ahk
51 lines (37 loc) · 1019 Bytes
/
ShortcutCreate.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
ShortcutCreate()
{
; creates a shortcut for the link
; MsgBox params: %params%
; declare local, global, static variables
Global ApplicationName
Try
{
; set default return value
ReturnValue := 0 ; success
; validate parameters
; initialise variables
; do something
fnStartTime := A_TickCount
fnElapsedTime := A_TickCount - fnStartTime ; measure elapsed time
While (ShortcutExists() = 0 && fnElapsedTime < 10000) ; try for up to 10 secs, while the file does not exist
{
FileCreateShortcut, %A_ScriptFullPath%, %A_Startup%\%ApplicationName%.lnk ; create it
fnElapsedTime := A_TickCount - fnStartTime ; measure elapsed time
}
}
Catch, ThrownValue
{
ReturnValue := !ReturnValue
CatchHandler(A_ThisFunc,ThrownValue.Message,ThrownValue.What,ThrownValue.Extra,ThrownValue.File,ThrownValue.Line,0,0,0)
}
Finally
{
}
; return
Return ReturnValue
}
/* ; testing
params := xxx
ReturnValue := ShortcutCreate(params)
MsgBox, ShortcutCreate`n`nReturnValue: %ReturnValue%
*/