external - C# SendMessage Without knowing TextBox ID -
i'm trying send string external program, have sample program of working with, not know actual textbox ids end being. quite problematic.
what program does, allow user click button, paste text onto external program. works fine using sendkeys. asked create hotkeys allow person keystroke , equivalent of pressing button.
i have hotkeys down, however, when person uses hotkey, ends sending message several times. i've narrowed down being sendkeys function, , i've tried using sendmessage, won't know textbox id, can tell, it's not viable option. here have sendkeys code.
private void focusprocess(string procname, string message, bool hotkeyed) { process[] objprocesses = process.getprocessesbyname(procname); if (autopasteon.checked || tofronton.checked) { foreach (process currentproc in objprocesses) { intptr hwnd = intptr.zero; hwnd = currentproc.mainwindowhandle; showwindowasync(new handleref(null, hwnd), sw_restore); setforegroundwindow(hwnd); if (autopasteon.checked) { sendkeys.send(message); } if (tofrontoff.checked) { setforegroundwindow(mainprog); setwindowpos(hwnd, hwnd_bottom, 0, 0, 0, 0, swp_nosize | swp_nomove | swp_noactivate); } } } }
it works pulling other process front, sending message, , sending back. i'm registering hotkeys using setwindowshookex library, , works fine. problem sending message using hotkey. works, ton of times. i've placed checks make paste @ maximum of 4 times/sec. around 10-20 times/sec. i've varified code executed once every quarter second, sendkeys still messing up.
Comments
Post a Comment