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!

Methods and keys in E!B

Status
Not open for further replies.

Handcopy

Programmer
Oct 17, 2007
11
US
Hello, I was wondering if there was a way to wait for certain keys to be pressed while the macro is running. For example, while the macro is running, is it possible to wait for a key to be pressed, so i could exit macro, mid-run? Also, i would like to know if i can wait for two different keys at once, i have tried something, but it didnt work as well as i wanted, this is what i tried
Code:
While (K <> " " and K <> "`")
	   K = Sess0.Screen.WaitForKeys()
            If (K <> " " and K <> "`") Then
                'nothing goes here, but this way of testing only works if i put in this if statement
            End If
WEnd
MsgBox F
 
Oh, and also i wanted to know if there was a way to make methods in E!B, and how to use them with parameters.
 
Try
Code:
   Do
      K = Sess.Screen.WaitForKeys()
   Loop While (K <> " " and K <> "`")
   
   Msgbox K
   
   Exit Sub ' exits macro
   
   Do While(1)   
   Loop

Functions and Subs
Code:
Declare Function Session_Open(ByRef message as String) As Integer  ' Function Prototype
Declare Sub Wait()                                                 ' Sub Prototype
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)    ' Sleep API

GLOBAL Sys as Object
GLOBAL Sess as Object

Sub Main
   Dim message as String
   
   If Session_Open (message) <> 1 Then
      Msgbox message
      Exit Sub
   End If
End Sub

' Function Declaration

Function Session_Open(ByRef message As String) As Integer
   Dim sess_open As Integer

   sess_open = 1

   Set Sys = CreateObject("Extra.System")
   Set Sess = Sys.ActiveSession

   If Sys Is Nothing Then
      message = "Could not create Extra.System...is E!PC installed on this machine?"
      sess_open = 0
   End If

   If Sess Is Nothing Then
      message = "No session available...stopping macro playback."
      sess_open = 0
   End If

   Session_Open = sess_open
End Function

' Sub Declaration

Sub Wait()
   Do While Sess.Screen.OIA.Xstatus <> 0
      DoEvents
   Loop
End Sub

Note, if you declare your subs and functions before Sub Main, you don't need the prototypes.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top