-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAssistant.ps1
117 lines (79 loc) · 3.91 KB
/
Assistant.ps1
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#================================================================================================================================
#----------------INFO----------------
#
# CC-BY-SA-NC Stella Ménier <[email protected]>
# Project creator for Skrivanek GmbH
#
# Usage: powershell.exe -executionpolicy bypass -file ".\Rocketlaunch.ps1"
# Usage: Compiled form, just double-click.
#
#-------------------------------------
#===============================================
# Initialization =
#===============================================
#========================================
# Get all important variables in place
# Grab script location in a way that is compatible with PS2EXE
if ($MyInvocation.MyCommand.CommandType -eq "ExternalScript")
{ $global:ScriptPath = Split-Path -Parent -Path $MyInvocation.MyCommand.Definition }
else
{$global:ScriptPath = Split-Path -Parent -Path ([Environment]::GetCommandLineArgs()[0])
if (!$ScriptPath){ $global:ScriptPath = "." } }
# When executed at windows start, location is not in the script folder
Set-Location -Path $ScriptPath
# Load and parse the JSON configuration file
$script:settings = Get-Content $ScriptPath\parts\state.json -Raw -ErrorAction:SilentlyContinue -WarningAction:SilentlyContinue | ConvertFrom-Json -ErrorAction:SilentlyContinue -WarningAction:SilentlyContinue
# legacy #$script:settings = Import-LocalizedData -FileName settings.psd1 -BaseDirectory $ScriptPath\parts
# Get localization
$script:text = Import-LocalizedData -FileName interface.psd1 -BaseDirectory $ScriptPath\localizations
# Load everything we need
Import-Module $ScriptPath\parts\PcOCRCapture.ps1
Import-Module $ScriptPath\parts\utils.ps1
Import-Module $ScriptPath\parts\UI.ps1
#===============================================
# Initialization =
#===============================================
#========================================
# Get all important variables in place
# Start the subprocesses
if ($settings.TopLeftOverview.Enabled -eq "true")
{
Start-Process -FilePath $ScriptPath\parts\hotcorner_topleft.exe -ArgumentList $settings.TopLeftOverview.reactivity,$settings.TopLeftOverview.sensitivity
$Menu_Toggle_HotCorner_TopLeft.Checked = $true
}
if ($settings.WindowsButton.Enabled -eq "true")
{
Start-Process -FilePath $ScriptPath\parts\hotcorner_winbutton.exe -ArgumentList $settings.WindowsButton.reactivity,$settings.WindowsButton.sensitivity
$Menu_Toggle_HotCorner_WinButton.Checked = $true
}
if ($settings.ShowDesktop.Enabled -eq "true")
{
Start-Process -FilePath $ScriptPath\parts\hotcorner_bottomright_showdesktop.exe -ArgumentList $settings.ShowDesktop.reactivity,$settings.ShowDesktop.sensitivity
$Menu_Toggle_HotCorner_ShowDesktop.Checked = $true
}
if ($settings.CloseActiveWindow.Enabled -eq "true")
{
Start-Process -FilePath $ScriptPath\parts\hotcorner_topright_close.exe -ArgumentList $settings.CloseActiveWindow.reactivity,$settings.CloseActiveWindow.sensitivity
$Menu_Toggle_HotCorner_Close.Checked = $true
}
if ($settings.KeepAwake.Enabled -eq "true")
{
Start-Process -FilePath $ScriptPath\parts\keepawake.exe
$Menu_Toggle_KeepAwake.Checked = $true
$Main_Tool_Icon.Icon = $icon
}
else {
$Main_Tool_Icon.Icon = $icondark
}
# Tell user we started
$Main_Tool_Icon.BalloonTipTitle = $text.TopUI.NotifyStartTitle
$Main_Tool_Icon.BalloonTipIcon = [System.Windows.Forms.ToolTipIcon]::Info
$Main_Tool_Icon.BalloonTipText = $text.TopUI.NotifyStartText
$Main_Tool_Icon.Visible = $true
$Main_Tool_Icon.ShowBalloonTip(200)
# Force garbage collection just to start slightly lower RAM usage.
[System.GC]::Collect()
# Create an application context for it to all run within.
# This helps with responsiveness, especially when clicking Exit.
$appContext = New-Object System.Windows.Forms.ApplicationContext
[void][System.Windows.Forms.Application]::Run($appContext)