1

Is there a way to detect when a windows process is waiting for user input.

For instance, when you click on a particular program it loads, in this case the program's process is probably in loading state rite?

what happens when the program is fully loaded and is waiting for user input to procedure to next step. Is there a way to detect this?

Cheers

Paktrick
  • 43
  • 3

1 Answers1

1

Call WaitForInputIdle with a handle to a process. it will suspend execution until the program completes its initialization and is waiting for user input with no input pending.

Hasturkun
  • 35,395
  • 6
  • 71
  • 104
  • It does not return any boolean values, so how can i detect whether the process provided is waiting for user input? – Paktrick Aug 02 '11 at 11:57
  • @Paktrick: It returns `0` for success, `WAIT_FAILED` or `WAIT_TIMEOUT` otherwise (the latter only possible if timeout wasn't `INFINITE`). – Hasturkun Aug 02 '11 at 12:00
  • so if the output is 0, this should mean the process provided is loaded? – Paktrick Aug 02 '11 at 12:01
  • hey is it possible to pass process id instead of handle? because i have to map this functions in jna. java native access – Paktrick Aug 02 '11 at 12:23
  • @Paktrick: You should be able to get a handle via [`OpenProcess`](http://msdn.microsoft.com/en-us/library/ms684320(VS.85).aspx). Don't forget to close it later with `CloseHandle` though – Hasturkun Aug 02 '11 at 14:15