解决方案 »
- DEV TreeList 无选中项
- 小弟刚入门请教大神们一些关于WRK内核的问题
- 用c#开发的office2003程序与office2007程序,代码相同吗?是否能互相兼容
- c# 方法引用问题!!
- “未将对象引用设置到对象的实例”这是为什么?
- 急需帮助!怎样实现在TextBox中限制中文状态下的‘-’字符,谢谢大家了,很急啊!
- 实现处理其他业务逻辑时,改变进度条progressbar的值
- 无法将类型为“System.TimeSpan”的对象强制转换为类型“System.IConvertible”
- C#中调用Oracle存储过程时出现的奇怪的错误,源码,在线等
- 如何获得文本框的值并将其赋值给数据库存储过程的参数以便向表中添加一条记录?
- numericUpDown
- 请问谁用过Sharpdevelop开发过WPF
public static extern bool SetWindowPos(IntPtr hWnd,
int hWndInsertAfter,
int X,
int Y,
int cx,
int cy,
int uFlags
); public static void SetWindowPos(IntPtr hWnd)
{
SetWindowPos(hWnd, -1, 0, 0, 0, 0, 3);
Thread.Sleep(500);
SetWindowPos(hWnd, -2, 0, 0, 0, 0, 3);
}
[System.Runtime.InteropServices.DllImport("user32.dll")]
public static extern bool IsWindowVisible(IntPtr hWnd);
然后设置 SetWindowPos(句柄)
string fileName = filePath.Substring(filePath.LastIndexOf('\\') + 1);
Console.WriteLine("fileName:"+fileName);
string titleName = fileName+" - The KMPlayer";
//取得句柄
IntPtr ParenthWnd = FindWindow(null, titleName);
if (ParenthWnd != IntPtr.Zero)
{
//选中当前的句柄窗口
//SetForegroundWindow(ParenthWnd);
SetWindowPos(ParenthWnd);
Console.WriteLine("暂停");
Thread.Sleep(1000);
SendKeys.SendWait(" ");
}
}我调用这个方法向那个窗口发送一个空格 我这应该怎么写呢 能帮我修改下这个方法吗
如果是窗体接收空格指令 用sendmessage即可
是这样的 我这打开了一个视频播放器 然后想在另外一个面板设置2个按钮 一个播放 一个暂停 来对这个播放器进行操作 暂停我就打算模拟键盘的空格键 在32位系统下 我这程序是没问题的 但是64位下面SetForegroundWindow()这个方法就不能对播放器窗口激活 导致SendKeys.SendWait(" ");没办法执行
private void ClickCharKey2(IntPtr hwnd, char key)
{
SystemApi.SendMessage(hwnd, SystemApi.WM_KEYDOWN, key, 0);
Thread.Sleep(500);
SystemApi.SendMessage(hwnd, SystemApi.WM_KEYUP, key, 0);
}
public const int WM_KEYDOWN = 0x0100;
public const int WM_KEYUP = 0x0101;
public const int WM_CHAR = 0x0102;
public const int WM_IME_KEYDOWN = 0x0290;//适用于tab键
DllImport("user32.dll", EntryPoint = "SendMessage")]
public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);