mirror of
https://github.com/browser-use/web-ui.git
synced 2026-03-22 11:17:17 +08:00
Update custom_controller.py
This commit is contained in:
@@ -5,10 +5,9 @@
|
||||
# @FileName: custom_action.py
|
||||
|
||||
import pyperclip
|
||||
|
||||
from browser_use.controller.service import Controller
|
||||
from browser_use.agent.views import ActionResult
|
||||
from browser_use.browser.context import BrowserContext
|
||||
from browser_use.controller.service import Controller
|
||||
|
||||
|
||||
class CustomController(Controller):
|
||||
@@ -19,12 +18,12 @@ class CustomController(Controller):
|
||||
def _register_custom_actions(self):
|
||||
"""Register all custom browser actions"""
|
||||
|
||||
@self.registry.action('Copy text to clipboard')
|
||||
@self.registry.action("Copy text to clipboard")
|
||||
def copy_to_clipboard(text: str):
|
||||
pyperclip.copy(text)
|
||||
return ActionResult(extracted_content=text)
|
||||
|
||||
@self.registry.action('Paste text from clipboard', requires_browser=True)
|
||||
@self.registry.action("Paste text from clipboard", requires_browser=True)
|
||||
async def paste_from_clipboard(browser: BrowserContext):
|
||||
text = pyperclip.paste()
|
||||
# send text to browser
|
||||
|
||||
Reference in New Issue
Block a user