For NSGaga:
string windowName = "Open Broadcaster Software v0.472b"; IntPtr outerPtr = FindWindow(null, windowName); IntPtr ptrOBS = (IntPtr)527814;//button that im trying to trigger keypress on SetForegroundWindow(outerPtr); SetForegroundWindow(ptrOBS); SetFocus(outerPtr, "OBSWindowClass");//SetFocus(ptrOBS, "Button"); const UInt32 WM_CHAR = 0x0102; const int VK_R = 0x52; // taken from http://msdn.microsoft.com/en-us/library/dd375731(v=vs.85).aspx const int VK_S = 0x53; //SetForegroundWindow(ptrOBS); System.Threading.Thread.Sleep(3000); SendKeys.SendWait("{r}"); SendMessage(outerPtr, WM_KEYDOWN, (IntPtr)VK_R, (IntPtr)1); PostMessage(outerPtr, WM_KEYDOWN, VkKeyScan('r'), 0);