Tag: sendkeys

背景键按下监听器

我有一个简单的窗口forms应用程序,当我按空格键时打开大写锁定,如果我按下一个字母则将其关闭。 问题是我必须专注于窗口才能工作(最顶层也不起作用,最顶层不会只关注它只显示窗口高于其他所有未聚焦的窗口)。 任何人都知道即使我在记事本中写作,我怎么能让它工作?

使用.NET 4.5.2从C#代码更改键盘布局

我正在编写我的SDL Trados Studio插件。 插件的最后一部分需要一些API完全没有公开的自动化,所以我所拥有的(保持某些东西)是自动化默认的键盘快捷键。 我的代码完全适用于英文键盘布局(以及匈牙利语!),但它当然不适用于希腊语,俄语等等。 我一直在寻找解决方案,但直到现在我都找不到它,不是在网上也不是在SO上,比如这篇文章: 通过代码改变键盘布局c# 我需要将键盘布局更改为英语,以便它可以采用正确的快捷键(和其他字符串)。 然后我需要将其切换回之前的状态。 我正在使用非常有限的API,因此我只有SendKeys我使用。 这是工作代码: //Save the document SendKeys.SendWait(“^s”); //Open files view SendKeys.SendWait(“%v”); SendKeys.SendWait(“i”); SendKeys.SendWait(“1”); Application.DoEvents(); //get url and credentials from a custom input form string[] psw = UploadData.GetPassword( Settings.GetValue(“Upload”, “Uri”, “”), Vars.wsUsername == null ? Settings.GetValue(“Upload”, “User”, “”) : Vars.wsUsername, Vars.wsPassword == null ? “” : Vars.wsPassword ); […]

.NET sendkeys到计算器

下面的sendkeys代码适用于记事本,但它不适用于计算器。 问题是什么? (与我发送的.NET程序中的Sendkeys问题相比,这是另一个问题) [DllImport(“user32.dll”, CharSet = CharSet.Unicode)] public static extern IntPtr FindWindow(string lpClassName,string lpWindowName); [DllImport(“User32”)] public static extern bool SetForegroundWindow(IntPtr hWnd); private void button1_Click(object sender, EventArgs e) { IntPtr calculatorHandle = FindWindow(“SciCalc”, “Calculator”); //IntPtr calculatorHandle = FindWindow(“Notepad”, “Untitled – Notepad”); if (calculatorHandle == IntPtr.Zero) { MessageBox.Show(“Calculator is not running.”); return; } SetForegroundWindow(calculatorHandle); System.Threading.Thread.Sleep(1000); SendKeys.SendWait(“111*11=”); //SendKeys.SendWait(“{ENTER}”); […]

使用RegisterHotKey检测Ctrl + V但不截取它

我需要检测用户何时按下Ctrl + V (无论窗口焦点如何 – 我的应用程序可能会被最小化)但我不能停止实际的粘贴操作。 我尝试了一些事情:(我成功绑定了RegisterHotKey的键击) 我有: protected override void WndProc(ref Message m) { if (m.Msg == 0x312) hotKey(); base.WndProc(ref m); } 我尝试过以下方法: void hotKey() { SendKeys.SendWait(“^v”); //just puts ‘v’ instead of clipboard contents } 和 void hotKey() { SendKeys.SendWait(ClipBoard.GetText()); /* This works, but since Ctrl is still down, it triggers * all the […]

使表格无法在C#中聚焦

我想写一个虚拟键盘,就像触摸屏电脑的Windows屏幕键盘一样。 但我的虚拟键盘问题正在从使用的应用程序中窃取焦点。 即使用户点击它,Windows屏幕键盘也会将焦点集中在当前应用程序上。 有没有办法在C#中使用Windows窗体做同样的事情? 我现在唯一能做的就是将键盘事件发送到特定的应用程序,例如以下代码中的记事本。 如果我可以使表单不可聚焦,我可以使用GetForegroundWindow获取当前聚焦窗口。 [DllImport(“USER32.DLL”, CharSet = CharSet.Unicode)] public static extern IntPtr FindWindow(string lpClassName,string lpWindowName); [DllImport(“USER32.DLL”)] public static extern bool SetForegroundWindow(IntPtr hWnd); private void button1_Click(object sender, EventArgs e) { IntPtr calculatorHandle = FindWindow(“notepad”, null); SetForegroundWindow(calculatorHandle); SendKeys.SendWait(“111”); } 有没有办法可以做到这一点? 有没有更好的方法让表格将键盘事件发送到正在使用的应用程序? 谢谢!!

适用于Citrix的SendKeys替代方案

我最近为客户开发了一个虚拟键盘应用程序。 该程序几乎适用于所有程序,但某些命令如{ENTER}或{DEL}不适用于Citrix。 是否有解决方法或替代SendKeys ? 编辑1:我尝试了SendInput方法(Windows输入模拟器使用SendInput),DEL键和箭头键仍然无法正常工作。 然而,ENTER键有效。 编辑2:解决了它。 测试了两个不同版本的Citrix。 这个问题给了我很多帮助。 : Citrix瘦客户机使用keybd_event的扫描码参数,即使MS表示它未使用且应为0.您还需要提供物理扫描码以供Citrix客户端使用。 Citrix客户端也存在使用SendInput API生成的键盘输入的主要问题。 我修补了Windows输入模拟器中的代码: // Function used to get the scan code [DllImport(“user32.dll”)] static extern uint MapVirtualKey(uint uCode, uint uMapType); /// /// Calls the Win32 SendInput method … /// /// The VirtualKeyCode to press public static void SimulateKeyPress(VirtualKeyCode keyCode) { var down = new INPUT(); […]

C#模拟按键

我正在寻找一种模拟在C#中按下右Ctrl键的方法,它必须是正确的。 我知道这可以为左边的一个做,但我找不到合适的东西。 这样我就可以模拟手动触发的bsod按键。 谢谢

使用SendKeys发送Windows密钥

我正在研究C#中的快捷方式。 我成功使用SendKeys实现了Ctrl,Alt和Shift。 像这样; Ctrl + C : System.Windows.Forms.SendKeys.SendWait(“^c”); 或Alt + F4 : System.Windows.Forms.SendKeys.SendWait(“%{F4}”); 但是我不能用SendKeys发送“Windows Key”。 我试过ex: Win + E : .SendWait(“#e”)但它不起作用。 我应该使用什么而不是“#”? 谢谢。