-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new file: .github/workflows/python.yml modified: Cargo.lock modified: Cargo.toml new file: Python/WindowsCapture/main.py new file: Python/windows-capture-native/.gitignore new file: Python/windows-capture-native/Cargo.lock new file: Python/windows-capture-native/Cargo.toml new file: Python/windows-capture-native/LICENCE new file: Python/windows-capture-native/pyproject.toml new file: Python/windows-capture-native/src/lib.rs modified: README.md new file: examples/basic.rs modified: src/buffer.rs modified: src/capture.rs modified: src/frame.rs modified: src/graphics_capture_api.rs modified: src/lib.rs
- Loading branch information
1 parent
d34fc44
commit 3bd2ced
Showing
17 changed files
with
1,116 additions
and
113 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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: Python | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
env: | ||
CARGO_TERM_COLOR: always | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: windows-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Build | ||
run: cargo build -p windows-capture-native --verbose | ||
- name: Run tests | ||
run: cargo test -p windows-capture-native --verbose |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,55 @@ | ||
# Python Version Is NOT Complete Yet | ||
|
||
|
||
from windows_capture_native import NativeWindowsCapture | ||
|
||
|
||
class Capture: | ||
def __init__(self, capture_cursor: bool = True, draw_border: bool = False): | ||
self.frame_handler = None | ||
self.closed_handler = None | ||
self.capture = NativeWindowsCapture( | ||
False, False, self.on_frame_arrived, self.on_closed | ||
) | ||
self.capture_cursor = capture_cursor | ||
self.draw_border = draw_border | ||
|
||
def start(self): | ||
self.capture.start() | ||
|
||
def on_frame_arrived(self, frame): | ||
if self.frame_handler: | ||
self.frame_handler(frame) | ||
else: | ||
raise Exception("on_frame_arrived Event Handler Is Not Set") | ||
|
||
def on_closed(self): | ||
if self.closed_handler: | ||
self.closed_handler() | ||
else: | ||
raise Exception("on_closed Event Handler Is Not Set") | ||
|
||
def event(self, handler): | ||
if handler.__name__ == "on_frame_arrived": | ||
self.frame_handler = handler | ||
elif handler.__name__ == "on_closed": | ||
self.closed_handler = handler | ||
else: | ||
raise Exception("Invalid Event Handler Use on_frame_arrived Or on_closed") | ||
return handler | ||
|
||
|
||
capture = Capture(False, False) | ||
|
||
|
||
@capture.event | ||
def on_frame_arrived(frame): | ||
print("on_frame_arrived") | ||
|
||
|
||
@capture.event | ||
def on_closed(): | ||
print("on_closed") | ||
|
||
|
||
capture.start() |
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 @@ | ||
target/ |
Oops, something went wrong.