Results 1 to 1 of 1

Thread: Record and Playback User Macros (keyboard only)

Threaded View

  1. #1

    Thread Starter
    Frenzied Member Phill64's Avatar
    Join Date
    Jul 2005
    Location
    Queensland, Australia
    Posts
    1,201

    Record and Playback User Macros (keyboard only)

    Want to allow users to record repeditive actions?

    Here is an example to record and playback keyboard actions by the user, this could allow an office worker to have several standard form templates easily, for all areas of your application.

    All they need do is start recording and type into the appropriate fields and then press stop, Playback later on and these keystrokes will be replayed.

    Basically, this is a simple example, it will not work for menu commands or mouse events, you will need to make these modifications yourself if you are interested in them, but this will get you started even if that's the case.


    How's it work?
    The MacroRecorder adds a handler for the KeyPress event on every control on the form parsed to it and returns a Macro object which can be serialized and can playback the events using SendKeys.

    Warning
    Take note that in my example i use .playing to detect whether the Macro class i have on the form is playing on the buttons which manipulate the Macros.. you dont want a macro pressing the "record macro" button

    Also be sure to use .Dispose on Macros that will no longer be used, to save memory.

    Some Code Explained
    I have used $[PREV] as a control name to indicate that an event occured o nthe same control as the previous event did, this saves alot of CPU as the control doesnt need to be re-located for every keypress.

    Control names have been used instead of references so that this class can be serialised to file and used on any instance of the form type it was recorded on

    ---
    I have attached the whole project and also just the namespace for quick reading
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width