parent
dc2acc7284
commit
5c9ec8a98b
|
|
@ -28,12 +28,10 @@ String makecode(String pstr, List pkey) {
|
||||||
|
|
||||||
// 解密
|
// 解密
|
||||||
String cutecode(List<int> pstr) {
|
String cutecode(List<int> pstr) {
|
||||||
print(pstr);
|
|
||||||
int len = pstr.length;
|
int len = pstr.length;
|
||||||
for (int i = 0; i < len; i++) {
|
for (int i = 0; i < len; i++) {
|
||||||
pstr[i] = cutcodeChar(String.fromCharCode(pstr[i])
|
pstr[i] = cutcodeChar(String.fromCharCode(pstr[i])
|
||||||
, skey[i % 5], skey[(i + 18) % 5]).codeUnitAt(0);
|
, skey[i % 5], skey[(i + 18) % 5]).codeUnitAt(0);
|
||||||
}
|
}
|
||||||
print(pstr);
|
|
||||||
return String.fromCharCodes(pstr);
|
return String.fromCharCodes(pstr);
|
||||||
}
|
}
|
||||||
|
|
@ -2,6 +2,8 @@ import 'dart:async';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
|
import 'package:web_synchronization_tool/windows/synchronization_web_tool.dart';
|
||||||
|
|
||||||
import 'little_extension.dart';
|
import 'little_extension.dart';
|
||||||
import 'code.dart';
|
import 'code.dart';
|
||||||
|
|
||||||
|
|
@ -30,8 +32,7 @@ class Socket {
|
||||||
int ic = 1;
|
int ic = 1;
|
||||||
|
|
||||||
connect() async {
|
connect() async {
|
||||||
socket = await RawDatagramSocket.bind('127.0.0.3', 1);
|
socket = await RawDatagramSocket.bind('127.0.0.1', 25501);
|
||||||
print('UDP Socket bound to ${socket?.address.address}:${socket?.port}');
|
|
||||||
|
|
||||||
// 发送身份包
|
// 发送身份包
|
||||||
Map data = {
|
Map data = {
|
||||||
|
|
@ -44,11 +45,25 @@ class Socket {
|
||||||
socket?.listen((RawSocketEvent e) {
|
socket?.listen((RawSocketEvent e) {
|
||||||
Datagram? d = socket?.receive();
|
Datagram? d = socket?.receive();
|
||||||
if (d == null) return;
|
if (d == null) return;
|
||||||
print(d.data.toList());
|
|
||||||
// String message = String.fromCharCodes(d.data).trim();
|
|
||||||
|
|
||||||
Map data = dataCute(d.data);
|
Map data = dataCute(d.data);
|
||||||
|
|
||||||
|
// 收到消息
|
||||||
|
if (data['op'] == 2){
|
||||||
|
|
||||||
|
print(data);
|
||||||
|
|
||||||
|
Map click = data['value']['click'];
|
||||||
|
int x = click['x'] as int;
|
||||||
|
int y = click['y'] as int;
|
||||||
|
|
||||||
|
SynchronizationWebTool.getInstance().clickSynchronization(x, y);
|
||||||
|
|
||||||
|
}
|
||||||
|
// 心跳
|
||||||
|
if (data['op'] == 11){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -103,10 +118,7 @@ class Socket {
|
||||||
|
|
||||||
Uint8List pData = data.sublist(4,data.length);
|
Uint8List pData = data.sublist(4,data.length);
|
||||||
|
|
||||||
// String ps = String.fromCharCodes(pData);
|
|
||||||
|
|
||||||
String str = cutecode(pData);
|
String str = cutecode(pData);
|
||||||
print(str);
|
|
||||||
|
|
||||||
Map map = json.decode(str);
|
Map map = json.decode(str);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -50,8 +50,8 @@ class SynchronizationWebTool{
|
||||||
|
|
||||||
if (event['click'] != null) {
|
if (event['click'] != null) {
|
||||||
Map click = event['click'];
|
Map click = event['click'];
|
||||||
double x = (click['x'] as int).toDouble();
|
int x = click['x'] as int;
|
||||||
double y = (click['y'] as int).toDouble();
|
int y = click['y'] as int;
|
||||||
|
|
||||||
clickSynchronization(x, y);
|
clickSynchronization(x, y);
|
||||||
SocketUtils.getInstance().sendMessage(event);
|
SocketUtils.getInstance().sendMessage(event);
|
||||||
|
|
@ -72,7 +72,7 @@ class SynchronizationWebTool{
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 点击同步
|
/// 点击同步
|
||||||
clickSynchronization(double x,double y){
|
clickSynchronization(int x,int y){
|
||||||
for (var controller in childController) {
|
for (var controller in childController) {
|
||||||
controller.executeScript(WindowsJs.clickJs(x, y));
|
controller.executeScript(WindowsJs.clickJs(x, y));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,7 @@ document.addEventListener("click", function (event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 模拟点击
|
/// 模拟点击
|
||||||
static String clickJs(double x, double y) {
|
static String clickJs(int x, int y) {
|
||||||
return 'document.elementFromPoint($x, $y).click();';
|
return 'document.elementFromPoint($x, $y).click();';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue