-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSYS-REC.ACTIONS.py
56 lines (56 loc) · 2.82 KB
/
SYS-REC.ACTIONS.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#-- !/usr/bin/env python3
#-- -*- coding: utf-8 -*-
#--
#-- ************************************************************************************************************:
#-- ******************************************** RECORD WIN ACTIONS ********************************************:
#-- ************************************************************************************************************:
#-- Author: JBallard (JEB) :
#-- Date: 2024.9.10 :
#-- Script: SYS-REC.ACTIONS.py :
#-- Purpose: A Python script that captures the users ACTIONS & writes them to a log file. :
#-- Class: python -m pip install pyautogui pygetwindow :
#-- Version: 1.0 :
#-- ************************************************************************************************************:
#-- ************************************************************************************************************:
#--
#-- ********************************************************:
#-- DEFINE PARAMS, CONSTANTS, CONFIG PATHS, CLASSES, & LIBS :
#-- ********************************************************:
import pyautogui
import pygetwindow as gw
import time
#--
#-- FUNCTION -RECORD ACTION EVERY DURATION:
def REC_Acts(duration=30):
#-- INITILIZES EMPTY LIST TO STORE ACTIONS:
actions = []
start_time = time.time()
print("NOTE - RECORDING ACTIONS...")
#--
#-- LOOP UNTIL END OF DURATION INPUT:
while time.time() - start_time < duration:
x, y = pyautogui.position()
actions.append((time.time() - start_time, x, y))
time.sleep(0.1)
#- RETURN LIST CONTAINING "TUPLES" OF RECORDED MOUSE ACTIONS:
return actions
#--
#-- FUNCTION - WRITES RECORDED ACTIONS TO FILE:
def SAV_Acts(filename, actions):
with open(filename, 'w') as f:
for action in actions:
f.write(f"{action[0]},{action[1]},{action[2]}\n")
#--
#-- MAIN FUNCTION:
if __name__ == "__main__":
#--
#-- PROMPT USER FOR SPECIFIED TIME DURATION:
duration = int(input("ENTER RECORDING DURATION (SEC): "))
actions = REC_Acts(duration)
#-- SAVE RECORDED ACTIONS TO FILE:
SAV_Acts("SYS-REC.WIN.ACTIONS.jeb", actions)
print("NOTE - RECORDED ACTIONS SAVED TO .\SYS-REC.WIN.ACTIONS.jeb")
#--
#-- ********************************************************:
#-- END OF PYTHON SCRIPT :
#-- ********************************************************: