Question VB.Net SendKeys when Desktop is in Locked mode Fails

Sil

New member
Joined
Dec 27, 2008
Messages
2
Programming Experience
1-3
Plz help me to solve this problem

For a VB.Net Exe that starts a Process(another eg Notepad.exe) and controls its flow by using Sendkeys Command works fine when the Desktop is in Unlocked Mode.

The Same Code Fails to run when the Desktop is in locked Mode . i need this code to work properly even if Desktop is in Locked Mode

The Code starts the Notepad




VB.NET:
Dim pid As Integer = 0

Dim Notepad_Process As Process = New Process

Notepad_Process.StartInfo.FileName = "F:\BIC\Export\a.txt"

Notepad_Process.Start()


'This part is working but no Keys are processed .How to handle this .... ?

Plz refer Code snippet below
VB.NET:
Code Reference 
 [COLOR="Magenta"]
Imports System.windows.forms

Module Module1

Sub Main()




Dim pid As Integer = 0

Dim Notepad_Process As Process = New Process

Notepad_Process.StartInfo.FileName = "F:\BIC\Export\a.txt"

Notepad_Process.Start()

'-----------------This Part of Code is Working but SendKeys are not 

While True

Try

AppActivate(Notepad_Process.Id)

Exit While

Catch

System.Threading.Thread.Sleep(1000)

End Try

End While

SendKeys.SendWait("{Enter}")

System.Threading.Thread.Sleep(1000)

SendKeys.SendWait("Write Some Text ")

System.Threading.Thread.Sleep(1000)

SendKeys.SendWait("%{F}") 'Alt + F

System.Threading.Thread.Sleep(1000)

SendKeys.SendWait("{X}") 'Exit

SendKeys.SendWait("{Y}") 'Save the file yes 




End Sub

End Module

 [/COLOR]
Thanks

Sil
 
Last edited by a moderator:
Back
Top