SystemUtil - QTP

QTP 11 adds two new methods to the SystemUtil object: BlockInput() and UnBlockInput().

The Blocklnput method allows you to blof k input from the keyboard and mouse while the script is running. This allows you to avoid any accidental keystrokes or mouse events which can disrupt the behavior of the executing test. This method should is suggested when using methods like Type or Set (with replay type set to mouse), etc. Input is blocked until one of the following events occur:

  • The UnBlocklnput method is called
  • CTRL + ALT + DEL key is presses
  • The test run ends
  • Any error is encountered during the test run
  • A Breakpoint is reached
  • A System error occurs

The code below shows typical use of these methods:

'Launch the calculator app
SystemUtil.Run"calc.exe"
'Wait Max 10 seconds to calculator window to appear
bWait= Window("title;=Calculator").Exist(10)
With Window("title:Calculator")
'Block any user input
SystemUtil.Blocklnput

Activate the application
Activate
Type a event
Type "2"
Type "+"
Type "3"
Type "="
Type "-10="
Allow user inputs
SystemUtil
.UnBlocklnput
'Display the output
Msgbox.WinEdit("nativeclass:=Edit").
GetROProperty(
"text")
End with


All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

QTP Topics