ok-script 0.0.7__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. autohelper/AutoHelper.py +116 -0
  2. autohelper/__init__.py +0 -0
  3. autohelper/capture/BaseCaptureMethod.py +30 -0
  4. autohelper/capture/HwndWindow.py +138 -0
  5. autohelper/capture/__init__.py +0 -0
  6. autohelper/capture/adb/ADBCaptureMethod.py +29 -0
  7. autohelper/capture/adb/DeviceManager.py +209 -0
  8. autohelper/capture/adb/__init__.py +0 -0
  9. autohelper/capture/adb/bin/__init__.py +0 -0
  10. autohelper/capture/adb/targets.py +61 -0
  11. autohelper/capture/adb/vbox.py +140 -0
  12. autohelper/capture/windows/WindowsGraphicsCaptureMethod.py +228 -0
  13. autohelper/capture/windows/__init__.py +0 -0
  14. autohelper/capture/windows/d3d11.py +74 -0
  15. autohelper/capture/windows/utils.py +149 -0
  16. autohelper/capture/windows/window.py +36 -0
  17. autohelper/color/Color.py +41 -0
  18. autohelper/color/__init__.py +0 -0
  19. autohelper/config/Config.py +79 -0
  20. autohelper/config/InfoDict.py +16 -0
  21. autohelper/config/__init__.py +0 -0
  22. autohelper/feature/Box.py +199 -0
  23. autohelper/feature/Feature.py +20 -0
  24. autohelper/feature/FeatureSet.py +207 -0
  25. autohelper/feature/FindFeature.py +52 -0
  26. autohelper/feature/__init__.py +0 -0
  27. autohelper/gui/App.py +120 -0
  28. autohelper/gui/Communicate.py +22 -0
  29. autohelper/gui/MainWindow.py +69 -0
  30. autohelper/gui/TabTitles.py +56 -0
  31. autohelper/gui/__init__.py +5 -0
  32. autohelper/gui/debug/AspectRatioWidget.py +31 -0
  33. autohelper/gui/debug/DebugTab.py +37 -0
  34. autohelper/gui/debug/FrameWidget.py +125 -0
  35. autohelper/gui/debug/InfoWidget.py +40 -0
  36. autohelper/gui/debug/LoggerWidget.py +74 -0
  37. autohelper/gui/debug/__init__.py +0 -0
  38. autohelper/gui/i18n/__init__.py +0 -0
  39. autohelper/gui/i18n/path.py +3 -0
  40. autohelper/gui/icon/__init__.py +0 -0
  41. autohelper/gui/icon/icon.py +6 -0
  42. autohelper/gui/loading/LoadingWindow.py +142 -0
  43. autohelper/gui/loading/__init__.py +0 -0
  44. autohelper/gui/overlay/OverlayWindow.py +34 -0
  45. autohelper/gui/overlay/__init__.py +0 -0
  46. autohelper/gui/resources.py +485 -0
  47. autohelper/gui/tasks/ConfigItemFactory.py +14 -0
  48. autohelper/gui/tasks/StartButton.py +47 -0
  49. autohelper/gui/tasks/TaskOpButton.py +33 -0
  50. autohelper/gui/tasks/TaskTab.py +121 -0
  51. autohelper/gui/tasks/TooltipTableWidget.py +39 -0
  52. autohelper/gui/tasks/__init__.py +0 -0
  53. autohelper/gui/util/Alert.py +20 -0
  54. autohelper/gui/util/InitWorker.py +17 -0
  55. autohelper/gui/util/__init__.py +0 -0
  56. autohelper/gui/widget/ListTableWidgetItem.py +27 -0
  57. autohelper/gui/widget/NumericTableWidgetItem.py +33 -0
  58. autohelper/gui/widget/RoundCornerContainer.py +59 -0
  59. autohelper/gui/widget/TabWidget.py +30 -0
  60. autohelper/gui/widget/UpdateConfigWidgetItem.py +16 -0
  61. autohelper/gui/widget/YesNonWidgetItem.py +23 -0
  62. autohelper/gui/widget/__init__.py +0 -0
  63. autohelper/interaction/ADBInteraction.py +33 -0
  64. autohelper/interaction/BaseInteraction.py +36 -0
  65. autohelper/interaction/Win32Interaction.py +56 -0
  66. autohelper/interaction/__init__.py +0 -0
  67. autohelper/logging/Logger.py +103 -0
  68. autohelper/logging/__init__.py +0 -0
  69. autohelper/ocr/OCR.py +50 -0
  70. autohelper/ocr/__init__.py +0 -0
  71. autohelper/predict/__init__.py +0 -0
  72. autohelper/predict/predict.py +45 -0
  73. autohelper/rotypes/Windows/Foundation/Collections.py +60 -0
  74. autohelper/rotypes/Windows/Foundation/__init__.py +153 -0
  75. autohelper/rotypes/Windows/Globalization/__init__.py +25 -0
  76. autohelper/rotypes/Windows/Graphics/Capture/__init__.py +110 -0
  77. autohelper/rotypes/Windows/Graphics/DirectX/Direct3D11/__init__.py +41 -0
  78. autohelper/rotypes/Windows/Graphics/DirectX/__init__.py +167 -0
  79. autohelper/rotypes/Windows/Graphics/Imaging/__init__.py +34 -0
  80. autohelper/rotypes/Windows/Graphics/__init__.py +5 -0
  81. autohelper/rotypes/Windows/Media/Ocr/__init__.py +76 -0
  82. autohelper/rotypes/Windows/Media/__init__.py +0 -0
  83. autohelper/rotypes/Windows/Security/Cryptography/__init__.py +18 -0
  84. autohelper/rotypes/Windows/Security/__init__.py +0 -0
  85. autohelper/rotypes/Windows/Storage/Streams/__init__.py +27 -0
  86. autohelper/rotypes/Windows/Storage/__init__.py +0 -0
  87. autohelper/rotypes/Windows/__init__.py +0 -0
  88. autohelper/rotypes/__init__.py +4 -0
  89. autohelper/rotypes/delegate.py +105 -0
  90. autohelper/rotypes/export.py +21 -0
  91. autohelper/rotypes/idldsl.py +272 -0
  92. autohelper/rotypes/inspectable.py +79 -0
  93. autohelper/rotypes/roapi.py +30 -0
  94. autohelper/rotypes/types.py +77 -0
  95. autohelper/rotypes/winstring.py +44 -0
  96. autohelper/save/BlackBarProcessor.py +25 -0
  97. autohelper/save/PostProcessor.py +6 -0
  98. autohelper/save/SaveByInterval.py +30 -0
  99. autohelper/save/SaveByKeyPress.py +27 -0
  100. autohelper/save/SaveMethodBase.py +46 -0
  101. autohelper/save/__init__.py +0 -0
  102. autohelper/scene/FeatureScene.py +14 -0
  103. autohelper/scene/Scene.py +21 -0
  104. autohelper/scene/__init__.py +0 -0
  105. autohelper/stats/StreamStats.py +34 -0
  106. autohelper/stats/__init__.py +0 -0
  107. autohelper/task/BaseTask.py +109 -0
  108. autohelper/task/ExecutorOperation.py +119 -0
  109. autohelper/task/FindFeatureTask.py +6 -0
  110. autohelper/task/TaskExecutor.py +249 -0
  111. autohelper/task/__init__.py +0 -0
  112. autohelper/util/__init__.py +0 -0
  113. autohelper/util/json.py +27 -0
  114. autohelper/util/list.py +2 -0
  115. autohelper/util/path.py +37 -0
  116. autohelper/util/thread.py +12 -0
  117. autohelper/util/win32_process.py +86 -0
  118. autohelper/util/yaml.py +28 -0
  119. ok_script-0.0.7.dist-info/METADATA +64 -0
  120. ok_script-0.0.7.dist-info/RECORD +122 -0
  121. ok_script-0.0.7.dist-info/WHEEL +5 -0
  122. ok_script-0.0.7.dist-info/top_level.txt +1 -0
