Compare commits

...

3 Commits

Author SHA1 Message Date
Abdul Rehman Kalsekar
8035043690
Merge d678b2bb0e into c4f08d05b5 2024-05-27 09:59:05 +07:00
Abdul Rehman Kalsekar
d678b2bb0e
Uploaded a Chrome Dinosaur Game automation script
A script that can play Chrome Dinosaur Game for you.
2022-10-01 00:18:12 +05:30
Abdul Rehman Kalsekar
6e7e9f2588
added main script
A project that can change your desktop wallpaper automatically.
2022-10-01 00:11:51 +05:30
2 changed files with 90 additions and 0 deletions

View File

@ -0,0 +1,44 @@
import os
import requests
import wget
import subprocess
import time
def get_wallpaper():
url = 'https://api.unsplash.com/photos/random?client_id=ZQfcb7DPk5z8ZH5W7Zaij6xG33M9U9BJ8ddfYifV6_E'
params = {
'query': 'HD wallpapers',
'orientation': 'landscape'
}
response = requests.get(url, params=params).json()
image_source = response['urls']['full']
image = wget.download(image_source, 'D:\\Abdul Rehman\\AI Automations\\Unsplash_Images_API\\Images')
return image
def change_wallpaper():
wallpaper = get_wallpaper()
cmd = """/usr/bin/osascript<<END
tell application "Finder"
set desktop picture to POSIX file "%s"
end tell
END"""
subprocess.Popen(cmd%wallpaper, shell=True)
subprocess.call(["killall Dock"], shell=True)
def main():
try:
while True:
change_wallpaper()
time.sleep(10)
except KeyboardInterrupt:
print("\nHope you like this one! Quitting.")
except Exception as e:
pass
if __name__ == "__main__":
main()

46
Dino Automation/main.py Normal file
View File

@ -0,0 +1,46 @@
import pyautogui # pip install pyautogui
from PIL import Image, ImageGrab # pip install pillow
from numpy import asarray
import time
def click(key):
pyautogui.keyDown(key)
return
def isCollision(data):
# Check colison for birds
for i in range(530,560):
for j in range(80, 127):
if data[i, j] < 171:
click("down")
return
# Check colison for cactus
for i in range(530, 620):
for j in range(130, 160):
if data[i, j] < 100:
click("up")
return
return
if __name__ == "__main__":
time.sleep(5)
click('up')
while True:
image = ImageGrab.grab().convert('L')
data = image.load()
isCollision(data)
# # Draw the rectangle for cactus
# for i in range(530, 610):
# for j in range(130, 160):
# data[i, j] = 0
# # # Draw the rectangle for birds
# for i in range(530, 560):
# for j in range(100, 125):
# data[i, j] = 171
# image.show()
# break