This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| Run the python script as adminstrator, which means anything evoked | |
| from this script will have admin privilege | |
| https://stackoverflow.com/questions/130763/request-uac-elevation-from-within-a-python-script/ | |
| """ | |
| import ctypes | |
| import sys |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import socket | |
| HEADER = 64 | |
| FORMAT = 'utf-8' | |
| PORT = 5050 | |
| SERVER = '10.56.103.74' | |
| ADDR = (SERVER, PORT) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import socket | |
| import threading | |
| # import pickle | |
| # instead of sending strings, pickle serializes python object and | |
| # unpickle de-serialize python object to put in use | |
| # custom message protocol | |
| # header message that represent how long the return message length is | |
| HEADER = 64 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import csv | |
| import os | |
| import signal | |
| import subprocess | |
| PROCESS = 'notepad.exe' | |
| STATUS = 'running' # running or not responding | |
| CMD = r'tasklist /fi "IMAGENAME eq {}" /fi "STATUS eq {}" /fo "csv"'.format(PROCESS, STATUS) | |
| # output as csv format |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import ctypes | |
| EnumWindows = ctypes.windll.user32.EnumWindows | |
| EnumWindowsProc = ctypes.WINFUNCTYPE(ctypes.c_bool, ctypes.POINTER(ctypes.c_int), ctypes.POINTER(ctypes.c_int)) | |
| GetWindowText = ctypes.windll.user32.GetWindowTextW | |
| GetWindowTextLength = ctypes.windll.user32.GetWindowTextLengthW | |
| GetWindowProcessId = ctypes.windll.user32.GetWindowThreadProcessId | |
| IsWindowVisible = ctypes.windll.user32.IsWindowVisible | |
| winMapping = dict() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class TestUI(QtWidgets.QWidget): | |
| def __init__(self, parent=None): | |
| super(TestUI, self).__init__(parent) | |
| # initialization object | |
| layout = QtWidgets.QGridLayout() | |
| pb = QtWidgets.QPushButton() | |
| name = "SP_MessageBoxCritical" | |
| icon = self.style().standardIcon(getattr(QtWidgets.QStyle, name)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class MyButton(QtWidgets.QPushButton): | |
| right_clicked = QtCore.Signal() | |
| left_clicked = QtCore.Signal() | |
| double_clicked = QtCore.Signal() | |
| def __init__(self, *args, **kwargs): | |
| super(MyButton, self).__init__(*args, **kwargs) | |
| self.timer = QtCore.QTimer() | |
| self.timer.setSingleShot(True) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class MainWidget(QtWidgets.QMainWindow): | |
| def __init__(self, parent=None): | |
| self.connectSignal() | |
| def connectSignal(self): | |
| self.someBtn.clicked.connect(self.openCustomWidget) | |
| def openCustomWidget(self): | |
| # initialize with a widget and a layout | |
| self.customWidget = QtWidgets.QWidget() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class MainUI(QtWidgets.QMainWindow): | |
| def __init__(self, parent=getMainWindow()): | |
| super(MainUI, self).__init__(parent) | |
| list = ['apple', 'banana', 'pear'] | |
| dialog = CustomDialog() | |
| dialog.setNamespaceCBox(list) | |
| # only when self.accept() is returned | |
| # need close event to return self.close() |