Skip to content

Instantly share code, notes, and snippets.

@adminy
Created October 19, 2019 08:13
Show Gist options
  • Save adminy/37fa326247dbc148084ede11539ec0bd to your computer and use it in GitHub Desktop.
Save adminy/37fa326247dbc148084ede11539ec0bd to your computer and use it in GitHub Desktop.
Bootcamp Mouse Enable Automation given you extracted AppleControlPannel.exe from bootcamp.exe
# coding: utf-8
from selenium import webdriver
from os import system
import subprocess
SW_MINIMIZE = 6
info = subprocess.STARTUPINFO()
info.dwFlags = subprocess.STARTF_USESHOWWINDOW
info.wShowWindow = SW_MINIMIZE
s = subprocess.Popen(r'C:\home\Winium.Desktop.Driver.exe', startupinfo=info)
#system('Powershell -Command "& { Start-Process \"C:\\home\\Winium.Desktop.Driver.exe\" -Verb RunAs }"')
driver = webdriver.Remote(
command_executor='http://localhost:9999',
desired_capabilities={
"debugConnectToRunningApp": 'false',
"app": r"C:/home/bootcamp/AppleControlPanel.exe"
})
def check_exists_by_name(name):
try:
driver.find_element_by_name(name)
except NoSuchElementException:
return False
return True
WINDOW = 'Boot Camp Control Panel'
while True:
if not check_exists_by_name(WINDOW):
print('window not initialized yet')
continue
else: break
TRACKPAD = 'Trackpad'
window = driver.find_element_by_name(WINDOW)
while True:
if not check_exists_by_name(TRACKPAD):
print('trackpad not initialized yet')
continue
else:
trackpad = window.find_element_by_name(TRACKPAD)
trackpad.click()
if trackpad.is_selected():
break
else:
print('failed to select: ', TRACKPAD)
continue
things_to_check = ['Tap to Click', 'Dragging', 'Secondary Click', 'Secondary Tap']
i = 0
while i < len(things_to_check):
if not check_exists_by_name(things_to_check[i]):
print(things_to_check[i]+' not initialized yet')
continue
else:
checkbox = window.find_element_by_name(things_to_check[i])
checkbox.click()
if checkbox.is_selected():
print('checked: ' + things_to_check[i])
i += 1
continue
# By this point apply exists and is waiting to be applied
window.find_element_by_name('Apply').click()
#window.find_element_by_name('OK').click()
driver.close()
s.kill()
print('finished success')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment