16,721
社区成员




Imports System.ComponentModel
Imports System.IO
Imports System.Threading
Public Class Form1
Declare Function GetDC Lib "user32" Alias "GetDC" (ByVal hwnd As Int32) As Int32
'获取窗体标题
'Public Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Int32, ByVal lpString As String, ByVal cch As Int32) As Int32
'Public Declare Function IsWindowVisible Lib "user32" (ByVal hwnd As Int32) As Int32
'Public Declare Function GetWindow Lib "user32" (ByVal hwnd As Int32, ByVal wCmd As Int32) As Int32
'获取位置上的窗体句柄
Declare Function WindowFromPoint Lib "user32" Alias "WindowFromPoint" (ByVal xPoint As Int32, ByVal yPoint As Int32) As Int32
'获取窗体大小
Declare Function GetWindowRect Lib "user32" Alias "GetWindowRect" (ByVal hwnd As Int32, ByRef lpRect As RECT) As Int32
'设置窗体大小
Declare Function SetWindowPos Lib "user32" Alias "SetWindowPos" (ByVal hwnd As Int32, ByVal hWndInsertAfter As Int32, ByVal x As Int32, ByVal y As Int32, ByVal cx As Int32, ByVal cy As Int32, ByVal wFlags As Int32) As Int32
'位置结构
Public Structure RECT
Public Left As Integer
Public Top As Integer
Public Right As Integer
Public Bottom As Integer
End Structure
Dim packFlash1 As AxDIRECTORSHOCKWAVELib.AxShockwaveCtl
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'设置控制系统列表格式
ListView1.View = View.Details
ListView1.GridLines = True
ListView1.FullRowSelect = True
ListView1.CheckBoxes = False
ListView1.Clear()
ListView1.Columns.Add("FLASH文件", 500, HorizontalAlignment.Left)
packFlash1 = New AxDIRECTORSHOCKWAVELib.AxShockwaveCtl
packFlash1.Location = New Point(500, 20)
packFlash1.Width = Me.Width - 500 - 20
packFlash1.Height = Me.Height - 20 - 45
packFlash1.Anchor = AnchorStyles.Left Or AnchorStyles.Right Or AnchorStyles.Top Or AnchorStyles.Bottom
'packFlash1.PerformAutoScale()
Me.Controls.Add(packFlash1)
Dim dirs As String() = Directory.GetFiles("C:\Users\wk950\Desktop\鼠标模拟\FLASH", "*.swf")
ListView1.Items.Clear()
For i As Integer = 0 To dirs.Count - 1
ListView1.Items.Add($"{dirs(i)}", 0)
Next
End Sub
'Dim playProcessHwnd As Process = Nothing
'Private Sub ListView1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ListView1.SelectedIndexChanged
' If ListView1.SelectedItems.Count = 0 Then
' Exit Sub
' End If
' 'packFlash1.SAlign = 1
' 'packFlash1.ScaleMode = 2
' 'packFlash1.swURL = ListView1.SelectedItems(0).Text
' packFlash1.Stop()
' packFlash1.GotoMovie(ListView1.SelectedItems(0).Text)
' packFlash1.Play()
' 'Me.Text = packFlash1.AutoStart
' 'packFlash1.Movie = ListView1.SelectedItems(0).Text
' 'If playProcessHwnd Is Nothing Then
' ' '第一次打开
' 'ElseIf playProcessHwnd.HasExited = True Then
' ' '中途被关闭了
' 'Else
' ' playProcessHwnd.Kill()
' 'End If
' 'MsgBox($"{Application.StartupPath}\PotPlayer\PotPlayerMini64.exe {ListView1.SelectedItems(0).Text}")
' 'Dim newPlayProcessHwnd As Process = Process.Start($".\PotPlayer\PotPlayerMini64.exe", $"{ListView1.SelectedItems(0).Text}")
' 'Dim newPlayProcessHwnd As Process = Process.Start($".\KenPlayer\KenPlayer.exe", $"{ListView1.SelectedItems(0).Text}")
' 'If playProcessHwnd Is Nothing Then
' ' '第一次打开
' ' playProcessHwnd = newPlayProcessHwnd
' 'ElseIf playProcessHwnd.HasExited = True Then
' ' '中途被关闭了
' ' playProcessHwnd = newPlayProcessHwnd
' 'End If
' 'Dim windowRect As RECT
' 'GetWindowRect(playProcessHwnd.MainWindowHandle, windowRect)
' 'Me.Text = $"{windowRect.Left} {windowRect.Top} {windowRect.Right} {windowRect.Bottom}"
' 'SetWindowPos(playProcessHwnd.MainWindowHandle, -1, 200, 200, 168, 84, 0)
'End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
FolderBrowserDialog1.SelectedPath = ""
FolderBrowserDialog1.ShowDialog()
If FolderBrowserDialog1.SelectedPath = "" Then
Exit Sub
End If
Dim dirs As String() = Directory.GetFiles(FolderBrowserDialog1.SelectedPath, "*.swf")
ListView1.Items.Clear()
For i As Integer = 0 To dirs.Count - 1
ListView1.Items.Add($"{dirs(i)}", 0)
Next
End Sub
Private Sub Form1_Closing(sender As Object, e As CancelEventArgs) Handles Me.Closing
'Try
' playProcessHwnd.CloseMainWindow()
'Catch ex As Exception
'End Try
End Sub
Private Sub ListView1_DoubleClick(sender As Object, e As EventArgs) Handles ListView1.DoubleClick
If ListView1.SelectedItems.Count = 0 Then
Exit Sub
End If
Me.Text = ListView1.SelectedItems(0).Text
'packFlash1.Stop()
packFlash1.GotoMovie(ListView1.SelectedItems(0).Text)
‘文件绝对路径,但还是空白无内容
packFlash1.Play()
End Sub
End Class
Private K As New AxShockwaveFlashObjects.AxShockwaveFlash
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
openDLG.Filter = "flash文件|*.swf"
If openDLG.ShowDialog = Windows.Forms.DialogResult.OK Then
K.LoadMovie(0, openDLG.FileName)
TrackBar1.Minimum = 1
TrackBar1.Maximum = K.TotalFrames
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
K.Play()
End Sub
我用的LOADMOVIE没问题