模拟键盘操作Windows应用程序

简介: 这是针对Windows系统录音软件的小程序 目的是把声音文件的频率转换的低一些 尝试过用WINDOWS API来做这个事,结果失败了 最后还是用程序操作EXE文件完成工作的   代码 using System;using System.

这是针对Windows系统录音软件的小程序

目的是把声音文件的频率转换的低一些

尝试过用WINDOWS API来做这个事,结果失败了

最后还是用程序操作EXE文件完成工作的

 

img_1c53668bcee393edac0d7b3b3daff1ae.gif img_405b18b4b6584ae338e0f6ecaf736533.gif 代码
 
  
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Diagnostics;
using System.Threading;

namespace ShengYin2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
folderBrowserDialog1.ShowNewFolderButton
= false ;
}

private void button1_Click( object sender, EventArgs e)
{
DialogResult dr
= folderBrowserDialog1.ShowDialog();
if (dr == DialogResult.OK)
{
label1.Text
= " 路径: " + folderBrowserDialog1.SelectedPath;
}
}

private void button2_Click( object sender, EventArgs e)
{
Process myProc
= new Process();
myProc.StartInfo.FileName
= @" C:\wINDOWS\system32\sndrec32.exe " ;
myProc.StartInfo.UseShellExecute
= false ;
myProc.StartInfo.RedirectStandardInput
= true ;
myProc.Start();
DirectoryInfo di
= new DirectoryInfo(folderBrowserDialog1.SelectedPath);
FileInfo[] fis
= di.GetFiles();
foreach (var a in fis)
{
if (a.Extension.Contains( " wav " ))
{
Thread.Sleep(
600 );
SendKeys.SendWait(
" %f " );
Thread.Sleep(
600 );
SendKeys.SendWait(
" o " );
Thread.Sleep(
600 );
SendKeys.SendWait(a.FullName);
Thread.Sleep(
600 );
SendKeys.SendWait(
" {Enter} " );
Thread.Sleep(
600 );
SendKeys.SendWait(
" %f " );
Thread.Sleep(
600 );
SendKeys.SendWait(
" a " );
Thread.Sleep(
600 );
SendKeys.SendWait(
" %c " );
Thread.Sleep(
600 );
SendKeys.SendWait(
" {Down} " );
Thread.Sleep(
600 );
SendKeys.SendWait(
" {Down} " );
Thread.Sleep(
600 );
SendKeys.SendWait(
" {Enter} " );
Thread.Sleep(
600 );
SendKeys.SendWait(
" {Enter} " );
Thread.Sleep(
600 );
SendKeys.SendWait(
" {Enter} " );
}
}
myProc.Close();
MessageBox.Show(
" 转换完成 " );
}
}
}

 

目录
相关文章
|
14小时前
|
编解码 Windows
LabVIEW应用程序在Windows版本之间的字体变化
LabVIEW应用程序在Windows版本之间的字体变化
|
4天前
|
存储 安全 搜索推荐
Windows之隐藏特殊文件夹(自定义快捷桌面程序)
Windows之隐藏特殊文件夹(自定义快捷桌面程序)
|
8天前
|
Windows
Windows 程序自启动实现方法详解
Windows 程序自启动实现方法详解
24 0
|
1月前
|
消息中间件 编译器 API
Windows窗口程序
Windows窗口程序
|
1月前
|
编译器 C语言 C++
|
1月前
|
C# Windows
.NET开源免费的Windows快速文件搜索和应用程序启动器
今天大姚给大家分享一款.NET开源(MIT License)、免费、功能强大的Windows快速文件搜索和应用程序启动器:Flow Launcher。
|
1月前
|
人工智能 机器人 C++
【C++/Python】Windows用Swig实现C++调用Python(史上最简单详细,80岁看了都会操作)
【C++/Python】Windows用Swig实现C++调用Python(史上最简单详细,80岁看了都会操作)
|
2月前
|
Windows
实现Windows程序的数据更新
实现Windows程序的数据更新
13 0
|
2月前
|
Windows
构建布局良好的Windows程序
构建布局良好的Windows程序
11 0
|
2月前
|
C# Windows
初识Windows程序
初识Windows程序
11 0

热门文章

最新文章