13.07.2015 Views

sendkeys.ocx programming reference manual - MagTek

sendkeys.ocx programming reference manual - MagTek

sendkeys.ocx programming reference manual - MagTek

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

SECTION 1. INTRODUCTIONUse the SendKeys.OCX to send keystrokes to a legacy windows application that does notsupport COM Objects. The SendKeys.OCX can be used in conjunction with other controls tosend output as keystrokes; a perfect example is <strong>MagTek</strong>’s Keyboard Wedge Reader OCX. TheKeyboard Wedge Reader sends keystrokes as keyboard data. The Keyboard Wedge OCXcaptures the keystrokes from the keyboard input. The SendKeys.OCX can be used to sendspecific portions of the data captured by the Keyboard Wedge OCX. This allows us to controlthe output of a Keyboard Wedge Reader and still send just the data required as keystrokes.1


SendKeys.OCX2


SECTION 2. PROPERTIESNAME PROPERTYSets and Returns the control name.SyntaxSendKeys.Name[ = value]The Name property syntax has these parts:PartValueDescriptionA string value specifying thename of the control.ExampleAssume a SendKeys control is named ‘SendKeys1’Msgbox SendKeys1.NameDisplays “SendKeys1” in a message box.SendKeys1.Name = “SendKeys2”Changes the name of the control to ‘SendKeys2’ALLCAPS PROPERTYSets and returns the AllCaps property.SyntaxSendKeys.Allcaps[ = value]The Allcaps property syntax has these parts:PartValueDescriptionA Boolean value specifying thestatus of AllCaps.RemarksIf AllCaps is True then any data sent as keystrokes will first be converted to upper case. If theAllCaps property is False then the keystrokes are sent without any conversion. Upper caseletters will remain uppercase and lower case letters will remain lower case.ExampleSendKeys.AllCaps = TrueData TypeBoolean3


SendKeys.OCXTARGETAPP PROPERTYSets and returns the TargetApp property.SyntaxSendKeys.TargetApp[ = value]The TargetApp property syntax has these parts:PartValueDescriptionA string value representing theTarget Application that willreceive the keystrokes.RemarksIf TargetApp is left blank then the SendKeys control will send the keystrokes to the activewindow. If the TargetApp property is not blank, the SendKeys control will activate the window<strong>reference</strong>d by the TargetApp property. TargetApp should <strong>reference</strong> the application by thename in the application title bar.ExampleSendKeys.TargetApp = “Untitled – Notepad”Data TypeStringWAITFORAPP PROPERTYSets and returns the WaitForApp property.SyntaxSendKeys.WaitForApp[ = value]The WaitForApp property syntax has these parts:PartValueDescriptionA Boolean Value representingthe status of WaitForApp.RemarksIf WaitForApp is True then SendKeys.OCX will wait for the application that is using theSendKeys.OCX to become active before it activates the TargetApp. If WaitForApp is Falsethen the TargetApp will be activated immediately.ExampleSendKeys.WaitForApp = FalseData TypeBoolean4


WAITFORKEYS PROPERTYSets and returns the WaitForKeys property.SyntaxSendKeys.WaitForKeys[ = value]The WaitForKeys property syntax has these parts:PartValueDescriptionA Boolean Value representingthe status of WaitForKeys.PropertiesRemarksIf WaitForKeys is True then SendKeys.OCX will wait for the system to process the keys beforecontinuing. If WaitForKeys is False then the keystrokes will be sent without waiting for thesystem to process the keystrokes.ExampleSendKeys.WaitForKeys = FalseData TypeBoolean5


SendKeys.OCX6


SENDDATA METHODSends the keystrokes.SyntaxSendKeys.SendData[ = strData]The SendData method syntax has these parts:PartstrDataSECTION 3 METHODSDescriptionThe SendData method is used tosend the keystrokes.RemarksThe SendData method is the method that sends the keystrokes to the computer. The SendDatamethod can also use Keywords to represent keystrokes. If the keystrokes are sent successfullythen the method will return 0. If the TargetApp <strong>reference</strong>s an application that is not running thenthe method will return an error code of 5.ExampleSendKeys.SendData = ‘Hello World{ENTER}”Data TypeInteger7


SendKeys.OCX8


SECTION 4. EXAMPLEPrivate Sub Command1_Click()Dim Response As Integer'Set the Target Application to Untitled - NotepadSendKeys1.TargetApp = "Untitled - Notepad"'Do not wait for this application to become active firstSendKeys1.WaitForApp = False'Do not wait for the keystrokes to be processedSendKeys1.WaitForKeys = False'Send the Keystrokes - Hello World! and the Enter keyResponse = SendKeys1.SendData("Hello World!{ENTER}")Select Case ResponseCase 0txtStatus.Text = "Success"Case 5txtStatus.Text = "Application: " & SendKeys1.TargetApp & " is not running"Case ElsetxtStatus.Text = "Unknown Error"End SelectEnd Sub9

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!