飞道的博客

使用CyberController来将旧手机改造成电脑外挂

522人阅读  评论(0)

这个是我在哔哩哔哩中发现的感觉比较实用在这里发表一下使用过程中的问题和见解

原作者视频旧手机改电脑外挂-效率或将“提升300%?”_哔哩哔哩_bilibili

参考视频旧手机改电脑外挂,简陋的参考视频_手机游戏热门视频 (bilibili.com)

  

 

 感谢这两位博主

 这个是文字教程和番外篇​​​​​​使用CyberController来将旧手机改造成电脑外挂------手机交互翻译、人脸解锁、语音识别....各个功能等你来探索_我真的爱发明的博客-CSDN博客_cybercontroller



zCyberController手机外挂番外篇:源代码的二次修改_二次更改外挂_我真的爱发明的博客-CSDN博客

 如果不能用或者出了BUG可以把KeyboardListener.py的代码改成如下所示


  
  1. import keyboard
  2. import time
  3. from screen_shot import ScreenCapture
  4. import io
  5. import pyautogui
  6. class KeyboardListener:
  7. def __init__( self, tcpServer):
  8. self.tcpServer = tcpServer
  9. self.t = 0
  10. self.c = 0
  11. self.key_state_map={}
  12. self.screen_capture = None
  13. def listen_keyboard( self,callback):
  14. self.callback = callback
  15. keyboard.hook(self.onKeyEvent)
  16. keyboard.wait()
  17. def onImgCapture( self,pic):
  18. imgByteArr = io.BytesIO()
  19. pic.save(imgByteArr, format= 'JPEG')
  20. bytes_data = imgByteArr.getvalue()
  21. self.tcpServer.send_img(bytes_data)
  22. def isCtrlHolding( self):
  23. return ( 'ctrl' in self.key_state_map and self.key_state_map[ 'ctrl']== 'down')\
  24. or ( 'left ctrl' in self.key_state_map and self.key_state_map[ 'left ctrl']== 'down')\
  25. or ( 'right ctrl' in self.key_state_map and self.key_state_map[ 'right ctrl']== 'down')
  26. def isAltHolding( self):
  27. return ( 'alt' in self.key_state_map and self.key_state_map[ 'alt']== 'down')\
  28. or ( 'left alt' in self.key_state_map and self.key_state_map[ 'left alt']== 'down')\
  29. or ( 'right alt' in self.key_state_map and self.key_state_map[ 'right alt']== 'down')
  30. def isKeyHolding( self,key):
  31. return (key in self.key_state_map and self.key_state_map[key]== 'down')
  32. def onKeyEvent( self,key):
  33. #update key_state_map
  34. self.key_state_map[key.name.lower()]=key.event_type
  35. #is screenshoot?
  36. if self.isKeyHolding( "caps lock")\
  37. and key.event_type== "down"\
  38. and key.name.lower()== "a":
  39. self.screen_capture = ScreenCapture()
  40. self.screen_capture.are_capture(self.onImgCapture)
  41. #print(self.key_state_map)
  42. #is triple c?
  43. # if key.event_type=="down" \
  44. # and key.name.lower()=="c" \
  45. # and self.isCtrlHolding():
  46. #
  47. # if self.t == 0:
  48. # self.t=time.time()
  49. # self.c += 1
  50. # print("wait for nex c",self.c)
  51. # return
  52. #
  53. # if (time.time()-self.t<0.5):
  54. # self.t=time.time()
  55. # self.c += 1
  56. # print("wait for nex c:",self.c)
  57. #
  58. # else:
  59. # self.c = 0
  60. # self.t=0
  61. # print("wait for nex c",self.c)
  62. #
  63. # if self.c>=2:
  64. # self.c=0
  65. # print("need trans")
  66. # if self.callback:
  67. # self.callback()
  68. if key.event_type== "down" \
  69. and key.name.lower()== "q" \
  70. and self.isCtrlHolding():
  71. pyautogui.hotkey( 'ctrl', 'c')
  72. print( "need trans")
  73. if self.callback:
  74. self.callback()

如果自动杀进程的的话修改Controller.py为如下代码


  
  1. import json
  2. import time
  3. from ComputerMonitor import ComputerMonitor
  4. from KeyboardListener import KeyboardListener
  5. from TcpServer import TcpServer
  6. from service import *
  7. import threading
  8. def on_message_received( data):
  9. command_message = json.loads(data)
  10. script = command_message[ "script"]
  11. params = command_message[ "params"]
  12. exec(script)
  13. def on_screen_locked():
  14. print( "screen locked")
  15. data = json.dumps({ "command": 2, "message": ""})
  16. print(data)
  17. tcpServer.send_text(data)
  18. computerMonitor = ComputerMonitor(on_screen_locked)
  19. def on_tcp_connected():
  20. if not computerMonitor.started:
  21. computerMonitor.start()
  22. tcpServer = TcpServer()
  23. tcpServer.set_receive_listener(on_message_received)
  24. tcpServer.connected_listener = on_tcp_connected
  25. tcpServer.start()
  26. keyboardListener = KeyboardListener(tcpServer)
  27. def onTrans():
  28. print( "need trans1111")
  29. content = getClipContent()
  30. text = json.dumps({ "command": 1, "message":content})
  31. tcpServer.send_text(text)
  32. def Trans_alive(): #用来进行TCP保活
  33. content = ''
  34. # text = json.dumps({"command":1,"message":content})
  35. text = json.dumps({ "command": 11, "message":content}) #这里之所以用11,而不是1,是因为原作者的command1对应的命令是翻译,会在手机端触发对应的翻译任务看,而11就只相当于是一条空命令了,既可以完成保活,又不会干扰手机端的命令执行,一举两得
  36. print( "text:", text)
  37. tcpServer.send_text(text)
  38. def run():
  39. print( '用来保活的,不用管我')
  40. t = threading.Timer( 3, run)
  41. t.start()
  42. Trans_alive()
  43. t = threading.Timer( 3,run)
  44. t.start()
  45. keyboardListener.listen_keyboard(onTrans)

如果连接不到的话可以按下键盘的win+R

 输入cmd

 查看IP配置

 有几个适配器就用它减一找到TcpServer.py编辑它把红圈圈住的数字改为刚才得到的数字

 好了这就是我的一些见解


转载:https://blog.csdn.net/m0_66674794/article/details/128780703
查看评论
* 以上用户言论只代表其个人观点,不代表本网站的观点或立场