How to block keyboard when script running?
SOLVED- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How to block keyboard when script running?
Solved! Go to Solution.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Short answer you can't. Test complete sends real keystrokes and mouse actions when playing back.
Thanks,
Carson
Click the Accept as Solution button if my answer has helped
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Right, without a physical keyboard hooked up, it will still work. However, TestComplete "takes over" the UI input on the operating system while it's executing so any keystrokes ore mouse actions done while the automation is running will interfere.
Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----
Why automate? I do automated testing because there's only so much a human being can do and remain healthy. Sleep is a requirement. So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.
Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
the following ppython code sample dose NOT work in TestComplete ,why?
import time
from ctypes import *
user32 = windll.LoadLibrary('user32.dll')
user32.BlockInput(True);
time.sleep(10);
user32.BlockInput(False);
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Define "does not work"? Where is the error? What error message are you getting?
Again... TestComplete needs to be able to interact with the objects on screen. It needs to be able to simulate keyboard and mouse events and it does so using the operating system. What is your purpose behind wanting to block the keyboard? What are you trying to achieve? Perhaps there is a better way.
Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----
Why automate? I do automated testing because there's only so much a human being can do and remain healthy. Sleep is a requirement. So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.
Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The answer is this:
you can't. Best practice is that, if an automation is running, the machine should be left untouched. This can be done with VM's in a console mode or a lab.
Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----
Why automate? I do automated testing because there's only so much a human being can do and remain healthy. Sleep is a requirement. So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.
Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Does this help?
(Note: ages old DelphiScript code that might not work in modern TestComplete and/or Windows and I think that you definitely must consider bitness as described here: https://support.smartbear.com/testcomplete/docs/testing-with/advanced/using-external-functions/calli...)
// Function's effect can be cancelled by pressing Ctrl-Alt-Del
procedure StopKeyMouse;
var Def_Proc;
var Lib;
Def_DLL := DLL.DefineDLL('USER32');
Def_Proc := Def_DLL.DefineProc('BlockInput', vt_b1, vt_b1);
Lib := DLL.Load('USER32.DLL', 'USER32');
Lib.BlockInput(true);
end;
//-------------------------------------------------------------------------------
procedure ResumeKeyMouse;
var Def_Proc;
var Lib;
Def_DLL := DLL.DefineDLL('USER32');
Def_Proc := Def_DLL.DefineProc('BlockInput', vt_b1, vt_b1);
Lib := DLL.Load('USER32.DLL', 'USER32');
Lib.BlockInput(false);
end;
//-------------------------------------------------------------------------------
/Alex [Community Champion]
____
[Community Champions] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Champions]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Champion] signature is assigned on quarterly basis and is used with permission by SmartBear Software.
https://community.smartbear.com/t5/Community-Champions/About-the-Community-Champions-Program/gpm-p/252662
================================