@@ -0,0 +1,103 @@
1
+ import logging
2
+ import os
3
+ import traceback
4
+ from logging.handlers import TimedRotatingFileHandler
5
+
6
+ from autohelper.gui.Communicate import communicate
7
+ from autohelper.util.path import get_path_relative_to_exe, ensure_dir_for_file
8
+
9
+
10
+ class CommunicateHandler(logging.Handler):
11
+ def __init__(self):
12
+ super().__init__()
13
+
14
+ def emit(self, record):
15
+ log_message = self.format(record)
16
+ communicate.log.emit(record.levelno, log_message)
17
+
18
+
19
+ formatter = logging.Formatter('%(asctime)s %(levelname)s %(threadName)s %(message)s')
20
+ communicate_handler = CommunicateHandler()
21
+ communicate_handler.setFormatter(formatter)
22
+
23
+
24
+ def get_substring_from_last_dot_exclusive(s):
25
+ # Find the last occurrence of "."
26
+ last_dot_index = s.rfind(".")
27
+ # If there's no ".", return an empty string or the original string based on your need
28
+ if last_dot_index == -1:
29
+ return "" # or return s to return the whole string if there's no dot
30
+ # Slice the string from just after the last "." to the end
31
+ return s[last_dot_index + 1:]
32
+
33
+
34
+ auto_helper_logger = logging.getLogger("autohelper")
35
+
36
+
37
+ def config_logger(config):
38
+ if config.get('debug'):
39
+ auto_helper_logger.setLevel(logging.DEBUG)
40
+ else:
41
+ auto_helper_logger.setLevel(logging.INFO)
42
+
43
+ auto_helper_logger.handlers = []
44
+ console_handler = logging.StreamHandler()
45
+ console_handler.setFormatter(formatter)
46
+ auto_helper_logger.addHandler(console_handler)
47
+ auto_helper_logger.addHandler(communicate_handler)
48
+ logging.getLogger().handlers = []
49
+
50
+ if config.get('log_file'):
51
+ logger_file = get_path_relative_to_exe(config.get('log_file'))
52
+ ensure_dir_for_file(logger_file)
53
+
54
+ os.makedirs("logs", exist_ok=True)
55
+ # File handler with rotation
56
+ file_handler = TimedRotatingFileHandler(logger_file, when="midnight", interval=1,
57
+ backupCount=7, encoding='utf-8')
58
+ file_handler.setFormatter(formatter)
59
+ file_handler.setLevel(logging.DEBUG) # File handler level
60
+ auto_helper_logger.addHandler(file_handler)
61
+
62
+ if config.get('error_log_file'):
63
+ error_log_file = get_path_relative_to_exe(config.get('error_log_file'))
64
+ ensure_dir_for_file(error_log_file)
65
+
66
+ os.makedirs("logs", exist_ok=True)
67
+ # File handler with rotation
68
+ file_handler = TimedRotatingFileHandler(error_log_file, when="midnight", interval=1,
69
+ backupCount=7, encoding='utf-8')
70
+ file_handler.setFormatter(formatter)
71
+ file_handler.setLevel(logging.ERROR) # File handler level
72
+ auto_helper_logger.addHandler(file_handler)
73
+
74
+
75
+ class Logger:
76
+ def __init__(self, name):
77
+ # Initialize the logger with the name of the subclass
78
+ self.logger = auto_helper_logger
79
+ self.name = name.split('.')[-1]
80
+
81
+ def debug(self, message):
82
+ self.logger.debug(f"{self.name}:{message}")
83
+
84
+ def info(self, message):
85
+ self.logger.info(f"{self.name}:{message}")
86
+
87
+ def warning(self, message):
88
+ self.logger.warning(f"{self.name}:{message}")
89
+
90
+ def error(self, message, exception=None):
91
+ if exception is not None:
92
+ traceback.print_exc()
93
+ stack_trace_str = traceback.format_exc()
94
+ else:
95
+ stack_trace_str = ""
96
+ self.logger.error(f"{self.name}:{message} {stack_trace_str}")
97
+
98
+ def critical(self, message):
99
+ self.logger.critical(f"{self.name}:{message}")
100
+
101
+
102
+ def get_logger(name):
103
+ return Logger(name)
File without changes
autohelper/ocr/OCR.py ADDED
@@ -0,0 +1,50 @@
1
+ import time
2
+
3
+ from autohelper.feature.Box import Box, sort_boxes, find_boxes_by_name
4
+ from autohelper.gui.Communicate import communicate
5
+ from autohelper.logging.Logger import get_logger
6
+
7
+ logger = get_logger(__name__)
8
+
9
+
10
+ class OCR:
11
+ executor = None
12
+ default_threshold = 0.6
13
+
14
+ def ocr(self, box: Box = None, match=None, threshold=0):
15
+ if threshold == 0:
16
+ threshold = self.default_threshold
17
+ start = time.time()
18
+ image = self.frame
19
+ if image is not None:
20
+ if box is not None:
21
+ x, y, w, h = box.x, box.y, box.width, box.height
22
+ image = image[y:y + h, x:x + w]
23
+
24
+ result, _ = self.executor.ocr(image, use_det=True, use_cls=False, use_rec=True)
25
+ detected_boxes = []
26
+ # Process the results and create Box objects
27
+ if result is not None:
28
+ for res in result:
29
+ pos = res[0]
30
+ text = res[1]
31
+ confidence = res[2]
32
+ if confidence >= threshold:
33
+ detected_box = Box(int(pos[0][0]), int(pos[0][1]), int(pos[2][0] - pos[0][0]),
34
+ int(pos[2][1] - pos[0][1]),
35
+ confidence, text)
36
+ if box is not None:
37
+ detected_box.x += box.x
38
+ detected_box.y += box.y
39
+ detected_boxes.append(detected_box)
40
+ if match is not None:
41
+ detected_boxes = find_boxes_by_name(detected_boxes, match)
42
+ communicate.draw_box.emit("ocr", detected_boxes, "red")
43
+ communicate.draw_box.emit("ocr_zone", box, "blue")
44
+ logger.debug(f"ocr_zone {box} found result: {len(detected_boxes)}) time: {time.time() - start}")
45
+ return sort_boxes(detected_boxes)
46
+
47
+ def find_text(self, text, box: Box = None, confidence=0):
48
+ for result in self.ocr(box, confidence):
49
+ if result.name == text:
50
+ return result
File without changes
File without changes
@@ -0,0 +1,45 @@
1
+ import torch
2
+ from PIL import Image, ImageDraw
3
+ import numpy as np
4
+ from ultralytics import YOLO
5
+
6
+ # Load the model
7
+ # model = torch.hub.load('ultralytics/yolov8', 'custom', path='models/best.pt')
8
+ model = YOLO('models/best.pt') # pretrained YOLOv8n model
9
+
10
+ # Run batched inference on a list of images
11
+ # results = model(['im1.jpg', 'im2.jpg']) # return a list of Results objects
12
+
13
+ # Load an image
14
+ image_path = 'images/3.jpg'
15
+ image = Image.open(image_path)
16
+
17
+ # Perform inference
18
+ results = model(image)
19
+
20
+ # Extract data
21
+ for result in results:
22
+ boxes = result.boxes # Boxes object for bbox outputs
23
+ print(boxes)
24
+ masks = result.masks # Masks object for segmentation masks outputs
25
+ keypoints = result.keypoints # Keypoints object for pose outputs
26
+ probs = result.probs # Probs object for classification outputs
27
+
28
+ for r in results:
29
+ im_array = r.plot() # plot a BGR numpy array of predictions
30
+ im = Image.fromarray(im_array[..., ::-1]) # RGB PIL image
31
+ im.show() # show image
32
+ im.save('results.jpg') # save image
33
+ # labels, cord = results.xyxyn[0][:, -1], results.xyxyn[0][:, :-1]
34
+
35
+ # # Draw bounding boxes and labels
36
+ # draw = ImageDraw.Draw(image)
37
+ # for label, (*xyxy,) in zip(labels, cord):
38
+ # label = model.module.names[int(label)] # Get label name
39
+ # xyxy = (xyxy * np.array([image.width, image.height, image.width, image.height])).tolist() # Scale coords
40
+ # draw.rectangle(xyxy, outline='red', width=3)
41
+ # draw.text(xyxy[:2], label, fill='red')
42
+
43
+ # Save or display image
44
+ # image.save('output/1.jpg')
45
+ # image.show()
@@ -0,0 +1,60 @@
1
+ from ctypes import c_uint, c_uint32, c_bool
2
+ from functools import lru_cache
3
+
4
+ from _ctypes import POINTER
5
+
6
+ from autohelper.rotypes.idldsl import define_winrt_com_method, pinterface_type
7
+ from autohelper.rotypes.inspectable import IInspectable
8
+
9
+
10
+ class IIterator_helpers:
11
+ def __next__(self):
12
+ if self.HasCurrent:
13
+ value = self.Current
14
+ self.MoveNext()
15
+ return value
16
+ raise StopIteration
17
+
18
+ def __iter__(self):
19
+ return self
20
+
21
+
22
+ @lru_cache()
23
+ def IIterator(T):
24
+ cls = pinterface_type('IIterator', '6a79e863-4300-459a-9966-cbb660963ee1', (T,), (IInspectable, IIterator_helpers))
25
+ define_winrt_com_method(cls, 'get_Current', propget=T, vtbl=6)
26
+ define_winrt_com_method(cls, 'get_HasCurrent', propget=c_bool, vtbl=7)
27
+ define_winrt_com_method(cls, 'MoveNext', retval=c_bool, vtbl=8)
28
+ define_winrt_com_method(cls, 'GetMany', c_uint, POINTER(T), POINTER(c_uint), retval=c_uint32, vtbl=9)
29
+ return cls
30
+
31
+
32
+ class IIterable_helpers(object):
33
+ def __iter__(self):
34
+ return self.First
35
+
36
+
37
+ @lru_cache()
38
+ def IIterable(T):
39
+ cls = pinterface_type('IIterable', 'faa585ea-6214-4217-afda-7f46de5869b3', (T,), (IInspectable, IIterable_helpers))
40
+ define_winrt_com_method(cls, 'get_First', propget=IIterator(T), vtbl=6)
41
+ return cls
42
+
43
+
44
+ class IVectorView_helpers:
45
+ def __len__(self):
46
+ return self.Size
47
+
48
+ def __getitem__(self, item):
49
+ return self.GetAt(c_uint(item))
50
+
51
+
52
+ @lru_cache()
53
+ def IVectorView(T):
54
+ cls = pinterface_type('IVectorView', 'bbe1fa4c-b0e3-4583-baef-1f1b2e483e56', (T,),
55
+ (IIterable(T), IVectorView_helpers))
56
+ define_winrt_com_method(cls, 'GetAt', c_uint, retval=T, vtbl=6)
57
+ define_winrt_com_method(cls, 'get_Size', propget=c_uint32, vtbl=7)
58
+ define_winrt_com_method(cls, 'IndexOf', T, POINTER(c_uint32), retval=c_bool, vtbl=8)
59
+ define_winrt_com_method(cls, 'GetMany', c_uint, c_uint, POINTER(IInspectable), POINTER(c_uint), vtbl=9)
60
+ return cls
@@ -0,0 +1,153 @@
1
+ import asyncio
2
+ from ctypes import Structure, c_float, HRESULT, c_int, windll, c_uint32, c_int32, WinError
3
+
4
+ from autohelper.rotypes import delegate, HSTRING
5
+ from autohelper.rotypes.idldsl import define_winrt_com_method, generics_cache, define_winrt_com_delegate, pinterface_type, \
6
+ GUID
7
+ from autohelper.rotypes.inspectable import IInspectable, IUnknown
8
+
9
+ _kernel32 = windll.LoadLibrary('kernel32.dll')
10
+ _CreateEvent = _kernel32.CreateEventW
11
+ _SetEvent = _kernel32.SetEvent
12
+ _WaitForSingleObject = _kernel32.WaitForSingleObject
13
+ _CloseHandle = _kernel32.CloseHandle
14
+
15
+
16
+ class Rect(Structure):
17
+ _fields_ = (('x', c_float), ('y', c_float), ('width', c_float), ('height', c_float))
18
+
19
+
20
+ class AsyncStatus(c_int32):
21
+ Started = 0
22
+ Completed = 1
23
+ Canceled = 2
24
+ Error = 3
25
+
26
+
27
+ @GUID('00000036-0000-0000-C000-000000000046')
28
+ class IAsyncInfo(IInspectable):
29
+ pass
30
+
31
+
32
+ @generics_cache
33
+ def AsyncOperationCompletedHandler(T):
34
+ cls = pinterface_type('IAsyncOperationCompletedHandler', 'fcdcf02c-e5d8-4478-915a-4d90b74b83a5', (T,),
35
+ (IUnknown, delegate.delegatebase))
36
+ AsyncOperationCompletedHandler.known_types[(T,)] = cls
37
+ define_winrt_com_delegate(cls, IAsyncOperation(T), AsyncStatus)
38
+ return cls
39
+
40
+
41
+ # IAsyncOperation<IInspectable>
42
+ class IAsyncOperation_helpers:
43
+ def as_future(self):
44
+ # FIXME: doesn't work
45
+ future = asyncio.Future()
46
+ if self.Status == AsyncStatus.Completed:
47
+ future.set_result(self.GetResults())
48
+ return future
49
+
50
+ def callback(iao, status):
51
+ status = status.value
52
+ if status == AsyncStatus.Completed:
53
+ result = self.GetResults()
54
+ future.set_result(result)
55
+ elif status == AsyncStatus.Error:
56
+ hr = iao.ErrorCode
57
+ future.set_exception(WinError(hr))
58
+ elif status == AsyncStatus.Canceled:
59
+ future.cancel()
60
+
61
+ delegatetype = AsyncOperationCompletedHandler(self.__class__._typeparam[0])
62
+ delegateobj = delegatetype.delegate(callback)
63
+ self.Completed = delegateobj
64
+ return future
65
+
66
+ def wait(self):
67
+ if self.Status == AsyncStatus.Completed:
68
+ return self.GetResults()
69
+ event = _CreateEvent(None, False, False, None)
70
+ results = []
71
+
72
+ def callback(iao, status):
73
+ status = status.value
74
+ if status == AsyncStatus.Completed:
75
+ result = iao.GetResults()
76
+ results.append(result)
77
+ _SetEvent(event)
78
+ elif status == AsyncStatus.Error:
79
+ hr = iao.ErrorCode
80
+ results.append(WinError(hr))
81
+ _SetEvent(event)
82
+ elif status == AsyncStatus.Canceled:
83
+ results.append(RuntimeError('AsyncStatus.Canceled'))
84
+
85
+ delegatetype = AsyncOperationCompletedHandler(self.__class__._typeparam[0])
86
+ delegateobj = delegatetype.delegate(callback)
87
+ self.Completed = delegateobj
88
+ # delegateobj._detach()
89
+ _WaitForSingleObject(event, -1)
90
+ _CloseHandle(event)
91
+ result = results[0]
92
+ if isinstance(result, BaseException):
93
+ raise result
94
+ else:
95
+ return result
96
+
97
+ def __await__(self):
98
+ return self.as_future().__await__()
99
+
100
+
101
+ @generics_cache
102
+ def IAsyncOperation(T):
103
+ cls = pinterface_type('IAsyncOperation', '9fc2b0bb-e446-44e2-aa61-9cab8f636af2', (T,),
104
+ (IAsyncInfo, IAsyncOperation_helpers))
105
+ IAsyncOperation.known_types[(T,)] = cls
106
+ define_winrt_com_method(cls, 'put_Completed', propput=AsyncOperationCompletedHandler(T), vtbl=6)
107
+ define_winrt_com_method(cls, 'get_Completed', propget=AsyncOperationCompletedHandler(T), vtbl=7)
108
+ define_winrt_com_method(cls, 'GetResults', retval=T, vtbl=8)
109
+ return cls
110
+
111
+
112
+ @generics_cache
113
+ def IReference(T):
114
+ cls = pinterface_type('IReference', '61c17706-2d65-11e0-9ae8-d48564015472', (T,), (IInspectable,))
115
+ IAsyncOperation.known_types[(T,)] = cls
116
+ define_winrt_com_method(cls, 'get_Value', propget=T, vtbl=6)
117
+ return cls
118
+
119
+
120
+ @GUID('30d5a829-7fa4-4026-83bb-d75bae4ea99e')
121
+ class IClosable(IInspectable):
122
+ def __enter__(self):
123
+ pass
124
+
125
+ def __exit__(self, exc_type, exc_val, exc_tb):
126
+ self.Close()
127
+
128
+
129
+ @GUID('96369f54-8eb6-48f0-abce-c1b211e627c3')
130
+ class IStringable(IInspectable):
131
+ def __str__(self):
132
+ return str(self.ToString())
133
+
134
+
135
+ @generics_cache
136
+ def TypedEventHandler(TSender, TResult):
137
+ cls = pinterface_type('IAsyncOperationCompletedHandler',
138
+ GUID(2648818996, 27361, 4576, 132, 225, 24, 169, 5, 188, 197, 63), (TSender, TResult),
139
+ (IUnknown, delegate.delegatebase))
140
+ TypedEventHandler.known_types[(TSender, TResult)] = cls
141
+ define_winrt_com_delegate(cls, TSender, TResult)
142
+ return cls
143
+
144
+
145
+ define_winrt_com_method(IAsyncInfo, 'get_Id', propget=c_uint32)
146
+ define_winrt_com_method(IAsyncInfo, 'get_Status', propget=c_int)
147
+ define_winrt_com_method(IAsyncInfo, 'get_ErrorCode', propget=HRESULT)
148
+ define_winrt_com_method(IAsyncInfo, 'Cancel')
149
+ define_winrt_com_method(IAsyncInfo, 'Close')
150
+
151
+ define_winrt_com_method(IClosable, 'Close', vtbl=6)
152
+
153
+ define_winrt_com_method(IStringable, 'ToString', retval=HSTRING, vtbl=6)
@@ -0,0 +1,25 @@
1
+ from autohelper.rotypes.idldsl import define_winrt_com_method, runtimeclass, _static_method, GUID
2
+ from autohelper.rotypes.inspectable import IInspectable
3
+ from autohelper.rotypes.winstring import HSTRING
4
+
5
+
6
+ @GUID('EA79A752-F7C2-4265-B1BD-C4DEC4E4F080')
7
+ class ILanguage(IInspectable):
8
+ pass
9
+
10
+
11
+ @GUID('9B0252AC-0C27-44F8-B792-9793FB66C63E')
12
+ class ILanguageFactory(IInspectable):
13
+ pass
14
+
15
+
16
+ class Language(runtimeclass, ILanguage):
17
+ CreateLanguage = _static_method(ILanguageFactory, 'CreateLanguage')
18
+
19
+
20
+ define_winrt_com_method(ILanguage, 'get_LanguageTag', propget=HSTRING, vtbl=6)
21
+ define_winrt_com_method(ILanguage, 'get_DisplayName', propget=HSTRING, vtbl=7)
22
+ define_winrt_com_method(ILanguage, 'get_NativeName', propget=HSTRING, vtbl=8)
23
+ define_winrt_com_method(ILanguage, 'get_Script', propget=HSTRING, vtbl=9)
24
+
25
+ define_winrt_com_method(ILanguageFactory, 'CreateLanguage', HSTRING, retval=Language, vtbl=6)
@@ -0,0 +1,110 @@
1
+ from ctypes import c_bool, c_int32, c_int64
2
+ from ctypes.wintypes import HWND, HMONITOR
3
+
4
+ from autohelper.rotypes.Windows.Foundation import IClosable, TypedEventHandler
5
+ from autohelper.rotypes.Windows.Graphics import SizeInt32
6
+ from autohelper.rotypes.Windows.Graphics.DirectX import DirectXPixelFormat
7
+ from autohelper.rotypes.idldsl import define_winrt_com_method, runtimeclass, GUID, \
8
+ runtimeclass_add_statics
9
+ from autohelper.rotypes.inspectable import IInspectable, IUnknown
10
+ from autohelper.rotypes.types import REFGUID
11
+ from autohelper.rotypes.winstring import HSTRING
12
+
13
+
14
+ @GUID('FA50C623-38DA-4B32-ACF3-FA9734AD800E')
15
+ class IDirect3D11CaptureFrame(IInspectable):
16
+ pass
17
+
18
+
19
+ @GUID('24EB6D22-1975-422E-82E7-780DBD8DDF24')
20
+ class IDirect3D11CaptureFramePool(IInspectable):
21
+ pass
22
+
23
+
24
+ @GUID('589B103F-6BBC-5DF5-A991-02E28B3B66D5')
25
+ class IDirect3D11CaptureFramePoolStatics2(IInspectable):
26
+ pass
27
+
28
+
29
+ @GUID('79C3F95B-31F7-4EC2-A464-632EF5D30760')
30
+ class IGraphicsCaptureItem(IInspectable):
31
+ pass
32
+
33
+
34
+ @GUID('814E42A9-F70F-4AD7-939B-FDDCC6EB880D')
35
+ class IGraphicsCaptureSession(IInspectable):
36
+ pass
37
+
38
+
39
+ @GUID('2C39AE40-7D2E-5044-804E-8B6799D4CF9E')
40
+ class IGraphicsCaptureSession2(IInspectable):
41
+ pass
42
+
43
+
44
+ @GUID('F2CDD966-22AE-5EA1-9596-3A289344C3BE')
45
+ class IGraphicsCaptureSession3(IInspectable):
46
+ pass
47
+
48
+
49
+ @GUID('3628E81B-3CAC-4C60-B7F4-23CE0E0C3356')
50
+ class IGraphicsCaptureItemInterop(IUnknown):
51
+ pass
52
+
53
+
54
+ class Direct3D11CaptureFrame(runtimeclass, IDirect3D11CaptureFrame, IClosable):
55
+ pass
56
+
57
+
58
+ class Direct3D11CaptureFramePool(runtimeclass, IDirect3D11CaptureFramePool, IClosable):
59
+ pass
60
+
61
+
62
+ class GraphicsCaptureItem(runtimeclass, IGraphicsCaptureItem):
63
+ pass
64
+
65
+
66
+ class GraphicsCaptureSession(runtimeclass, IGraphicsCaptureSession, IGraphicsCaptureSession2, IGraphicsCaptureSession3,
67
+ IClosable):
68
+ pass
69
+
70
+
71
+ define_winrt_com_method(IDirect3D11CaptureFrame, 'get_Surface', propget=IInspectable)
72
+ define_winrt_com_method(IDirect3D11CaptureFrame, 'get_SystemRelativeTime',
73
+ propget=c_int64) # FIXME: Windows.Foundation.TimeSpan
74
+ define_winrt_com_method(IDirect3D11CaptureFrame, 'get_ContentSize', propget=SizeInt32)
75
+
76
+ define_winrt_com_method(IDirect3D11CaptureFramePool, 'Recreate',
77
+ IInspectable['Windows.Graphics.DirectX.Direct3D11.IDirect3DDevice'], DirectXPixelFormat,
78
+ c_int32, SizeInt32) # FIXME: Windows.Graphics.DirectX.DirectXPixelFormat
79
+ define_winrt_com_method(IDirect3D11CaptureFramePool, 'TryGetNextFrame', retval=Direct3D11CaptureFrame)
80
+ define_winrt_com_method(IDirect3D11CaptureFramePool, 'add_FrameArrived',
81
+ TypedEventHandler(Direct3D11CaptureFramePool, IInspectable), retval=c_int64)
82
+ define_winrt_com_method(IDirect3D11CaptureFramePool, 'remove_FrameArrived', c_int64)
83
+ define_winrt_com_method(IDirect3D11CaptureFramePool, 'CreateCaptureSession', GraphicsCaptureItem,
84
+ retval=GraphicsCaptureSession)
85
+ define_winrt_com_method(IDirect3D11CaptureFramePool, 'get_DispatcherQueue',
86
+ propget=IInspectable['Windows.System.DispatcherQueue'])
87
+
88
+ define_winrt_com_method(IDirect3D11CaptureFramePoolStatics2, 'CreateFreeThreaded',
89
+ IInspectable['Windows.Graphics.DirectX.Direct3D11.IDirect3DDevice'], DirectXPixelFormat,
90
+ c_int32, SizeInt32,
91
+ retval=Direct3D11CaptureFramePool) # R: Windows.Graphics.DirectX.DirectXPixelFormat
92
+
93
+ define_winrt_com_method(IGraphicsCaptureItem, 'get_DisplayName', propget=HSTRING)
94
+ define_winrt_com_method(IGraphicsCaptureItem, 'get_Size', propget=SizeInt32)
95
+ define_winrt_com_method(IGraphicsCaptureItem, 'add_Closed', TypedEventHandler(GraphicsCaptureItem, IInspectable),
96
+ retval=c_int64)
97
+ define_winrt_com_method(IGraphicsCaptureItem, 'remove_Closed', c_int64)
98
+
99
+ define_winrt_com_method(IGraphicsCaptureSession, 'StartCapture')
100
+
101
+ define_winrt_com_method(IGraphicsCaptureSession2, 'get_IsCursorCaptureEnabled', propget=c_bool)
102
+ define_winrt_com_method(IGraphicsCaptureSession2, 'put_IsCursorCaptureEnabled', propput=c_bool)
103
+
104
+ define_winrt_com_method(IGraphicsCaptureSession3, 'get_IsBorderRequired', propget=c_bool)
105
+ define_winrt_com_method(IGraphicsCaptureSession3, 'put_IsBorderRequired', propput=c_bool)
106
+
107
+ define_winrt_com_method(IGraphicsCaptureItemInterop, 'CreateForWindow', HWND, REFGUID, retval=GraphicsCaptureItem)
108
+ define_winrt_com_method(IGraphicsCaptureItemInterop, 'CreateForMonitor', HMONITOR, REFGUID, retval=GraphicsCaptureItem)
109
+
110
+ runtimeclass_add_statics(Direct3D11CaptureFramePool, IDirect3D11CaptureFramePoolStatics2)
@@ -0,0 +1,41 @@
1
+ import ctypes
2
+
3
+ import autohelper.rotypes as rotypes
4
+ import autohelper.rotypes.Windows.Foundation
5
+ import autohelper.rotypes.idldsl
6
+ from autohelper.rotypes.types import REFGUID
7
+
8
+
9
+ @rotypes.idldsl.GUID('A37624AB-8D5F-4650-9D3E-9EAE3D9BC670')
10
+ class _IDirect3DDevice(rotypes.IInspectable):
11
+ pass
12
+
13
+
14
+ class IDirect3DDevice(_IDirect3DDevice, rotypes.Windows.Foundation.IClosable):
15
+ pass
16
+
17
+
18
+ @rotypes.idldsl.GUID('0BF4A146-13C1-4694-BEE3-7ABF15EAF586')
19
+ class _IDirect3DSurface(rotypes.IInspectable):
20
+ pass
21
+
22
+
23
+ class IDirect3DSurface(_IDirect3DSurface, rotypes.Windows.Foundation.IClosable):
24
+ pass
25
+
26
+
27
+ @rotypes.idldsl.GUID('A9B3D012-3DF2-4EE3-B8D1-8695F457D3C1')
28
+ class IDirect3DDxgiInterfaceAccess(rotypes.IUnknown):
29
+ pass
30
+
31
+
32
+ rotypes.idldsl.define_winrt_com_method(IDirect3DDxgiInterfaceAccess, 'GetInterface', REFGUID, retval=rotypes.IUnknown)
33
+
34
+ _CreateDirect3D11DeviceFromDXGIDevice = ctypes.oledll.d3d11.CreateDirect3D11DeviceFromDXGIDevice
35
+ _CreateDirect3D11DeviceFromDXGIDevice.argtypes = (rotypes.IUnknown, ctypes.POINTER(rotypes.IInspectable))
36
+
37
+
38
+ def CreateDirect3D11DeviceFromDXGIDevice(dxgidev):
39
+ outptr = rotypes.IInspectable()
40
+ _CreateDirect3D11DeviceFromDXGIDevice(dxgidev, ctypes.byref(outptr))
41
+ return outptr