i starting executable several times this
process proc = new process(); proc.startinfo.filename = path + "/builtgame.exe"; proc.start(); process proc1 = new process(); proc1.startinfo.filename = path + "/builtgame.exe"; proc1.start(); now want resize , move spawned windows.
i using movewindow , findwindow
[dllimport("user32.dll", setlasterror = true)] internal static extern bool movewindow(intptr hwnd, int x, int y, int nwidth, int nheight, bool brepaint); [dllimport("user32.dll", setlasterror = true)] internal static extern intptr findwindow(string windowclass, string title); initially thought use handle spawned process
movewindow(proc.handle, 0, 0, 100, 100, true); but didn't work , tried use findwindow
intptr handle = findwindow(null,"mywindowtitle") which indeed worked , returned handle findwindow different 1 process.handle
after tried use
movewindow(proc.mainwindowhandle, 0, 0, 100, 100, true); but mainwindowhandle 0.
the problem have want start multiple processes , correct window handle each window findwindow returns first one.
how this?
call enumwindows enumerate top-level windows. each such window, call getwindowtext find out text can compare against target value.
if looking windows in specific process, use getwindowthreadprocessid.
Comments
Post a Comment