Controlsend keys [to not active window]
I understand that i cant use SendKeys.SendWait("sampletext") to send keys to not active window. is there any other way can I do this?
Code:
Dim ProcID As Integer
ProcID = Shell("notepad.EXE")
ControlSend ( "title", controlID, "string"
title - The title of the window to access.
controlID - Send text to the 1st Edit control in the Notepad window
String - of characters to send to the control.
ControlSend("Untitled - Notepad", "Edit1", "sampletext"
ControlSend("Untitled - Notepad", "[CLASSNN:Edit1]", "sampletext")
ControlSend("Untitled - Notepad", "[CLASS:Edit; INSTANCE:1]", "sampletext")
Re: Controlsend keys [to not active window]
If your trying to send text or something to an inactive window its best to use the sendmessage api as it can be used to send text, get text , click a button etc. to a specific window even if it is inactive.
Declaration:
Code:
Private Declare Auto Function SendMessage Lib "user32.dll" Alias "SendMessage" (ByVal hWnd As IntPtr, ByVal Msg As Integer, ByVal wParam As Integer, ByVal lParam As IntPtr) As IntPtr
However if you were to use sendmessage you would need to use findwindow:
Code:
rivate Declare Auto Function FindWindow Lib "user32" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer
Now i know this looks comlicated it sure was for me but try them out and they can be really helpful!