QProcess can't know that you have used it to open some kind of window, don't expect that it'll have an api related to specific applications.
I see two workarounds. First, easy and unreliable, is to call FindWindow winapi procedure, and use returned window handle to bring the window to the front with ShowWindow, so it'll look like:
HWND handle = FindWindow(0,windowTitle); // i'm not sure what will be the title, probably "Document.txt - Notepad" or something
if( ShowWindow(handle,SW_SHOW) ){ qDebug() << "hurray"; }
HWND handle = FindWindow(0,windowTitle); // i'm not sure what will be the title, probably "Document.txt - Notepad" or something
if( ShowWindow(handle,SW_SHOW) ){ qDebug() << "hurray"; }
To copy to clipboard, switch view to plain text mode
Second, more reliable, is to enumerate all opened windows, for each of them check the process id of process which opened the window, and use pid() of the QProcess for comparison. If the window pid equals notepad QProcess pid, you can call ShowWindow, passing the window handle like above:
1) EnumWindows - for "looping" through all opened windows (here you'll get HWND of window)
2) GetWindowThreadProcessId - for getting process id of window
3) PROCESS_INFORMATION structure - this you'll get with QProcess:: pid() (you want to use dwProcessId member)
4) ShowWindow - call it using HWND from 1) if pid from 2) equals pid from 3)
Simple, isn't it ?
Bookmarks