matrix_aash
asked on
If application is active
Hi
I am writing a program that sends keys to an application. So i need an if statement that says If notepad is active, run this code. Otherwise it will be sending keys when i'm doing anything!
Thanks!
I am writing a program that sends keys to an application. So i need an if statement that says If notepad is active, run this code. Otherwise it will be sending keys when i'm doing anything!
Thanks!
ASKER
This is got an in-game thing so send keys is the only way unless you know the API for the game which is unlikley. Is there an if statement that checks to see if it is activated?
Depends. Could be done with Win32 API depending on how you are tracking the notepad window... How is notepad being run in the first place? Does it have a window caption we can track? Could there be more than one notepad window?
And why is AppActivate not appropriate rather than checking to see if the window is active?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Nice. :)
ASKER
Thanks mate!
Dim ProcessID As Integer = Shell("Notepad.exe", AppWinStyle.NormalFocus)
AppActivate(ProcessID) 'Also takes window text, like "Untitled - Notepad"
SendKeys.Send("This is a test")