Click here to Skip to main content
15,888,579 members
Articles / Desktop Programming / WTL

Screen Event Recorder DLL/Application

Rate me:
Please Sign up or sign in to vote.
4.91/5 (34 votes)
9 May 2003MIT3 min read 214K   4.4K   105  
Screen Event Recorder (DLL) shows how to create a DLL/Application (one that can be used with RunDll32.exe).
#ifndef EVENTMAP_H
#define EVENTMAP_H
#include <winuser.h>

#pragma once

enum EventType {
	evt_ACTION		= HC_ACTION,
	evt_GETNEXT		= HC_GETNEXT,
	evt_SKIP		= HC_SKIP,
	evt_NOREMOVE	= HC_NOREMOVE,
	evt_SYSMODALON	= HC_SYSMODALON,
	evt_SYSMODALOFF	= HC_SYSMODALOFF
};

class CEventManager
{
public:
	CEventManager();
	virtual ~CEventManager();
	bool IsRecording() const;
	bool StartRecorder(bool bSkipMouse, bool bSkipKeyboard, bool bClearPrevious = true);
	void StopRecorder( bool bClearAll = false);
	bool IsPlaying() const;
	bool StartPlayer(bool bSkipMouse, bool bSkipKeyboard, int nRepeat = 0);
	void StopPlayer(bool bClearAll = false);
	bool GetSkipMouse() const;
	void SetSkipMouse( bool bSkip );
	bool GetSkipKeyboard() const;
	void SetSkipKeyboard( bool bSkip );
	bool GetModalState() const;
	void SetModalState( bool bState );
	void RemoveAllEvents();
	bool LoadEventFile(LPCTSTR szFileName);
	bool SaveEventFile(LPCTSTR szFileName);

public:
	virtual LRESULT OnRecordEvent(EventType evtType, LPARAM lParam);
	virtual LRESULT OnPlayEvent(EventType evtType, LPARAM lParam);

protected:
	void Lock();
	void Unlock();
	EVENTMSG* AllocArraySize(DWORD dwSize, DWORD dwFlags = 0);

protected:
	bool m_bRecording;		// in recording mode
	bool m_bPlaying;		// in playing mode
	bool m_bSkipMouse;		// Skip mouse message
	bool m_bSkipKeyboard;	// Skip keyboard message
	bool m_bModalState;		// MODAL ON/OFF
	int  m_nRepeatCount;	// Repeat count - when playing
	EVENTMSG m_EventMsg;	// Current event

	EVENTMSG*	m_lpEventArray;	// Array of events
	DWORD		m_dwMaxSize;	// Maximum size of the array (in EVENTMSG size not BYTES)
	DWORD		m_dwCurPos;		// Current position
	DWORD		m_dwCurSize;	// Number of stored events... (<= m_dwMaxSize)

	HANDLE m_hMutex;
};

#endif //EVENTMAP_H

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The MIT License


Written By
Software Developer (Senior)
United States United States
Ernest is a multi-discipline software engineer.
Skilled at software design and development for all Windows platforms.
-
MCSD (C#, .NET)
Interests: User Interface, GDI/GDI+, Scripting, Android, iOS, Windows Mobile.
Programming Skills: C/C++, C#, Java (Android), VB and ASP.NET.

I hope you will enjoy my contributions.

Comments and Discussions