Hi all. I am trying to write simple c# program,but all tutorials and snippets on the net doesn't work for me(I have only very basic knowledge of C#). I come to you guys for help if possible please.
What I am trying to do is send some keystroke to application in the background (The rest of the computer to be usable ) based either on the pid of the application or the name. Here comes the hard part (if based on name) I Would like to open few of the same applications and obviously they will have the same name so the work around that I believe would be just to send the same keys to all windows with that name.
I am posting below my initial code from Python which I know it works, but would love to convert it to C#. Also I would like for the program to have 2 button for start and stop, nothing fancy just the basic form1 app will do. Here is the code:
import win32gui
import win32con
import win32api
from time import sleep
hwndMain = win32gui.FindWindow("Notepad", "test - Notepad")
hwndChild = win32gui.GetWindow(hwndMain, win32con.GW_CHILD)
while(True):
temp = win32api.PostMessage(hwndChild, win32con.WM_CHAR, 0x44, 0)
print(temp)
sleep(1)
What I have tried:
I've tried pretty much every youtube or first page google tutorials, but nothing can do exactly what I described above, please help!