-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added tests for opening desktops on windows
- Loading branch information
Showing
8 changed files
with
125 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# -*- coding: utf-8 -*- | ||
from .FileUtils import FileUtils | ||
from .host_info import HostInfo | ||
from .windows import Window |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# -*- coding: utf-8 -*- | ||
from frameworks.host_control import HostInfo | ||
|
||
if HostInfo().os == 'windows': | ||
from .windows_window import WindowsWindow as Window | ||
else: | ||
from .linux_window import LinuxWindow as Window |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# -*- coding: utf-8 -*- | ||
from typing import Optional | ||
|
||
from .window import Window | ||
|
||
|
||
class LinuxWindow(Window): | ||
|
||
@staticmethod | ||
def get_hwnd(class_name: str, text: str) -> Optional[int]: | ||
pass | ||
|
||
@staticmethod | ||
def get_child_window_hwnd(window_hwnd: int, child_window_title: str, child_window_text: str) -> Optional[int]: | ||
pass | ||
|
||
@staticmethod | ||
def click_on_button(button_hwnd: int): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# -*- coding: utf-8 -*- | ||
from abc import ABC, abstractmethod | ||
from typing import Optional | ||
|
||
|
||
class Window(ABC): | ||
|
||
@staticmethod | ||
@abstractmethod | ||
def get_hwnd(class_name: str, text: str) -> Optional[int]: ... | ||
|
||
@staticmethod | ||
@abstractmethod | ||
def get_child_window_hwnd(window_hwnd: int, child_window_title: str, child_window_text: str) -> Optional[int]: ... | ||
|
||
@staticmethod | ||
@abstractmethod | ||
def click_on_button(button_hwnd: int): ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# -*- coding: utf-8 -*- | ||
from typing import Optional | ||
|
||
from .window import Window | ||
|
||
try: | ||
import win32gui | ||
import win32con | ||
except ImportError: | ||
pass | ||
|
||
|
||
class WindowsWindow(Window): | ||
|
||
@staticmethod | ||
def get_hwnd(class_name: str, text: str) -> Optional[int]: | ||
|
||
def enum_windows_callback(hwnd: int): | ||
if win32gui.IsWindowVisible(hwnd): | ||
if ( | ||
class_name.strip() == win32gui.GetClassName(hwnd).strip() | ||
and text.strip() == win32gui.GetWindowText(hwnd).strip() | ||
): | ||
return hwnd | ||
|
||
win32gui.EnumWindows(enum_windows_callback) | ||
return None | ||
|
||
@staticmethod | ||
def get_child_window_hwnd(window_hwnd: int, child_window_title: str, child_window_text: str) -> Optional[int]: | ||
|
||
def find_button(hwnd): | ||
cls_name, text = win32gui.GetClassName(hwnd), win32gui.GetWindowText(hwnd) | ||
if cls_name in child_window_title and child_window_text in text: | ||
return hwnd | ||
|
||
win32gui.EnumChildWindows(window_hwnd, find_button) | ||
return None | ||
|
||
@staticmethod | ||
def click_on_button(button_hwnd: int): | ||
try: | ||
win32gui.SendMessage(button_hwnd, win32con.BM_CLICK, 0, 0) | ||
except Exception as ex: | ||
print(ex) | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"Default_app_window": { | ||
"class_name": "#32770", | ||
"window_text": "ONLYOFFICE Desktop Editors", | ||
"button_class_name": "Button", | ||
"button_text": "No" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters