Skip to content

Commit 18436ed

Browse files
Merge pull request #1 from abdullahashfaq-ds/app
PyCapture v1.0
2 parents 9a251fe + 279aced commit 18436ed

File tree

8 files changed

+490
-1
lines changed

8 files changed

+490
-1
lines changed

PyCapture.exe

35.1 MB
Binary file not shown.

README.md

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,57 @@
1-
# PyCapture
1+
# PyCapture
2+
3+
PyCapture is a desktop application designed to automate screen capturing, allowing users to schedule screenshots at specified intervals. It is ideal for monitoring, documentation, and visual data collection, all without manual intervention.
4+
5+
## Features
6+
7+
- Automatically captures screenshots at user defined intervals.
8+
- Set a total duration for capturing, ranging from a few minutes to continuous monitoring.
9+
- Choose a save directory where all screenshots will be stored for easy access.
10+
- Enjoy a clean, minimalist interface that is intuitive and user-friendly.
11+
12+
## Interface
13+
14+
![PyCapture](assets/app.png)
15+
16+
## Installation and Setup
17+
18+
To get started quickly, download the `PyCapture.exe` file and run it without needing to install or configure anything. For developers, follow these steps to set up the application:
19+
20+
1. **Clone the Repository**
21+
22+
```bash
23+
git clone [email protected]:abdullahashfaq-ds/PyCapture.git
24+
cd PyCapture
25+
```
26+
27+
2. **Create and Activate a Virtual Environment**
28+
29+
For Linux/Mac:
30+
31+
```bash
32+
python -m venv venv
33+
source venv/bin/activate
34+
```
35+
36+
For Windows:
37+
38+
```bash
39+
python -m venv venv
40+
venv\Scripts\activate
41+
```
42+
43+
3. **Install Dependencies**
44+
45+
```bash
46+
pip install -r requirements.txt
47+
```
48+
49+
4. **Run the Application**
50+
51+
```bash
52+
python app.py
53+
```
54+
55+
## License
56+
57+
This project is licensed under the [MIT License](LICENSE). See the LICENSE file for more details.

app.py

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
import os
2+
import sys
3+
from PyQt5 import QtWidgets, uic
4+
from PyQt5.QtCore import QTimer
5+
6+
7+
class Screenshots(QtWidgets.QMainWindow):
8+
def __init__(self):
9+
super().__init__()
10+
uic.loadUi('app.ui', self)
11+
12+
self.screenshot_timer = None
13+
self.stop_timer = None
14+
self.button1.clicked.connect(self.start)
15+
self.button2.clicked.connect(self.stop)
16+
self.counter = 1
17+
self.setFixedSize(self.size())
18+
19+
def take_screenshot(self):
20+
try:
21+
pixmap = QtWidgets.QApplication.primaryScreen().grabWindow(
22+
QtWidgets.QApplication.desktop().winId()
23+
)
24+
save_path = self.input3.text()
25+
if not save_path:
26+
raise ValueError('Save path is empty')
27+
if not os.path.exists(save_path):
28+
os.makedirs(save_path)
29+
save_path += f'/screenshot_{self.counter}.png'
30+
pixmap.save(save_path)
31+
self.counter += 1
32+
except Exception as e:
33+
self.handle_error('Error taking screenshot', str(e))
34+
35+
def start(self):
36+
try:
37+
save_path = self.input3.text()
38+
if not save_path:
39+
raise ValueError('Save path is empty')
40+
time_interval = self.input1.text()
41+
if not time_interval.isdigit() or int(time_interval) <= 0:
42+
raise ValueError('Invalid time interval')
43+
total_interval = self.input2.text()
44+
if total_interval.lower() == 'true':
45+
total_interval = -1
46+
elif not total_interval.isdigit() or int(total_interval) <= 0:
47+
raise ValueError('Invalid total interval')
48+
else:
49+
total_interval = int(total_interval)
50+
if not os.path.exists(save_path):
51+
os.makedirs(save_path)
52+
53+
self.input1.setEnabled(False)
54+
self.input2.setEnabled(False)
55+
self.input3.setEnabled(False)
56+
self.button1.setEnabled(False)
57+
58+
start_message = QtWidgets.QMessageBox(self)
59+
start_message.setStyleSheet('color: white; font-size: 12px;')
60+
start_message.setIcon(QtWidgets.QMessageBox.Icon.Information)
61+
start_message.setText('Program is starting...')
62+
start_message.setWindowTitle('Starting')
63+
start_message.setStandardButtons(
64+
QtWidgets.QMessageBox.StandardButton.Ok
65+
)
66+
start_message.show()
67+
68+
self.screenshot_timer = QTimer()
69+
self.screenshot_timer.timeout.connect(self.take_screenshot)
70+
self.screenshot_timer.start(int(time_interval) * 1000)
71+
72+
if total_interval != -1:
73+
self.stop_timer = QTimer()
74+
self.stop_timer.setSingleShot(True)
75+
self.stop_timer.timeout.connect(self.stop)
76+
self.stop_timer.start(total_interval * 60000)
77+
78+
except Exception as e:
79+
error_message = QtWidgets.QMessageBox(self)
80+
error_message.setStyleSheet('color: white; font-size: 12px;')
81+
error_message.setIcon(QtWidgets.QMessageBox.Icon.Critical)
82+
error_message.setText(f'Error starting application: {str(e)}')
83+
error_message.setWindowTitle('Error')
84+
error_message.setStandardButtons(
85+
QtWidgets.QMessageBox.StandardButton.Ok
86+
)
87+
error_message.show()
88+
89+
def stop(self):
90+
try:
91+
if self.screenshot_timer is not None:
92+
self.screenshot_timer.stop()
93+
94+
if self.stop_timer is not None:
95+
self.stop_timer.stop()
96+
97+
self.input1.setEnabled(True)
98+
self.input2.setEnabled(True)
99+
self.input3.setEnabled(True)
100+
self.button1.setEnabled(True)
101+
102+
end_message = QtWidgets.QMessageBox(self)
103+
end_message.setStyleSheet('color: white; font-size: 12px;')
104+
end_message.setIcon(QtWidgets.QMessageBox.Icon.Information)
105+
end_message.setText('Program has ended.')
106+
end_message.setWindowTitle('Ending')
107+
end_message.setStandardButtons(
108+
QtWidgets.QMessageBox.StandardButton.Ok
109+
)
110+
end_message.show()
111+
112+
except Exception as e:
113+
error_message = QtWidgets.QMessageBox(self)
114+
error_message.setStyleSheet('color: white; font-size: 12px;')
115+
error_message.setIcon(QtWidgets.QMessageBox.Icon.Critical)
116+
error_message.setText(
117+
'An error occurred while stopping the application. Please try again or contact support.'
118+
)
119+
error_message.setWindowTitle('Error')
120+
error_message.setStandardButtons(
121+
QtWidgets.QMessageBox.StandardButton.Ok
122+
)
123+
error_message.show()
124+
125+
126+
if __name__ == '__main__':
127+
app = QtWidgets.QApplication(sys.argv)
128+
window = Screenshots()
129+
window.show()
130+
sys.exit(app.exec())

0 commit comments

Comments
 (0)