Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

WaitForKeys and VB.Net 2

Status
Not open for further replies.

cbouknight

Programmer
Jan 5, 2008
12
US
I'm trying to use WaitForKeys as follows:

Code:
Proceed = Screen1.WaitForKeys(9000, "<Tab>")

If Proceed Then
   MessageBox.Show("Done.")
Else
   MessageBox.Show("No key pressed in 9 seconds.")
End If

I have "proceed" declared as boolean.

However, on executing the code, I get an error stating "Conversion from type '_ComObject' to type 'Boolean' is not valid."

How can I properly use this properly?
 
Considering you are using VB.NET though, you should be able to monitor the keys being pressed. I wouldn't imagine it'd be too hard to write a script that if EXTRA is the activate application it watches for a key to be pressed.

But, I'd suggest using the VB.NET forum for it. My VB.NET knowledge is fairly limited.

If you only need code to watch the EXTRA screen until it changes, then that's pretty easy to do. Please note, the following code is VBScript.

Code:
Function Wait4Change(iSeconds, oScreen)
  Dim sOld, sNew, dTime, iWaitTime
  iWaitTime = iSeconds/(24*60*60)
  sOld = oScreen.Area(1, 1, 24, 80, , 2).Value
  sNew = sOld
  dTime = Time + iWaitTime
  Do While Time < dTime
    sNew = oScreen.Area(1, 1, 24, 80, , 3).Value
    If sOld <> sNew Then
      Exit Do
    End If
  Loop
  If sNew = sOld Then
    Wait4Change = ""
  Else
    Wait4Change = sNew
  End If
End Function

VB.NET has much better date/time comparison and calculations, so you wouldn't have to crunch numbers to figure out the time fractions for hour, minute, second, etc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top