Skip to content

Commit

Permalink
Merge pull request #8 from nitinNT/issue#7
Browse files Browse the repository at this point in the history
implemented change_power_options method
  • Loading branch information
NavpreetDevpuri committed Oct 26, 2021
2 parents 438b746 + bc3b552 commit 9412f98
Showing 1 changed file with 24 additions and 7 deletions.
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')

0 comments on commit 9412f98

Please sign in to comment.