-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathForm1.vb
More file actions
92 lines (75 loc) · 2.77 KB
/
Form1.vb
File metadata and controls
92 lines (75 loc) · 2.77 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
Public Class frmMain
Private Const KEYEVENTF_KEYUP As Integer = &H2
Private Const VK_PLAY_PAUSE As Byte = &HB3
Private Const VK_MEDIA_STOP As Byte = &HB2
Private Const VK_MEDIA_PREV_TRACK As Byte = &HB1
Private Const VK_MEDIA_NEXT_TRACK As Byte = &HB0
Private idletime As Integer
Private Declare Sub keybd_event Lib "user32" (
ByVal bVk As Byte,
ByVal bScan As Byte,
ByVal dwFlags As Integer,
ByVal dwExtraInfo As Integer
)
Private Sub btnPlay_Click(sender As Object, e As EventArgs) Handles btnPlay.Click
' Press and release Play/Pause
sendKey(VK_PLAY_PAUSE)
End Sub
Private Sub btnStop_Click(sender As Object, e As EventArgs) Handles btnStop.Click
sendKey(VK_MEDIA_STOP)
End Sub
Private Sub sendKey(VK_MAP As Byte)
Try
keybd_event(VK_MAP, 0, 0, 0)
keybd_event(VK_MAP, 0, KEYEVENTF_KEYUP, 0)
Catch ex As Exception
Debug.Print("Error sending key: " & ex.Message)
End Try
End Sub
Private Sub btnbck_Click(sender As Object, e As EventArgs) Handles btnbck.Click
sendKey(VK_MEDIA_PREV_TRACK)
End Sub
Private Sub btnffwd_Click(sender As Object, e As EventArgs) Handles btnffwd.Click
sendKey(VK_MEDIA_NEXT_TRACK)
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles tmridle.Tick
'Me.Opacity = 1
If idletime < 5 Then
idletime = idletime + 1
Debug.Print("Idling in:" & idletime)
Else
changeopacity(0.3)
tmridle.Enabled = False
End If
End Sub
Private Sub changeopacity(value As Double)
If value < 0 OrElse value > 1 Then
Throw New ArgumentOutOfRangeException(NameOf(value), "Opacity must be between 0 and 1.")
End If
Me.Opacity = value
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
End
End Sub
Private Sub frmMain_Load(sender As Object, e As EventArgs) Handles Me.Load
tmridle.Interval = 1000 ' 1 second
tmridle.Enabled = False
End Sub
Private Sub frmMain_MouseMove(sender As Object, e As MouseEventArgs) Handles Me.MouseMove
' Reset idle time when mouse moves inside the form
idletime = 0
changeopacity(1)
tmridle.Enabled = False
End Sub
Private Sub frmMain_Activated(sender As Object, e As EventArgs) Handles Me.Activated
idletime = 0
changeopacity(1)
'tmridle.Enabled = True
Debug.Print("Form activated")
End Sub
Private Sub frmMain_Deactivate(sender As Object, e As EventArgs) Handles Me.Deactivate
'changeopacity(0.4)
tmridle.Enabled = True
Debug.Print("Form deactivated")
End Sub
End Class