Quick script, Loop keystrokes 'x' times??

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gviteri
    New Member
    • Feb 2008
    • 5

    Quick script, Loop keystrokes 'x' times??

    I apologize for not researching this information on my own but I am at work and need a quick fix.

    I am running WRQ Reflections built on Visual Basic. I need to create a macro that first inquires with a dialogue box that will indicate # of times to loop the script. The script will be very simple:

    Press f2, confirm data has been written
    Press f3, confirm data has been written

    This information will be looped hundreds of times and will save my accounts receivable department hours each week. Again, I hope to dive into scripting on my own soon and I know how frustrating it is to have people ask for things flatout. But thank you anyone for any help. Please let me know if there is any additional information that I should give.
  • gviteri
    New Member
    • Feb 2008
    • 5

    #2
    This is the code that I recorded with the macro recorder:

    Code:
    Sub MotherNature()
    ' Generated by the Reflection Macro Recorder on 02-18-2008 09:45:57.79.
    ' Generated by WRQ Reflection for UNIX and Digital 10.0.
        On Error GoTo ErrorHandler
    
        Const NEVER_TIME_OUT = 0
    
        Dim ESC As String   ' Chr$(rcESC) = Chr$(27) = Control-[
    
        ESC = Chr$(rcESC)
    
        With Session
            ' Press AnsiF2 (Perform the ANSI F2 function).
            .TransmitTerminalKey rcAnsiF2Key
    
            ' The following string was not unique:
            ' .WaitForString ESC & "[C", NEVER_TIME_OUT, rcAllowKeystrokes
    
            .StatusBar = "Waiting for Prompt: 25759"
            .WaitForString "C" & ESC & "[C" & ESC & "[C" & ESC & "[C" & ESC & "[C", NEVER_TIME_OUT, rcAllowKeystrokes
            .StatusBar = ""
            ' Press AnsiF3 (Perform the ANSI F3 function).
            .TransmitTerminalKey rcAnsiF3Key
    
            ' The following string was not unique:
            ' .WaitForString ESC & "[C", NEVER_TIME_OUT, rcAllowKeystrokes
    
            .StatusBar = "Waiting for Prompt: _____"
            .WaitForString "C" & ESC & "[C" & ESC & "[C" & ESC & "[C" & ESC & "[C", NEVER_TIME_OUT, rcAllowKeystrokes
            .StatusBar = ""
    
        Exit Sub
    
    ErrorHandler:
        .MsgBox Err.Description, vbExclamation + vbOKOnly
    
        End With
        ' Recording stopped at 09:46:17.75.
    End Sub
    I was hoping to generalize the script to simply:
    Code:
    dialogue box prompt: XY
    x = XY
    y = 0
    
    Sub MotherNature()
    .TransmitTerminalKey rcAnsiF2Key
    [wait for data to insert, verify insertion]
    .TransmitTerminalKey rcAnsiF3Key
    [wait for data to insert, verify insertion]
    x = x - 1;
    if x = y, Exit Sub
    gosub Mothernature
    End Sub
    As you can see I am inept within VB and can use a lot of help with the appropriate syntax. If there is any other information that I can provide please let me know and I will do my best to supply it. Thank you very much for any help provided.

    Comment

    • gviteri
      New Member
      • Feb 2008
      • 5

      #3
      I had a chance to peruse through the very basics for VB and this is what I came up with:
      Code:
      sub fix()
      Dim x
      x=InputBox("How many times should this loop?")
      
          With Session
           Do
      	.TransmitTerminalKey rcAnsiF2Key
      	[NEED CURSOR VERIFICATION]
      	.TransmitTerminalKey rcAnsiF3Key
      	[NEED CURSOR VERIFICATION]
      	x = x-1
      	Loop while x>0	
      Exit Sub
      I don't want the keys to be 'pushed' instananeously since the system is on a network and can be laggy at times. I was thinking that maybe there is a way to verify that the cursor is 'ready' and when that is the case to move on to the next line. I wasn't able to successfully search for a WaitForCursor or Wait command in VB.
      I'm doing my best here but I have literally about 20 minutes of VB experience (that I just accumulated). :) Thanks,

      Comment

      • mayurkumart
        New Member
        • Feb 2008
        • 1

        #4
        Hi,
        Even i am using the same reflection V12 emulator to test my application using QTP. If u don't mind, we both can share knowledge about the reflection.
        If so my question is, how we need to write the code in order totalk to a unix system.
        the second question is what are all the changes we need to make for the macros script to work on a vb platform?

        Comment

        Working...