12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- #!/usr/bin/env python
- # -*- encoding: utf-8 -*-
- '''
- @Contact : liuyuqi.gov@msn.cn
- @Time : 2022/10/05 06:31:20
- @License : Copyright © 2017-2022 liuyuqi. All Rights Reserved.
- @Desc : 程序入口
- '''
- import threading
- from cyber.tcp_server import TcpServer
- from cyber.keyboard_listener import KeyboardListener
- from cyber.service import *
- from cyber.computer_monitor import ComputerMonitor
- from cyber.command_message import CommandMessage;
- import json
- import pyautogui
- from cyber.keyboard_manager import *
- import time
- def on_message_received(data):
- '''
- 回调函数, exec执行命令
- '''
- command_message = json.loads(data)
- script = command_message["script"]
- params = command_message["params"]
- exec(script)
- def on_screen_locked():
- '''
- 回调函数
- '''
- print("screen locked")
- data = json.dumps({"command":2,"message":""})
- print(data)
- tcpServer.send_text(data)
- computerMonitor = ComputerMonitor(on_screen_locked)
- def on_tcp_connected():
- '''
- 回调函数
- '''
- if not computerMonitor.started:
- computerMonitor.start()
- def onTrans():
- '''
- 回调函数
- '''
- print("need trans")
- content = getClipContent()
- text = json.dumps({"command":1,"message":content})
- tcpServer.send_text(text)
-
- if __name__=='__main__':
- tcpServer = TcpServer()
- tcpServer.set_receive_listener(on_message_received)
- tcpServer.connected_listener = on_tcp_connected
- tcpServer.start()
-
- # 按键监听
- keyboardListener = KeyboardListener(tcpServer)
- keyboardListener.listen_keyboard(onTrans)
|