-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlaunchbox_autohotkeyscript.ahk
60 lines (53 loc) · 1.67 KB
/
launchbox_autohotkeyscript.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
56
57
58
59
60
; ===========================================================================
; Run a program or switch to it if already running.
; Target - Program to run. E.g. Calc.exe or C:\Progs\Bobo.exe
; WinTitle - Optional title of the window to activate. Programs like
; MS Outlook might have multiple windows open (main window and email
; windows). This parm allows activating a specific window.
; ===========================================================================
RunOrActivate(Target, WinTitle = "")
{
; Get the filename without a path
SplitPath, Target, TargetNameOnly
Process, Exist, %TargetNameOnly%
If ErrorLevel > 0
PID = %ErrorLevel%
Else
Run, %Target%, , , PID
; At least one app (Seapine TestTrack wouldn't always become the active
; window after using Run), so we always force a window activate.
; Activate by title if given, otherwise use PID.
If WinTitle <>
{
SetTitleMatchMode, 2
WinWait, %WinTitle%, , 3
;TrayTip, , Activating Window Title "%WinTitle%" (%TargetNameOnly%)
WinActivate, %WinTitle%
}
Else
{
WinWait, ahk_pid %PID%, , 3
;TrayTip, , Activating PID %PID% (%TargetNameOnly%)
WinActivate, ahk_pid %PID%
}
;SetTimer, RunOrActivateTrayTipOff, 1500
}
; Turn off the tray tip
RunOrActivateTrayTipOff:
SetTimer, RunOrActivateTrayTipOff, off
TrayTip
Return
RunIfNotActive(Target, WinTitle = "")
{
; Get the filename without a path
SplitPath, Target, TargetNameOnly
Process, Exist, %TargetNameOnly%
If ErrorLevel > 0
PID = %ErrorLevel%
Else
Run, %Target%, , , PID
}
; ps4 home button
Joy13::
RunIfNotActive("C:\Users\USER\LaunchBox\BigBox.exe")
return