Announcement

Collapse

Maintenance

The forum could be offline for 30-60 minutes in the very near future for maintenance (said 3pm Pacific). I was behind on getting this notice. I do apologize.
See more
See less

inputing keystrokes in third party programs

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • inputing keystrokes in third party programs

    here is a tsr program to supply keyboard input to another program

    i am asking for help in programming it and we can all use it
    i hope i am not reinventing the wheel here.


    well most of the work is done i believe except for
    some error routines
    memory reducing
    unloading the program from memmory by the command prompt
    i use tsrmark and tsrremv to solve these program now
    maybe some adjusting on times concerning the popup stuff command

    a data file to provide keyboard input can be any file

    all timing is based on a one-half (.5) second
    for example if the first line is a number of 10, the program will wait
    about 5 seconds before suppling input
    the minium input of time if 0 is replaced with a value of 1 so a one-haf
    second pause between inputs is the least

    the first line in the data file is how long the tsr will wait before supplying
    keyboard input

    the remaining of the data files is a string then a number - comma delimited
    for special key characters, they will will start with << and end with >>
    so a carriage return will be <<cr>> and down cursor will be <<dn>>

    a listing of the program is first followed by a sample data file to that list
    the keyboard entrys made .

    thanks your help in advance.


    --------------------------------------------------------------
    Code:
    REM TSRKMACR.BAS
    REM POWERBASIC SOURCE CODE
    REM TO SUPPLY ANSWERS TO PROGRMS FROM A FILE PLACED ON THE COMMAND LINE
    REM VERSION 05-29-2006
    REM COMPILED WITH POWERBASIC 3.5 FOR DOS
    REM $CPU 80386 'program works on any CPU
    $OPTIMIZE SPEED 'make FASTEST possible executable
    $DEBUG MAP OFF 'turn off map file generation
    $DEBUG PBDEBUG OFF 'don't include pbdebug support in our executable
    $LIB COM OFF 'turn off PowerBASIC's communications library.
    $LIB CGA OFF 'turn off PowerBASIC's CGA graphics library.
    $LIB EGA OFF 'turn off PowerBASIC's EGA graphics library.
    $LIB LPT OFF 'turn off PowerBASIC's printer support library.
    $LIB IPRINT OFF 'turn off PowerBASIC's interpreted print library.
    $LIB FULLFLOAT OFF 'turn off PowerBASIC's floating point support.
    $ERROR BOUNDS ON  'turn on bounds checking
    $ERROR NUMERIC OFF 'turn off numeric checking
    $ERROR OVERFLOW OFF 'turn off overflow checking
    $ERROR STACK OFF 'turn off stack checking
    $COM 0 'set communications buffer to nothing
    $STRING 32 'set largest string size at 32k
    $STACK 4096 'let's use a 2k stack
    $SOUND 1 'smallest music buffer possible
    $STATIC
    $OPTION CNTLBREAK OFF 'don't allow Ctrl-Break to exit program
    $COMPILE EXE 'this tells PB to make a standalone EXE
    $EVENT OFF
    
    
    DIM MACROWAIT%(1600)
    DIM MACROKEY$(1600)
    x& = SETMEM( -700000 ) 'release unused memory
    
    MACROFILE$=COMMAND$
    IF MACROFILE$="" THEN GOTO NOTAIL
    ON ERROR GOTO FINDFILENO
    OPEN MACROFILE$ FOR INPUT AS #1
    CLOSE 1
    
    ON ERROR GOTO ERRORINFILE
    
    FIRSTTIME%=0
    MACROLINES%=0
    OPEN MACROFILE$ FOR INPUT AS #1
     INPUT #1, FIRSTTIME%
    DO UNTIL EOF(1)
     INPUT #1, A$,A%
     MACROLINES%=MACROLINES%+1
     LOOP
     CLOSE 1
    
    ON ERROR GOTO FINISHERR
    
    OPEN MACROFILE$ FOR INPUT AS #1
     INPUT #1, FIRSTTIME%
     FOR I%=1 TO MACROLINES%
     INPUT #1, MACROKEY$(I%),A%
     IF LEN(MACROKEY$(I%))<>6 THEN GOTO 11
     IF UCASE$(MACROKEY$(I%))="<<CR>>" THEN MACROKEY$(I%)=CHR$(13)
     IF UCASE$(MACROKEY$(I%))="<<UP>>" THEN MACROKEY$(I%)=CHR$(0,0,&H48)
     IF UCASE$(MACROKEY$(I%))="<<DN>>" THEN MACROKEY$(I%)=CHR$(0,0,&H50)
     IF UCASE$(MACROKEY$(I%))="<<LT>>" THEN MACROKEY$(I%)=CHR$(0,0,&H4B)
     IF UCASE$(MACROKEY$(I%))="<<RT>>" THEN MACROKEY$(I%)=CHR$(0,0,&H4D)
     IF UCASE$(MACROKEY$(I%))="<<PU>>" THEN MACROKEY$(I%)=CHR$(0,0,&H49)
     IF UCASE$(MACROKEY$(I%))="<<PD>>" THEN MACROKEY$(I%)=CHR$(0,0,&H51)
     IF UCASE$(MACROKEY$(I%))="<<NL>>" THEN MACROKEY$(I%)=CHR$(0,0,&H45)
     IF UCASE$(MACROKEY$(I%))="<<CL>>" THEN MACROKEY$(I%)=CHR$(0,0,&H3A)
     IF UCASE$(MACROKEY$(I%))="<<SL>>" THEN MACROKEY$(I%)=CHR$(0,0,&H46)
     IF UCASE$(MACROKEY$(I%))="<<F1>>" THEN MACROKEY$(I%)=CHR$(0,0,&H3B)
     IF UCASE$(MACROKEY$(I%))="<<F2>>" THEN MACROKEY$(I%)=CHR$(0,0,&H3C)
     IF UCASE$(MACROKEY$(I%))="<<F3>>" THEN MACROKEY$(I%)=CHR$(0,0,&H3D)
     IF UCASE$(MACROKEY$(I%))="<<F4>>" THEN MACROKEY$(I%)=CHR$(0,0,&H3E)
     IF UCASE$(MACROKEY$(I%))="<<F5>>" THEN MACROKEY$(I%)=CHR$(0,0,&H3F)
     IF UCASE$(MACROKEY$(I%))="<<F6>>" THEN MACROKEY$(I%)=CHR$(0,0,&H40)
     IF UCASE$(MACROKEY$(I%))="<<F7>>" THEN MACROKEY$(I%)=CHR$(0,0,&H41)
     IF UCASE$(MACROKEY$(I%))="<<F8>>" THEN MACROKEY$(I%)=CHR$(0,0,&H42)
     IF UCASE$(MACROKEY$(I%))="<<F9>>" THEN MACROKEY$(I%)=CHR$(0,0,&H43)
     11
     IF LEN(MACROKEY$(I%))<>7 THEN GOTO 12
     IF UCASE$(MACROKEY$(I%))="<<INS>>" THEN MACROKEY$(I%)=CHR$(0,0,&H52)
     IF UCASE$(MACROKEY$(I%))="<<F10>>" THEN MACROKEY$(I%)=CHR$(0,0,&H44)
     IF UCASE$(MACROKEY$(I%))="<<F11>>" THEN MACROKEY$(I%)=CHR$(0,0,&HD9)
     IF UCASE$(MACROKEY$(I%))="<<F12>>" THEN MACROKEY$(I%)=CHR$(0,0,&HDA)
     IF UCASE$(MACROKEY$(I%))="<<END>>" THEN MACROKEY$(I%)=CHR$(0,0,&H4F)
     IF UCASE$(MACROKEY$(I%))="<<PTR>>" THEN MACROKEY$(I%)=CHR$(0,0,&H37)
     IF UCASE$(MACROKEY$(I%))="<<DEL>>" THEN MACROKEY$(I%)=CHR$(0,0,&H53)
     12
     IF UCASE$(MACROKEY$(I%))="<<HOME>>" THEN MACROKEY$(I%)=CHR$(0,0,&H47)
     IF A%=0% THEN A%=1%
     MACROWAIT%(I%)=A%*9%
     NEXT I%
    CLOSE 1
    
    ON ERROR GOTO FINISH
    
    POPUP TIMER FIRSTTIME%*9%
    POPUP SLEEP
    POPUP TIMER 9
    10
     KBUFFER%=POPUP(3)
     IF KBUFFER%=0 THEN POPUP SLEEP
     IF KBUFFER%=0 THEN GOTO 10
    
     FOR I%=1 TO MACROLINES%
     KEYSTROKE$=MACROKEY$(I%)
    NEWKEYSTROKE:
     KBUFFER%=POPUP(3)
    
     IF LEN(KEYSTROKE$)>KBUFFER% THEN
             TEMP$=LEFT$(KEYSTROKE$,KBUFFER%)
             B$=RIGHT$(KEYSTROKE$,LEN(KEYSTROKE$)-KBUFFER%)
             POPUP STUFF TEMP$,2,0
             POPUP TIMER 9
             POPUP SLEEP
             KEYSTROKE$=B$
             GOTO NEWKEYSTROKE
     END IF
    
    POPUP STUFF KEYSTROKE$,0,0
    IF I%=MACROLINES% THEN  I%=0:GOTO FINISHTSR
    IF MACROWAIT%(I%)<0% THEN  I%=0:GOTO FINISHTSR
    POPUP TIMER MACROWAIT%(I%)
    POPUP SLEEP
     NEXT I%
    
    GOTO FINISH
    
    FINISHTSR:
    I%=I%+1
    POPUP TIMER 73
    POPUP SLEEP
    IF POPUP(1) THEN GOTO FINISH
    IF I%=3330 THEN GOTO FINISH
    GOTO FINISHTSR
    
    FINDFILENO:
    PRINT "cannot find the keyboard macro file listed on the command tail"
    GOTO FINISH
    NOTAIL:
    PRINT "command tail is blank, place a keyboard macro file on the command tail"
    GOTO FINISH
    ERRORINFILE:
    PRINT "There was a problem reading the file "+MACROFILE$
    PRINT "around line number "+STR$(MACROLINES%)
    FINISHERR:
    PRINT "There was an error filling keystrokes"
    PRINT "around line number "+STR$(MACROLINES%)+" in "+MACROFILE$
    FINISH:
    STOP
    END
    --------------------------------------------------------------
    the start of the data file listing
    --------------------------------------------------------------
    6
    "dir",1
    "<<CR>>",8
    "see the brown fox",3
    "<<CR>>",3
    "see the red fox",3
    "<<CR>>",3
    --------------------------------------------------------------
    the end of the data file listing


    ------------------




    [This message has been edited by paul d purvis (edited May 29, 2006).]
    p purvis

  • #2
    I guess some applications really are "forever"....

    Code:
    [72030,3563] Michael Mattias
    STUFFR.ZIP
      Bin,  Bytes:     6201, Count:   178, 16-Apr-94
    
      Title   : PowerBASIC TSR Keyboard Macro Stuffer
      Keywords: STUFF KEY KEYBOARD MACRO POPUP TSR SOURCE FREE
    
      This archive contains the PB source code and documentation for STUFFER, a
      PB TSR keyboard macro stuffer program. Macros are stored in an ordinary
      ASCII text file and read when the program is loaded (sample file included,
      too!). Will not double-install; will de-install if safe. Good example of
      an application for PB's POPUP STUFF command. 100 percent PB code; easy
      to modify. Requires PB 3.0+. Public Domain. From Michael Mattias.
    --- Compuserve "PCVENB" files catalog---

    Why do I still have this record? This code was the basis for my very first paying software development job as an independent developer/marketer. So call me a sentimental old fart.



    [This message has been edited by Michael Mattias (edited May 28, 2006).]
    Michael Mattias
    Tal Systems Inc. (retired)
    Racine WI USA
    [email protected]
    http://www.talsystems.com

    Comment


    • #3
      i should have used in the source code
      popup timer rather than popup quiet
      i found that out rereading the pb manual


      yes michael good programs should last a long time
      and i really appreciate the info and the program.

      you know in your heart there is something out there that does what you
      want to do.
      but it can be forever finding it these days with so many hits with a search on the internet
      thanks a again for your ever giving kind help that i respect
      paul purvis



      ------------------


      [This message has been edited by paul d purvis (edited May 28, 2006).]
      p purvis

      Comment


      • #4
        >if should have used in the source code
        >popup timer rather than popup quiet

        For a macro stuffer, why not POPUP KEY? Just like many MS-DOS TSRs, a hot-key triggers the sleeping program.. and this particular program could be used with any MS-DOS program which needs to accept characters from the keyboard.

        I never noticed that you were using popup quiet, because your code was posted without Code Tags and trying to read unformatted code is not very easy.

        You can 'edit' your post to insert the tags.
        Michael Mattias
        Tal Systems Inc. (retired)
        Racine WI USA
        [email protected]
        http://www.talsystems.com

        Comment


        • #5
          ok i made some minor modifications to the original post
          the intent, was to write a program to provide answers to a third party
          program, where the third party program was heavy in use of menus and
          to retrieve printouts you have to answer a lot of questions(prompts).

          as i get older, my hands are hurting more with my but, and time is always
          short along with my patience get shorter.

          we are moving to some new software where doing a lot things i do is tedious.
          this new software has all reports printed, which i hate, did i say hate.
          i belive most all reports now should go straight to a file and then you can decide
          whether to view the file or print it. i hate the old way to doing things, i do not
          really care for the people that do not want to change their crappy way of doing things
          like it was 1983.
          but you still have to work with whatever software you have to do a job.
          i am in high hopes my software will fill the some of my pains and disappointments of other
          peoples software.

          but i did try to find the software stuffr.zip and was not able to find it.
          i have written tsr's for macro keyboarding.
          but i wanted a program to automate another program and get out of it
          thanks michael




          ------------------
          p purvis

          Comment


          • #6
            i am having some progblems with the keyboard buffer on the command propmpt of
            windows 2000 pro when running cmd.exe, but not command.com.

            popup(3) gives an answer of zero
            there does not seem to be a keyboard buffer until you enter a program.

            see
            http://<a href="http://www.powerbasi...</a>kuhn<br />

            member posted october 22, 2001 12:40 pm click here to see the profile for matthias kuhn edit/delete message reply w/quote hi lance,

            you give never up or ?

            i've tested

            popup stuff "test",0,0

            but nothing happend

            ?popup(3) is always zero.

            dummy&=(-500000) before has no effect
            popup quiet 1092 before - the same.

            i`m using dos mode of win 95 ver 4.00.1111. and dos-window.

            greetings

            matthias


            maybe somebody has an answer to this, tamedos caused this problem to go away, but
            who wants to run a third party program to make your own program run.

            paul d purvis

            ------------------




            [this message has been edited by paul d purvis (edited may 30, 2006).]
            p purvis

            Comment

            Working...
            X