|
-
Dec 9th, 2013, 07:11 PM
#1
Thread Starter
Member
SendKeys brings up Cannot Hook Error
Hello. I've been tralling the interwebs for a few hours now, and there is this one piece of code that is preventing my entire application from being complete!
Essentially, my application waits until a set of variables are equal to what they should be then it sends keys to the currently active window.
The code I am using is
But, whenever my program gets to the stage of doing this, it comes up with a security error.
Code:
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.Security.SecurityException: Hook cannot be created.
at System.Windows.Forms.SendKeys.InstallHook()
at System.Windows.Forms.SendKeys.Send(String keys, Control control, Boolean wait)
at System.Windows.Forms.SendKeys.Send(String keys)
at WindowsApplication1.Form1.Timer1_Tick(Object sender, EventArgs e) in C:\Users\Darren Steels\Dropbox\CB\CB\Form1.vb:line 174
at System.Windows.Forms.Timer.OnTick(EventArgs e)
at System.Windows.Forms.Timer.TimerNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
The Zone of the assembly that failed was:
MyComputer
As I copy and paste, the application did start sending the Number 4 to chrome within this textbox!
Code:
4444444444444444444444
as expected, so why doesn't it work within this other application?
UAC is disabled on my machine, and I even right click the application and click run as administrator. Nothing.
I have installed .Net 1.1, 1.1SP1 and the SendKeys Hotfix, in hopes that it may possibly work, it didn't, I assume because my project is using .Net 4
I have looked at SendInput, but the code wasn't clear or wasn't for the version of VB I am using. I have looked at keybd_event, but can't find any code at all to do with that.
I just need something to use as an alternative to SendKeys that will send key presses to another application, no questions asked...
Any help much appreciated!
Thanks!
~ TheMeq ~
If I helped in anyway, please hit the star and send me some rep! Thanks
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|