嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 2 元微信扫码支付:2 元
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
简单封装scrcpy电脑usb操作手机的简单应用(适用Android、HarmonyOS、ColorOS等等)
这一篇主要介绍简单封装scrcpy的简单应用,可点击电脑屏幕操作手机。
此方式兼容性较好,适用于Android、HarmonyOS、ColorOS等等兼容安卓的所有系统,苹果除外。有时间了写写Apple。
有空了把设置脚本加上去,在电脑上刷金币视频、刷直播间评论等等,这些功能实现起来很简单,查百度可完成全部功能。
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Threading;
using System.Windows.Forms;
namespace p_Demo3
{
public partial class Form1 : Form
{
private Process stdoutProcess = null;
private const int SW_HIDE = 0;
private const int SW_RESTORE = 9;
public Form1()
{
InitializeComponent();
this.StartPosition = FormStartPosition.Manual;
this.FormBorderStyle = FormBorderStyle.FixedSingle;
this.LocationChanged = Form1_LocationChanged;
this.FormClosed = Form1_FormClosed;
}
[DllImport("user32.dll", EntryPoint = "FindWindow")]
private extern static IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll")]
public static extern int ShowWindow(int hwnd, int nCmdShow);
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern int SendMessage(int hWnd, int msg, int wParam, int lparam);
[System.Runtime.InteropServices.DllImportAttribute("user32.dll", EntryPoint = "MoveWindow")]
public static extern bool MoveWindow(System.IntPtr hWnd, int X, int Y, int nWidth, int nHeight, bool bRepaint);
private void Form1_LocationChanged(object sender, EventArgs e)
{
if (stdoutProcess != null)
{
MoveWindow(stdoutProcess.MainWindowHandle, this.Location.X 30, this.Location.Y 80, 500, 760, true);
}
}
private void button1_Click(object sender, EventArgs e)
{
stdoutProcess = new Process();
stdoutProcess.StartInfo.FileName = @"App\scrcpy.exe";
stdoutProcess.StartInfo.Arguments = $"--always-on-top --window-title=SQK(my)-Demo --window-borderless --window-width=500 --window-height=760 --window-x=" (this.Location.X 30) " --window-y=" (this.Location.Y 80);
stdoutProcess.StartInfo.UseShellExecute = false;
stdoutProcess.StartInfo.RedirectStandardOutput = true;
stdoutProcess.StartInfo.CreateNoWindow = true;
stdoutProcess.Start();
}
// 关闭程序
private void Form1_FormClosed(object sender, FormClosedEventArgs e)
{
IntPtr hwnd = FindWindow(null, "SQK(my)-Demo");
SendMessage((int)hwnd, 0x0010, 0, 0);
Kill_Process("adb");
}
/// 删除进程
private void Kill_Process(string processName)
{
foreach (Process p in Process.GetProcesses())
{
if (p.ProcessName.Contains(processName))
{
try
{
p.Kill();
p.WaitForExit();
}
catch { }
}
}
}
}
}
.
├── p_Demo3
│ ├── p_Demo3
│ │ ├── App.config
│ │ ├── Form1.Designer.cs
│ │ ├── Form1.cs
│ │ ├── Form1.resx
│ │ ├── Program.cs
│ │ ├── Properties
│ │ │ ├── AssemblyInfo.cs
│ │ │ ├── Resources.Designer.cs
│ │ │ ├── Resources.resx
│ │ │ ├── Settings.Designer.cs
│ │ │ └── Settings.settings
│ │ ├── bin
│ │ │ └── Debug
│ │ │ ├── App
│ │ │ │ ├── AdbWinApi.dll
│ │ │ │ ├── AdbWinUsbApi.dll
│ │ │ │ ├── SDL2.dll
│ │ │ │ ├── adb.exe
│ │ │ │ ├── avcodec-58.dll
│ │ │ │ ├── avformat-58.dll
│ │ │ │ ├── avutil-56.dll
│ │ │ │ ├── icon.png
│ │ │ │ ├── scrcpy-console.bat
│ │ │ │ ├── scrcpy-noconsole.vbs
│ │ │ │ ├── scrcpy-server
│ │ │ │ ├── scrcpy.exe
│ │ │ │ ├── swresample-3.dll
│ │ │ │ └── swscale-5.dll
│ │ │ ├── p_Demo3.exe
│ │ │ ├── p_Demo3.exe.config
│ │ │ └── p_Demo3.pdb
│ │ ├── obj
│ │ │ └── Debug
│ │ └── p_Demo3.csproj
│ └── p_Demo3.sln
└── 简单封装scrcpy电脑usb操作手机的简单应用(适用Android、HarmonyOS、ColorOS等等).rar
8 directories, 30 files