c# - SetForegroundWindows optional captionName -
i have code, match captionname, don't know do, , how can put regex or maybe other thing, can check captionname want use bringtofront method.. take :
class program { [dlliport("user32.dll")] public static extern int32 setforegroundwindow(int hwnd); [dllimport("user32.dll")] public static extern int findwindow(string lpclassname, string lpwindowname); private static void bringtofront(string classname, string captionname) { setforegroundwindow(findwindow(classname, captionname)); } static void main(string[] args) { bringtofront("notepad","#*#"); } }
try code. can process handle filter process process.getprocesses(), , handle.
invoke setforegroundwindow show them foreground.
class program { [dllimport("user32.dll", setlasterror = true)] static extern bool setforegroundwindow(intptr hwnd); private static void bringtofront(string captionname) { foreach (process p in process.getprocesses() .tolist() .findall(/*write rule here*/p => p.mainwindowtitle.contains(captionname))) { setforegroundwindow(p.mainwindowhandle); } } static void main(string[] args) { bringtofront("notepad"); } }
Comments
Post a Comment