-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmp4.xaml.vb
More file actions
310 lines (247 loc) · 11.2 KB
/
mp4.xaml.vb
File metadata and controls
310 lines (247 loc) · 11.2 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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
Imports System.ComponentModel
Imports System.IO
Imports System.Runtime.InteropServices
Imports System.Text
Imports System.Windows.Threading
Public Class mp4
Dim time As String '时间
Dim selectedFolder As String '选择的文件夹
Dim startmp4file As String
Dim startmp4file514 As String
Private firstLine As String = String.Empty
'Private secondLine As String = String.Empty
Private timewhenthecountdownstarts As String
Private IsEnded As Boolean = False
Private starting_config As String
Public ClickLaunch As String = Nothing
Private Declare Function FindWindowEx Lib "user32.dll" Alias "FindWindowExA" (ByVal hwndParent As IntPtr, ByVal hwndChildAfter As IntPtr, ByVal lpszClass As String, ByVal lpszWindow As String) As IntPtr
Private Declare Function GetWindowText Lib "user32.dll" Alias "GetWindowTextA" (ByVal hwnd As IntPtr, ByVal lpString As StringBuilder, ByVal cch As Integer) As Integer
Private Declare Function GetClassName Lib "user32.dll" Alias "GetClassNameA" (ByVal hWnd As IntPtr, ByVal lpClassName As StringBuilder, ByVal nMaxCount As Integer) As Integer
Private WithEvents pollTimer As New DispatcherTimer()
Private ReadOnly started As Boolean = False
Public Determinewhetherthevideowasclicked As Boolean = False
Public isend114 As Boolean = True
<DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)>
Private Shared Function FindWindow(ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr
End Function
Dim appDirecory As String = AppDomain.CurrentDomain.BaseDirectory
Dim ThemsDirectory As String = AppDomain.CurrentDomain.BaseDirectory & "\Thems"
Private Sub mp4_Loaded(sender As Object, e As RoutedEventArgs) Handles Me.Loaded
Topmost = True
Dim folders() As String = Directory.GetDirectories(ThemsDirectory)
'If Whethertostartinfullscreen = "ON" Then
' Me.WindowState = WindowState.Normal
'End If
System.Diagnostics.Debug.WriteLine(folders.Length)
If File.Exists("product.config") Then
Using reader As New StreamReader("product.config")
Dim a114 As String = reader.ReadLine() '没用的变量,占行的
Startupparameters = reader.ReadLine()
firstLine = reader.ReadLine()
timewhenthecountdownstarts = reader.ReadLine()
End Using
End If
If ninthline = "True" Then
If folders.Length > 0 Then
Dim random As New Random()
Dim randomIndex As Integer = random.Next(0, folders.Length)
selectedFolder = folders(randomIndex)
Try
Dim files() As String = Directory.GetFiles(selectedFolder)
startmp4file = selectedFolder & "\startmp4.mp4"
If Enableclicking = "SR" Then
ClickLaunch = selectedFolder & "\startmp41.mp4"
End If
Catch ex As Exception
MsgBox("主题读取失败。 " & secondLine & " 请检查 Thems 文件夹是否为空,或其内部图片是否完好。", vbExclamation)
End Try
Else
MsgBox("主题读取失败。 " & secondLine & " 请检查 Thems 文件夹是否为空,或其内部图片是否完好。", vbExclamation)
End If
Try
If File.Exists(startmp4file) Then
kdtkyd6666.Source = New Uri(startmp4file, UriKind.Absolute)
'kdtkyd6666.Play()
Else
MsgBox("视频触发失败,请检查" & startmp4file & "\startmp4.mp4是否可用,或在设置页面中关闭启动视频", vbExclamation)
isend114 = False
Close()
End If
' kdtkyd6666.Source = New Uri(startmp4file, UriKind.Absolute)
Catch ex As Exception
MsgBox("视频触发失败,请检查" & startmp4file & "\startmp4.mp4是否可用,或在设置页面中关闭启动视频。错误信息::" & ex.ToString, vbExclamation)
' End
End Try
Else
selectedFolder = Path.Combine(path1:=ThemsDirectory, path2:=ninthline)
Try
Dim files() As String = Directory.GetFiles(selectedFolder)
startmp4file514 = selectedFolder & "\startmp4.mp4"
If Enableclicking = "SR" Then
ClickLaunch = selectedFolder & "\startmp41.mp4"
End If
System.Diagnostics.Debug.WriteLine(startmp4file514)
Catch ex As Exception
MsgBox("主题读取失败。 " & secondLine & " 请检查 Thems 文件夹是否为空,或其内部图片是否完好。", vbExclamation)
End Try
Try
If File.Exists(startmp4file514) Then
kdtkyd6666.Source = New Uri(startmp4file514, UriKind.Absolute)
'kdtkyd6666.Play()
Else
MsgBox("视频触发失败,请检查" & startmp4file514 & "\startmp4.mp4是否可用,或在设置页面中关闭启动视频", vbExclamation)
isend114 = False
Close()
End If
Catch ex As Exception
MsgBox("视频触发失败,请检查" & startmp4file514 & "\startmp4.mp4是否可用,或在设置页面中关闭启动视频。错误信息::" & ex.ToString, vbExclamation)
Close()
End Try
End If
If firstLine = "False" And ClickLaunch IsNot Nothing Then
isend114 = False
MsgBox("暂不支持点击后启动与倒计时启动同时启用qwq", vbInformation)
Close()
End If
If firstLine = "False" And ClickLaunch = Nothing Then
countdownstarts()
End If
End Sub
Private Sub kdtkyd6666_MediaEnded() Handles kdtkyd6666.MediaEnded
kdtkyd6666.Stop()
Console.WriteLine("114")
'If firstLine = "True" Then
Try
If ClickLaunch = Nothing Then
If SharedV.StartString = Nothing Then
'MsgBox(line12)
'MsgBox(Startupparameters)
If line12 = "True" Then
Process.Start(secondLine, Startupparameters)
Else
Process.Start(secondLine)
End If
Initiateswindowdetection()
Else
Process.Start(secondLine, """" & SharedV.StartString & """")
Initiateswindowdetection()
End If
Else
'kdtkyd6666_Copy.Visibility = Visibility.Visible
Determinewhetherthevideowasclicked = True
End If
Catch ex As Exception
MsgBox("无法启动 " & secondLine & " 请检查程序路径是否有误。", vbExclamation)
End
End Try
'End If
End Sub
Private Async Sub Initiateswindowdetection()
pollTimer.Interval = TimeSpan.FromSeconds(0.5) ' 设置轮询间隔为1秒
pollTimer.Start() ' 启动计时器
Console.WriteLine("启动监测")
Focus()
Await Task.Delay(Int(Waittime))
Hide()
Close()
End Sub
Private Sub pollTimer_Tick(sender As Object, e As EventArgs) Handles pollTimer.Tick
Topmost = True
Focus()
' 执行轮询
'PollWindowVisible()
'Dim windowTitle As String = "希沃白板"
'Dim windowExists As Boolean = IsWindowExistsByTitle(windowTitle)
'If windowExists Then
' Console.WriteLine("窗口存在")
'Else
' Console.WriteLine("窗口不存在")
'End If
' 查找窗口标题为"希沃白板"的窗口
Dim hWnd As IntPtr = FindWindow(Nothing, starting_config)
Console.WriteLine(starting_config)
If hWnd <> IntPtr.Zero Then
Console.WriteLine("窗口存在,退出")
Ended()
Else
Console.WriteLine("窗口不存在")
End If
End Sub
Private Async Sub countdownstarts()
Await Task.Delay(Int(timewhenthecountdownstarts))
Try
If SharedV.StartString = Nothing Then
If line12 = "True" Then
Process.Start(secondLine, Startupparameters)
Else
Process.Start(secondLine)
End If
Else
Process.Start(secondLine, """" & SharedV.StartString & """")
End If
Catch ex As Exception
MsgBox("无法启动 " & secondLine & " 请检查程序路径是否有误。", vbExclamation)
End
End Try
pollTimer.Interval = TimeSpan.FromSeconds(0.5)
pollTimer.Start()
Console.WriteLine("启动监测")
Focus()
Await Task.Delay(Int(Waittime))
Hide()
Close()
If IsEnded = False Then
Ended()
End If
End Sub
Private Async Sub Ended()
IsEnded = True
Focus()
pollTimer.Stop()
Await Task.Delay(2000)
Hide()
Close()
End
End Sub
Private Sub mp4_Closing(sender As Object, e As CancelEventArgs) Handles Me.Closing
If isend114 Then
e.Cancel = True
End If
End Sub
Private Sub kdtkyd6666_MouseLeftButtonDown(sender As Object, e As MouseButtonEventArgs) Handles kdtkyd6666.MouseLeftButtonDown
Console.WriteLine(Determinewhetherthevideowasclicked)
If Determinewhetherthevideowasclicked Then
Determinewhetherthevideowasclicked = False
If File.Exists(ClickLaunch) Then
Me.Background = New SolidColorBrush(Media.Color.FromRgb(255, 255, 255))
kdtkyd6666_Copy.Visibility = Visibility.Visible
kdtkyd6666_Copy.Source = New Uri(ClickLaunch, UriKind.Absolute)
kdtkyd6666_Copy.Play()
kdtkyd6666.Visibility = Visibility.Hidden
Try
If SharedV.StartString = Nothing Then
If line12 = "True" Then
Process.Start(secondLine, Startupparameters)
Else
Process.Start(secondLine)
End If
'Initiateswindowdetection()
Else
Process.Start(secondLine, """" & SharedV.StartString & """")
'Initiateswindowdetection()
End If
Catch ex As Exception
MsgBox("无法启动 " & secondLine & " 请检查程序路径是否有误。", vbExclamation)
End
End Try
Else
MsgBox("视频触发失败,请检查" & startmp4file514 & "\startmp42.mp4是否可用,或在设置页面中关闭启动视频点击", vbExclamation)
isend114 = False
Close()
End If
End If
End Sub
Private Sub kdtkyd6666_Copy_MediaEnded(sender As Object, e As RoutedEventArgs) Handles kdtkyd6666_Copy.MediaEnded
Initiateswindowdetection()
End Sub
End Class