Skip to content

Commit

Permalink
automationz
Browse files Browse the repository at this point in the history
  • Loading branch information
nathfavour committed Jul 20, 2024
1 parent c3ac256 commit 0b42b3f
Show file tree
Hide file tree
Showing 12 changed files with 241 additions and 1 deletion.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## AUTOMATIONS

Automating whatever aspect of my daily life I can..
Automating whatever aspect of my daily life I can..

# New methodologies

Software development should be easier than ever possible, so we introduced new methodologies here that make things kinda easier...
Empty file added browsers/automation.json
Empty file.
Empty file added flow/automation.json
Empty file.
Empty file added github/automation.json
Empty file.
50 changes: 50 additions & 0 deletions gui/brightness.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import sys
import subprocess

def set_brightness_windows(max_brightness=True):
# Windows: Use WMI to set brightness, 0-100 scale
level = '100' if max_brightness else '0'
subprocess.call(['powershell', '-Command', f"(Get-WmiObject -Namespace root/WMI -Class WmiMonitorBrightnessMethods).WmiSetBrightness(1, {level})"])

def set_brightness_linux(max_brightness=True):
# Linux: Use xrandr, requires identifying connected display
output = subprocess.check_output('xrandr --current | grep " connected"', shell=True).decode('utf-8').split()[0]
level = '1.0' if max_brightness else '0.1' # Scale is 0.0 to 1.0
subprocess.call(['xrandr', '--output', output, '--brightness', level])

def toggle_brightness():
# Placeholder for checking current brightness (platform-specific)
# This function should return True if at max brightness, False otherwise
# Implementing this check is highly platform-specific and may not be straightforward
return False

def main():
if len(sys.argv) > 1:
action = sys.argv[1]
if action == '0':
if sys.platform.startswith('win'):
set_brightness_windows(False)
elif sys.platform.startswith('linux'):
set_brightness_linux(False)
elif action == '1':
if sys.platform.startswith('win'):
set_brightness_windows(True)
elif sys.platform.startswith('linux'):
set_brightness_linux(True)
else:
# If no argument provided, toggle based on current state
if toggle_brightness():
# If currently max, set to min
if sys.platform.startswith('win'):
set_brightness_windows(False)
elif sys.platform.startswith('linux'):
set_brightness_linux(False)
else:
# If not max, set to max
if sys.platform.startswith('win'):
set_brightness_windows(True)
elif sys.platform.startswith('linux'):
set_brightness_linux(True)

if __name__ == "__main__":
main()
35 changes: 35 additions & 0 deletions gui/clickelect.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import sys
import pytesseract
import pyautogui
from PIL import Image

def find_and_click_string(search_string):
# Take a screenshot of the entire screen
screenshot = pyautogui.screenshot()

# Use pytesseract to extract text and bounding boxes
text_data = pytesseract.image_to_data(screenshot, output_type=pytesseract.Output.DICT)
text_list = text_data['text']

# Iterate through detected text elements to find the search string
for i, text in enumerate(text_list):
if search_string in text:
# Calculate the center of the bounding box
x = text_data['left'][i] + text_data['width'][i] // 2
y = text_data['top'][i] + text_data['height'][i] // 2

# Move the mouse to the center of the bounding box and double-click
pyautogui.moveTo(x, y)
pyautogui.click(clicks=2)
return True

return False

if __name__ == "__main__":
if len(sys.argv) < 2:
print("Usage: python find_and_click.py 'string_to_find'")
sys.exit(1)

search_string = sys.argv[1]
if not find_and_click_string(search_string):
print(f"The string '{search_string}' was not found on the screen.")
31 changes: 31 additions & 0 deletions gui/find-string.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import pyautogui
import pytesseract
from PIL import Image
import sys

# Specify the path to the Tesseract executable if it's not in your PATH
# pytesseract.pytesseract.tesseract_cmd = r'<full_path_to_your_tesseract_executable>'

