Skip to content

Commit 78d527f

Browse files
authored
Add files via upload
1 parent 81b2e67 commit 78d527f

6 files changed

Lines changed: 867 additions & 2 deletions

File tree

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 Macro Recorder
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 106 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,106 @@
1-
# MacroRec
2-
simple macro recorder
1+
# Macro Recorder
2+
3+
A powerful and user-friendly macro recording and playback application for Windows. Record and replay keyboard and mouse actions with customizable settings.
4+
5+
![Macro Recorder Screenshot](screenshot.png)
6+
7+
## Features
8+
9+
- Record keyboard and mouse actions
10+
- Customizable recording settings
11+
- System tray integration
12+
- Hotkey support
13+
- Adjustable playback speed
14+
- Repeat and loop playback options
15+
- Save and load macros
16+
- Modern and intuitive GUI
17+
18+
## Installation
19+
20+
### Prerequisites
21+
- Windows 10 or later
22+
- Python 3.8 or later (for development)
23+
24+
### Download
25+
1. Go to the [Releases](https://github.com/yourusername/macro-recorder/releases) page
26+
2. Download the latest `Macro Recorder.exe`
27+
3. Run the executable - no installation required
28+
29+
### Development Setup
30+
1. Clone the repository:
31+
```bash
32+
git clone https://github.com/yourusername/macro-recorder.git
33+
cd macro-recorder
34+
```
35+
36+
2. Create a virtual environment:
37+
```bash
38+
python -m venv venv
39+
venv\Scripts\activate
40+
```
41+
42+
3. Install dependencies:
43+
```bash
44+
pip install -r requirements.txt
45+
```
46+
47+
4. Run the application:
48+
```bash
49+
python macro_recorder_gui.py
50+
```
51+
52+
## Usage
53+
54+
### Recording Macros
55+
1. Click "Start Recording" or press F7
56+
2. Perform your actions (keyboard and mouse)
57+
3. Click "Stop Recording" or press Esc
58+
4. Save your macro with a descriptive name
59+
60+
### Playing Macros
61+
1. Select a macro from the list
62+
2. Click "Play Selected" or press F8
63+
3. Adjust playback settings in the Settings tab:
64+
- Playback speed
65+
- Repeat count
66+
- Repeat delay
67+
- Loop playback
68+
69+
### Settings
70+
- **Recording Settings**
71+
- Record keyboard/mouse
72+
- Mouse movement threshold
73+
- System tray behavior
74+
- **Hotkeys**
75+
- Start recording: F7
76+
- Stop recording: Esc
77+
- Play macro: F8
78+
- **Playback Settings**
79+
- Playback speed
80+
- Repeat count
81+
- Repeat delay
82+
- Loop playback
83+
84+
## Building the Executable
85+
86+
To build the standalone executable:
87+
88+
```bash
89+
pyinstaller macro_recorder_gui.spec
90+
```
91+
92+
The executable will be created in the `dist` directory.
93+
94+
## License
95+
96+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
97+
98+
## Contributing
99+
100+
Contributions are welcome! Please feel free to submit a Pull Request.
101+
102+
## Acknowledgments
103+
104+
- [PyInstaller](https://www.pyinstaller.org/) for creating standalone executables
105+
- [pynput](https://github.com/moses-palmer/pynput) for input device control
106+
- [ttkthemes](https://github.com/RedFantom/ttkthemes) for modern GUI themes

app.ico

8.56 KB
Binary file not shown.

macro_recorder.py

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
import keyboard
2+
import mouse
3+
import json
4+
import time
5+
from pynput.mouse import Controller as MouseController
6+
from pynput.keyboard import Controller as KeyboardController
7+
from datetime import datetime
8+
import os
9+
10+
class MacroRecorder:
11+
def __init__(self):
12+
self.recording = False
13+
self.events = []
14+
self.mouse = MouseController()
15+
self.keyboard = KeyboardController()
16+
self.start_time = None
17+
self.macro_dir = "macros"
18+
19+
# Create macros directory if it doesn't exist
20+
if not os.path.exists(self.macro_dir):
21+
os.makedirs(self.macro_dir)
22+
23+
def start_recording(self):
24+
print("Recording started... Press 'Esc' to stop recording.")
25+
self.recording = True
26+
self.events = []
27+
self.start_time = time.time()
28+
29+
# Start listening to events
30+
keyboard.hook(self.on_keyboard_event)
31+
mouse.hook(self.on_mouse_event)
32+
33+
def stop_recording(self):
34+
self.recording = False
35+
keyboard.unhook_all()
36+
mouse.unhook_all()
37+
print("Recording stopped.")
38+
return self.events
39+
40+
def on_keyboard_event(self, event):
41+
if event.event_type == 'down':
42+
if event.name == 'esc' and self.recording:
43+
self.stop_recording()
44+
return
45+
46+
current_time = time.time() - self.start_time
47+
self.events.append({
48+
'type': 'keyboard',
49+
'event': 'press',
50+
'key': event.name,
51+
'time': current_time
52+
})
53+
54+
def on_mouse_event(self, event):
55+
if not self.recording:
56+
return
57+
58+
current_time = time.time() - self.start_time
59+
if hasattr(event, 'button'):
60+
self.events.append({
61+
'type': 'mouse',
62+
'event': event.event_type,
63+
'button': event.button,
64+
'position': (event.x, event.y),
65+
'time': current_time
66+
})
67+
elif hasattr(event, 'x'):
68+
self.events.append({
69+
'type': 'mouse',
70+
'event': 'move',
71+
'position': (event.x, event.y),
72+
'time': current_time
73+
})
74+
75+
def save_macro(self, name=None):
76+
if not name:
77+
name = datetime.now().strftime("%Y%m%d_%H%M%S")
78+
79+
filename = os.path.join(self.macro_dir, f"{name}.json")
80+
with open(filename, 'w') as f:
81+
json.dump(self.events, f)
82+
print(f"Macro saved as: {filename}")
83+
return filename
84+
85+
def load_macro(self, filename):
86+
with open(filename, 'r') as f:
87+
self.events = json.load(f)
88+
return self.events
89+
90+
def play_macro(self, events=None):
91+
if events is None:
92+
events = self.events
93+
94+
if not events:
95+
print("No events to play!")
96+
return
97+
98+
print("Playing macro in 3 seconds...")
99+
time.sleep(3)
100+
101+
last_time = 0
102+
for event in events:
103+
# Wait for the appropriate time
104+
time_to_wait = event['time'] - last_time
105+
if time_to_wait > 0:
106+
time.sleep(time_to_wait)
107+
108+
if event['type'] == 'keyboard':
109+
if event['event'] == 'press':
110+
keyboard.press(event['key'])
111+
keyboard.release(event['key'])
112+
113+
elif event['type'] == 'mouse':
114+
if event['event'] == 'move':
115+
self.mouse.position = event['position']
116+
elif event['event'] == 'click':
117+
mouse.move(event['position'][0], event['position'][1])
118+
mouse.click(event['button'])
119+
elif event['event'] == 'double click':
120+
mouse.move(event['position'][0], event['position'][1])
121+
mouse.double_click(event['button'])
122+
123+
last_time = event['time']
124+
125+
def main():
126+
recorder = MacroRecorder()
127+
print("Macro Recorder")
128+
print("Press 'F7' to start recording")
129+
print("Press 'F8' to play last recorded macro")
130+
print("Press 'F9' to save last recorded macro")
131+
print("Press 'Ctrl+Q' to quit")
132+
133+
def on_f7():
134+
recorder.start_recording()
135+
136+
def on_f8():
137+
if recorder.events:
138+
recorder.play_macro()
139+
else:
140+
print("No macro recorded yet!")
141+
142+
def on_f9():
143+
if recorder.events:
144+
recorder.save_macro()
145+
else:
146+
print("No macro recorded yet!")
147+
148+
keyboard.add_hotkey('f7', on_f7)
149+
keyboard.add_hotkey('f8', on_f8)
150+
keyboard.add_hotkey('f9', on_f9)
151+
152+
keyboard.wait('ctrl+q')
153+
print("Program terminated.")
154+
155+
if __name__ == "__main__":
156+
main()

0 commit comments

Comments
 (0)