-
Notifications
You must be signed in to change notification settings - Fork 0
/
oAMPP_GUI.py
174 lines (145 loc) · 6.02 KB
/
oAMPP_GUI.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
import sys
import os
import platform
import webbrowser
import subprocess
import requests
from PyQt5.QtWidgets import (QApplication, QMainWindow, QPushButton, QVBoxLayout, QProgressBar,
QLabel, QMessageBox, QWidget, QHBoxLayout, QSystemTrayIcon, QMenu)
from PyQt5.QtGui import QIcon, QPixmap, QFont
from PyQt5.QtCore import Qt, QThread, pyqtSignal
# Conditional import for Windows-specific modules
if platform.system() == 'Windows':
import winreg
else:
winreg = None
def resource_path(relative_path):
""" Get absolute path to resource, works for dev and for PyInstaller """
try:
# PyInstaller creates a temp folder and stores path in _MEIPASS
base_path = sys._MEIPASS
except Exception:
base_path = os.path.abspath(".")
return os.path.join(base_path, relative_path)
class FixerThread(QThread):
progress = pyqtSignal(int)
finished = pyqtSignal()
def run(self):
if platform.system() != 'Windows':
self.progress.emit(100)
self.finished.emit()
return
try:
key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System", 0, winreg.KEY_ALL_ACCESS)
current_value, _ = winreg.QueryValueEx(key, "EnableLUA")
if current_value == 1:
for i in range(101):
self.progress.emit(i)
if i == 50:
winreg.SetValueEx(key, "EnableLUA", 0, winreg.REG_DWORD, 0)
self.msleep(20)
else:
for i in range(101):
self.progress.emit(i)
self.msleep(10)
winreg.CloseKey(key)
except Exception as e:
print(f"Error: {e}")
self.finished.emit()
class OAMPPApp(QMainWindow):
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
self.setWindowTitle('oAMPP - XAMPP UAC Fixer')
self.setGeometry(300, 300, 500, 400)
self.setWindowIcon(QIcon(resource_path('icons/favicon-32x32.png')))
central_widget = QWidget()
self.setCentralWidget(central_widget)
layout = QVBoxLayout(central_widget)
# Logo
logo_label = QLabel()
pixmap = QPixmap(resource_path('oAMPP_logo.png'))
logo_label.setPixmap(pixmap.scaled(150, 150, Qt.KeepAspectRatio, Qt.SmoothTransformation))
logo_label.setAlignment(Qt.AlignCenter)
layout.addWidget(logo_label)
# Title
title_label = QLabel('oAMPP - XAMPP UAC Fixer')
title_label.setAlignment(Qt.AlignCenter)
title_label.setFont(QFont('Arial', 16, QFont.Bold))
layout.addWidget(title_label)
# Fix button
self.fix_button = QPushButton('Fix UAC Issue')
self.fix_button.setStyleSheet("background-color: #4CAF50; color: white; font-size: 14px; padding: 10px;")
self.fix_button.clicked.connect(self.start_fix)
layout.addWidget(self.fix_button)
# Progress bar
self.progress_bar = QProgressBar()
self.progress_bar.setStyleSheet("QProgressBar {border: 2px solid grey; border-radius: 5px; text-align: center;}"
"QProgressBar::chunk {background-color: #4CAF50;}")
layout.addWidget(self.progress_bar)
# Social links
social_layout = QHBoxLayout()
tg_button = QPushButton('Telegram')
tg_button.setIcon(QIcon(resource_path('icons/telegram_icon.png')))
tg_button.clicked.connect(lambda: self.open_url('https://t.me/VorTexCyberBD'))
social_layout.addWidget(tg_button)
git_button = QPushButton('GitHub')
git_button.setIcon(QIcon(resource_path('icons/github_icon.png')))
git_button.clicked.connect(lambda: self.open_url('https://github.com/nectariferous/oAMPP'))
social_layout.addWidget(git_button)
layout.addLayout(social_layout)
# System tray
self.tray_icon = QSystemTrayIcon(self)
self.tray_icon.setIcon(QIcon(resource_path('icons/favicon-32x32.png')))
tray_menu = QMenu()
show_action = tray_menu.addAction("Show")
quit_action = tray_menu.addAction("Exit")
show_action.triggered.connect(self.show)
quit_action.triggered.connect(QApplication.instance().quit)
self.tray_icon.setContextMenu(tray_menu)
self.tray_icon.show()
def start_fix(self):
self.fix_button.setEnabled(False)
self.fixer_thread = FixerThread()
self.fixer_thread.progress.connect(self.update_progress)
self.fixer_thread.finished.connect(self.fix_finished)
self.fixer_thread.start()
def update_progress(self, value):
self.progress_bar.setValue(value)
def fix_finished(self):
self.fix_button.setEnabled(True)
QMessageBox.information(self, 'Fix Complete', 'UAC issue has been fixed. Please restart your computer for changes to take effect.')
def open_url(self, url):
try:
webbrowser.open(url)
except Exception as e:
print(f"Error opening URL: {e}")
self.fallback_open_url(url)
def fallback_open_url(self, url):
try:
if platform.system() == 'Windows':
os.startfile(url)
elif platform.system() == 'Darwin': # macOS
subprocess.Popen(['open', url])
else: # Linux and others
subprocess.Popen(['xdg-open', url])
except Exception as e:
print(f"Fallback error opening URL: {e}")
QMessageBox.warning(self, 'Error', f'Unable to open URL: {url}')
def closeEvent(self, event):
event.ignore()
self.hide()
self.tray_icon.showMessage(
"oAMPP",
"Application was minimized to tray",
QSystemTrayIcon.Information,
2000
)
def main():
app = QApplication(sys.argv)
ex = OAMPPApp()
ex.show()
sys.exit(app.exec_())
if __name__ == '__main__':
main()