def find_string_on_screen(search_string):
# Take a screenshot of the entire screen
screenshot = pyautogui.screenshot()

# Use pytesseract to convert the image to text
text = pytesseract.image_to_string(screenshot)

# Count the occurrences of the search string in the text
count = text.count(search_string)

return count

if __name__ == "__main__":
if len(sys.argv) != 2:
print("Usage: python script.py <search_string>")
sys.exit(1)

search_string = sys.argv[1]
occurrences = find_string_on_screen(search_string)
if occurrences > 0:
print(f"The string '{search_string}' was found {occurrences} times on the screen.")
else:
print(f"The string '{search_string}' was not found on the screen.")
19 changes: 19 additions & 0 deletions gui/run-command.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import subprocess
import pyautogui
import time

# Open PowerShell
# subprocess.Popen('powershell')


subprocess.Popen(['start', 'powershell'], shell=True)


time.sleep(2) # Wait for PowerShell to open

# Type the command in the PowerShell window
pyautogui.typewrite('gh api user', interval=0.1)
time.sleep(1) # Wait a bit before pressing Enter

# Press Enter to execute the command
pyautogui.press('enter')
Empty file added image-editing/automation.json
Empty file.
55 changes: 55 additions & 0 deletions networking/wifi-password.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import subprocess
import re

def get_current_wifi_password():
try:
# Get the currently connected SSID on Windows
ssid_output = subprocess.check_output(['netsh', 'wlan', 'show', 'interfaces']).decode('utf-8')
ssid_match = re.search(r'SSID\s*:\s*(.+)\r', ssid_output)
if ssid_match:
ssid = ssid_match.group(1)
# Get the WiFi profile details, including the password
key_output = subprocess.check_output(['netsh', 'wlan', 'show', 'profile', ssid, 'key=clear']).decode('utf-8')
key_match = re.search(r'Key Content\s*:\s*(.+)\r', key_output)
if key_match:
password = key_match.group(1)
print(f"SSID: {ssid}\nPassword: {password}")
else:
print("Password could not be retrieved.")
else:
print("No WiFi connected or SSID could not be retrieved.")
except Exception as e:
print(f"An error occurred: {e}")

get_current_wifi_password()















# from wifi_password import wifi_password

# def get_current_wifi_password():
# try:
# # Get the name (SSID) of the currently connected WiFi
# ssid = wifi_password.connected_ssid()
# if ssid:
# # Get the password of the currently connected WiFi
# password = wifi_password.get_password(ssid)
# print(f"SSID: {ssid}\nPassword: {password}")
# else:
# print("No WiFi connected.")
# except Exception as e:
# print(f"An error occurred: {e}")

# get_current_wifi_password()
43 changes: 43 additions & 0 deletions requirements.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"Python": {
"Django": {
"version": "3.2",
"dependencies": [
{"name": "djangorestframework", "version": "3.12.4"},
{"name": "django-filter", "version": "2.4.0"}
]
},
"Flask": {
"version": "1.1.2",
"dependencies": [
{"name": "Flask-RESTful", "version": "0.3.8"},
{"name": "Flask-SQLAlchemy", "version": "2.5.1"}
]
}
},
"JavaScript": {
"React": {
"version": "17.0.2",
"dependencies": [
{"name": "redux", "version": "4.1.0"},
{"name": "react-router-dom", "version": "5.2.0"}
]
},
"Vue": {
"version": "2.6.12",
"dependencies": [
{"name": "vuex", "version": "3.6.2"},
{"name": "vue-router", "version": "3.5.1"}
]
}
},
"Java": {
"Spring": {
"version": "5.3.8",
"dependencies": [
{"name": "spring-boot-starter-web", "version": "2.5.2"},
{"name": "spring-boot-starter-data-jpa", "version": "2.5.2"}
]
}
}
}
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pyautogui
pygetwindow
wifi-password

0 comments on commit 0b42b3f

Please sign in to comment.