GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 07-Sep-2005, 23:22
patito patito is offline
New Member
 
Join Date: Sep 2005
Posts: 1
patito is on a distinguished road

little help with a simple program


hi,

im looking for a little help sending keystrokes to an especific window, so far my code is:
CPP / C++ / C Code:
#include <windows.h>

   int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow) {

char message[100];
int handle;

handle=FindWindow("window title", NULL);
		PostMessage(handle, WM_QUIT, 0, 0); 

}
this code works very good to close a lot of running programs that i have tried,but now i found one that is not closing after using that,it just gives me an error and locks the computer.

that program closes very well using ctrl+alt+del,so im looking for some code example to be able to send that key combination to the program i want to close.

any help will be preciated,thanks in advance.
Last edited by dsmith : 08-Sep-2005 at 07:41. Reason: Please use [c] & [/c] when posting C code
  #2  
Old 08-Sep-2005, 08:15
kobi_hikri's Avatar
kobi_hikri kobi_hikri is offline
Regular Member
 
Join Date: Apr 2005
Location: Israel
Posts: 431
kobi_hikri has a spectacular aura aboutkobi_hikri has a spectacular aura about
Quote:
Originally Posted by patito
im looking for a little help sending keystrokes to an especific window

Hey,
My friend wrote some code to do exactly that task some years ago, but he wrote his application in x86 assembly.
I wrote an application that does the job and works with Girder (an infrared application that allows sending keystrokes to applications just as you mentioned) but I had the problem of "highlighting" the requiered window (I can see you managed to overcome that problem).

I'll try to write something as this task interests me too, and will be a part of my operating system project. I'll post my results.

Best regards,
Kobi Hikri.
  #3  
Old 08-Sep-2005, 08:24
WaltP's Avatar
WaltP WaltP is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Midwest US
Posts: 3,373
WaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to all
Quote:
Originally Posted by patito
this code works very good to close a lot of running programs that i have tried,but now i found one that is not closing after using that,it just gives me an error and locks the computer.
You will need to figure out what's different about the program that won't close. It's probably hooked into the system differently than a normal program.
__________________

The 3 Laws of the Procrastination Society:
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
  #4  
Old 08-Sep-2005, 08:40
kobi_hikri's Avatar
kobi_hikri kobi_hikri is offline
Regular Member
 
Join Date: Apr 2005
Location: Israel
Posts: 431
kobi_hikri has a spectacular aura aboutkobi_hikri has a spectacular aura about
Quote:
Originally Posted by WaltP
You will need to figure out what's different about the program that won't close. It's probably hooked into the system differently than a normal program.

I think the application you are trying to close has a thread (which the application starts when it is called) that monitors it's status.
I think so because that is what I would do if I considered a process "critical" and wanted it to run as long as the system runs.
Excuse me for asking, but can you share the name of the application you are having problems with ?

Kobi Hikri.
 
 

Recent GIDBlogVista ?Widgets? on Windows XP by LocalTech

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[TUTORIAL] Calling an external program in C (Linux) dsmith C Programming Language 4 22-Apr-2005 13:30
Help with simple math table program (was a SIMPLE program) Bubba C Programming Language 3 09-Mar-2005 12:40
Help with a simple program matthewbarr C Programming Language 3 10-Feb-2005 10:08
Help with a simple program. bluedragon27 C Programming Language 1 16-Nov-2004 15:40

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 20:24.


vBulletin, Copyright © 2000 - 2010, Jelsoft Enterprises Ltd.