Disable/enable the mouse and keyboard - is it possible? : Automation API

Disable/enable the mouse and keyboard - is it possible?

Class library usage, coding and language questions.

Disable/enable the mouse and keyboard - is it possible?

Postby testMunky » Wed Jan 16, 2008 12:57 pm

Hello,

I've done a search and can't find the info so thought i'd post here :)

Is it possible to disable the keyboard and/or mouse for the duration of the script?

Thanks


Si :twisted:
testMunky
 
Posts: 6
Joined: Wed Jan 16, 2008 12:52 pm
Location: Hants, UK

Postby Support Team » Wed Jan 16, 2008 6:42 pm

You can block input from mouse and keyboard by calling the WinAPI function BlockInput(bool). Just be sure to call the function from the same thread that runs the automation script, otherwise the automated clicks and keyboard events may also be blocked.

To use this method in C#, include the following definition in your class:
Code: Select all
[System.Runtime.InteropServices.DllImport("user32.dll")]
static extern bool BlockInput(bool block);

Another problem with the BlockInput function is that it sometimes seems to block Ranorex.Element access and actions, too. That's why this functionality is not included in Ranorex by default. So, if your script blocks on a specific line, just enable the input before that line and disable it afterwards again.

Regards,
Alex
Ranorex Support Team
User avatar
Support Team
Site Admin
 
Posts: 4840
Joined: Fri Jul 07, 2006 5:30 pm
Location: Graz, Austria


Return to Automation API

Who is online

Users browsing this forum: No registered users and 0 guests