c# - system.windows.forms.sendkeys.sendwait not working when window is maximize -
i sending keystrokes other running application using sendkeys.sendwait
. not working if target application not minimize. wrong method? other methods send keystrokes running application.
code block using:
setforegroundwindow(handletoapplication); system.windows.forms.sendkeys.sendwait(keystroke);
i suggest manipulating window prior sending keys it...
private void setwindowstate(string windowtitle, int option) { /** sw_hide 0 sw_shownormal 1 sw_normal 1 sw_showminimized 2 sw_showmaximized 3 sw_maximize 3 sw_shownoactivate 4 sw_show 5 sw_minimize 6 sw_showminnoactive 7 sw_showna 8 sw_restore 9 sw_showdefault 10 sw_forceminimize 11 sw_max 11 **/ process[] plist = process.getprocesses(); intptr handle = new intptr(); foreach (process x in plist) { if (x.mainwindowtitle == windowtitle) { handle = x.mainwindowhandle; break; } } showwindow(handle, option); }
Comments
Post a Comment