Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implemented change_power_options method #8

Merged
merged 1 commit into from
Oct 26, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 24 additions & 7 deletions peg/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,25 @@ def get_screenshot_name_to_path_map(self, screenshot_names):
screenshot_path = os.path.join(self.screenshots_dir, screenshot_name)
screenshot_name_to_path_map[screenshot_name] = screenshot_path
return screenshot_name_to_path_map

def open_run_command_window(self):
pyautogui.hotkey('win', 'r')

def open_chrome(self):
open_run_command_window()
self.open_run_command_window()
pyautogui.write('chrome')
pyautogui.hotkey('enter', interval=3)

def open_file_or_folder_from_run_command_window(self,file_or_folder_path):
def open_file_or_folder_from_run_command_window(self, file_or_folder_path):
# open run window
open_run_command_window()
self.open_run_command_window()
# write path in run window
pyautogui.write(file_or_folder_path)
# press enter so that we go to that path
pyautogui.hotkey('enter')

def download_file_from_url_using_chrome(self,file_url):
open_chrome()
def download_file_from_url_using_chrome(self, file_url):
self.open_chrome()
# We got to enter url section
pyautogui.hotkey('alt', 'd')
# paste the given file url so that we can download the file
Expand All @@ -45,3 +45,20 @@ def download_file_from_url_using_chrome(self,file_url):
pyautogui.hotkey('ctrl', 's', interval=1)
# if window is there then we have to press enter button to download file
pyautogui.hotkey('enter')

def change_power_options(self,screen_off_on_battery, screen_off_when_plugged, sleep_on_battery,
sleep_when_plugged):
self.open_run_command_window()
pyautogui.write('powershell')
pyautogui.hotkey('enter', interval=1)
pyautogui.write(f'powercfg /change monitor-timeout-dc {screen_off_on_battery}')
pyautogui.hotkey('enter', interval=1)
pyautogui.write(f'powercfg /change monitor-timeout-ac {screen_off_when_plugged}')
pyautogui.hotkey('enter', interval=1)
pyautogui.write(f'powercfg /change standby-timeout-dc {sleep_on_battery}')
pyautogui.hotkey('enter', interval=1)
pyautogui.write(f'powercfg /change standby-timeout-ac {sleep_when_plugged}')
pyautogui.hotkey('enter', interval=1)
# close the window
pyautogui.write('exit')
pyautogui.hotkey('enter')