Directly sending keystrokes to another process via hooking

This is a little code that allows you to send message to a backgrounded application. To send the “A” char for example, simply call sendKeystroke(Keys.A), and don’t forget to use namespace System.windows.forms to be able to use the Keys object. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Runtime.InteropServices; using System.Windows.Forms; namespace keybound { … Read more

sendMessage from extension background or popup to content script doesn’t work

In your background page you should call chrome.tabs.query({active: true, currentWindow: true}, function(tabs){ chrome.tabs.sendMessage(tabs[0].id, {action: “open_dialog_box”}, function(response) {}); }); instead of using chrome.extension.sendMessage as you currently do. The chrome.tabs variant sends messages to content scripts, whereas the chrome.extension function sends messages to all other extension components.

Send Message in C#

public static extern int FindWindow(string lpClassName, String lpWindowName); In order to find the window, you need the class name of the window. Here are some examples: C#: const string lpClassName = “Winamp v1.x”; IntPtr hwnd = FindWindow(lpClassName, null); Example from a program that I made, written in VB: hParent = FindWindow(“TfrmMain”, vbNullString) In order to … Read more

How do I send key strokes to a window without having to activate it using Windows API?

Alright, this is kind of disappointing I’m sure, but you fundamentally cannot do this with 100% reliability. Windows assumes that the active window is the one getting keyboard input. The proper way to fake keyboard input is with SendInput, and you’ll notice that it sends messages to the active window only. That being said, you … Read more