-
Notifications
You must be signed in to change notification settings - Fork 71
/
ShortcutDelete.ahk
51 lines (37 loc) · 978 Bytes
/
ShortcutDelete.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
ShortcutDelete()
{
; deletes the shortcut for a script
; MsgBox params: %params%
; declare local, global, static variables
Global ShortcutName
Try
{
; set default return value
ReturnValue := 0 ; success
; validate parameters
; initialise variables
; delete the shortcut
fnStartTime := A_TickCount
fnElapsedTime := A_TickCount - fnStartTime ; measure elapsed time
While (ShortcutExists() = 1 && fnElapsedTime < 10000) ; try for up to 10 secs, while the file does not exist
{
FileDelete, %ShortcutName% ; delete 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 := ShortcutDelete(params)
MsgBox, ShortcutDelete`n`nReturnValue: %ReturnValue%
*/