-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathForm1.vb
More file actions
130 lines (95 loc) · 4.36 KB
/
Form1.vb
File metadata and controls
130 lines (95 loc) · 4.36 KB
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
Imports System.ComponentModel
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
Timer1.Start()
Me.TopLevel = True
Me.TopMost = True
Me.Location = New Point(Screen.PrimaryScreen.WorkingArea.Width - Me.Width, Screen.PrimaryScreen.WorkingArea.Height - Me.Height)
Me.TransparencyKey = SystemColors.Control
Me.BackColor = SystemColors.Control
End Sub
' Check for Mouse Rightclick on Form and textboxes, show contextmenu
Private Sub Form1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseUp
If e.Button = MouseButtons.Right Then
'ContextMenuStrip1.Show(Me, New Point(e.X, e.Y))
ContextMenuStrip1.Show(MousePosition.X, MousePosition.Y)
End If
End Sub
Private Sub lblramusage_click(sender As Object, e As MouseEventArgs) Handles lblRamUsage.MouseClick
If e.Button = MouseButtons.Right Then
'ContextMenuStrip1.Show(Me, New Point(e.X, e.Y))
ContextMenuStrip1.Show(MousePosition.X, MousePosition.Y)
End If
End Sub
Private Sub lblram_click(sender As Object, e As MouseEventArgs) Handles lblRAM.MouseClick
If e.Button = MouseButtons.Right Then
'ContextMenuStrip1.Show(Me, New Point(e.X, e.Y))
ContextMenuStrip1.Show(MousePosition.X, MousePosition.Y)
End If
End Sub
Private Sub NotifyIcon_click(sender As Object, e As MouseEventArgs) Handles NotifyIcon.MouseClick
If e.Button = MouseButtons.Right Then
ContextMenuStrip1.Show(MousePosition.X, MousePosition.Y)
End If
End Sub
' ProcessMonitor()
Sub ProcessMonitor()
' GetProcessesByName(),
Dim processesFA() As Process = Process.GetProcessesByName("ForgedAlliance")
Dim processesSC() As Process = Process.GetProcessesByName("SupremeCommander")
Dim ProcessUsage As Double
' Found something?
Dim myProcess() As Process
Dim MyProcessname As String = ""
If processesFA.Length > 0 Then
myProcess = processesFA
MyProcessname = "ForgedAlliance.exe"
End If
If processesSC.Length > 0 Then
myProcess = processesSC
MyProcessname = "SupremeCommander.exe"
End If
If myProcess IsNot Nothing Then
' Loop
For cnt = 0 To myProcess.Length - 1
' Process is still running?
If Not myProcess(cnt).HasExited Then
ProcessUsage = (myProcess(cnt).WorkingSet64 / 1024)
lblRAM.Text = Format(ProcessUsage, "##,##0K")
If ProcessUsage > 2000000 Then ' 2000000 Then
Me.BackColor = Color.Red
Me.Opacity = 0.6
NotifyIcon.Icon = My.Resources.red_gr_2gb
'If GlobalVars.FirstTimeShow = True Then
'Me.WindowState = FormWindowState.Normal
'Me.TopMost = True
'End If
'GlobalVars.FirstTimeShow = False
Else
Me.BackColor = SystemColors.Control
Me.TransparencyKey = SystemColors.Control
'Me.TopMost = False
'LblError.BackColor = SystemColors.Control
'LblError.Text = MyProcessname & " found!"
NotifyIcon.Icon = My.Resources.blue_less_2GB
End If
End If
Next
Else
'LblError.Text = "Process not found!"
'LblError.BackColor = Color.Red
lblRAM.Text = "0k"
End If ' If myProcess IsNot Nothing Then
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
ProcessMonitor()
End Sub
Private Sub CloseToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles CloseToolStripMenuItem.Click
NotifyIcon.Visible = False
Me.Close()
End Sub
Private Sub Form1_Closing(sender As Object, e As CancelEventArgs) Handles Me.Closing
NotifyIcon.Visible = False
End Sub
End Class