-
February 12th, 2013, 10:54 PM
#1
How to check thread with MFC ?
I use MFC Find console window and send key to console like this.
Code:
HWND w;
w = FindWindow(NULL, L"c:\\users\\pkru\\documents\\visual studio 2010\\Projects\\CleanVirus\\Debug\\CleanVirus.exe");
if(w==NULL)
MessageBox(NULL,_T("Not Found"), _T("OK"), MB_OK);
else{
DWORD dwProcessId = 0;
GetWindowThreadProcessId( ::GetDesktopWindow(),
&dwProcessId );
while(TRUE){
//if(w!=NULL){
//MessageBox(NULL,_T("Found"), _T("OK"), MB_OK);
ir[0].EventType = KEY_EVENT;
ir[0].Event.KeyEvent.bKeyDown = TRUE;
ir[0].Event.KeyEvent.dwControlKeyState = 0;
ir[0].Event.KeyEvent.uChar.UnicodeChar = 'y';
ir[0].Event.KeyEvent.wRepeatCount = 1;
ir[0].Event.KeyEvent.wVirtualKeyCode = 'Y';
ir[0].Event.KeyEvent.wVirtualScanCode = MapVirtualKey('Y', MAPVK_VK_TO_VSC);
ir[1].EventType = KEY_EVENT;
ir[1].Event.KeyEvent.bKeyDown = TRUE;
ir[1].Event.KeyEvent.dwControlKeyState = 0;
ir[1].Event.KeyEvent.uChar.UnicodeChar = VK_RETURN;
ir[1].Event.KeyEvent.wRepeatCount = 1;
ir[1].Event.KeyEvent.wVirtualKeyCode = VK_RETURN;
ir[1].Event.KeyEvent.wVirtualScanCode = MapVirtualKey(VK_RETURN, MAPVK_VK_TO_VSC);
ir[2].EventType = KEY_EVENT;
ir[2].Event.KeyEvent.bKeyDown = FALSE;
ir[2].Event.KeyEvent.dwControlKeyState = 0;
ir[2].Event.KeyEvent.uChar.UnicodeChar = VK_RETURN;
ir[2].Event.KeyEvent.wRepeatCount = 1;
ir[2].Event.KeyEvent.wVirtualKeyCode = VK_RETURN;
ir[2].Event.KeyEvent.wVirtualScanCode = MapVirtualKey(VK_RETURN, MAPVK_VK_TO_VSC);
dwTmp = 0;
WriteConsoleInput(hConIn, ir, 3, &dwTmp);
Sleep( 1000 );
}
FreeConsole();
}
After program process success in console it not close console windows but it show like this in Output
The thread 'Win32 Thread' (0x1300) has exited with code 0 (0x0).
I think if I can check when VC will show this line, then I can use FreeConsole(); for close console windows.
-
February 12th, 2013, 11:38 PM
#2
Re: How to check thread with MFC ?
What app launches CleanVirus.exe? If your process is launching it, try to launch it with the /c switch.
E.g.
Code:
C:\>"c:\users\pkru\documents\visual studio 2010\Projects\CleanVirus\Debug\CleanVirus.exe" /c
-
February 12th, 2013, 11:52 PM
#3
Re: How to check thread with MFC ?
C:\>"c:\users\pkru\documents\visual studio 2010\Projects\CleanVirus\Debug\CleanVirus.exe"
is my project name in VC which FindWindow() read title from
DWORD WINAPI unhidden(LPVOID lp)
{
system("C:/unhidden.bat");
return 0;
}
And the code unhidden.bat is
@echo off
N:
Unhidden.exe
I try to use Unhidden.exe /c but it not close console window
when process success it show like this in console. it not close console windows.
Process complete !
Press any key to continue . . .
-
February 13th, 2013, 04:28 AM
#4
Re: How to check thread with MFC ?
Originally Posted by mmc01
I try to use Unhidden.exe /c but it not close console window
when process success it show like this in console. it not close console windows.
If you run your program from VS with F5, you are not able to avoid being given with "Press any key to continue..." This is how VS works, and this has nothing to do with your code.
Best regards,
Igor
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|