HID devices for virtual machines - python

I've been playing some crypto games and to boost my farming I've been using a bot that controls the mouse to farm my resources.
The bot is built in python and it uses the main hid device to work.
I've been thinking in using VM's to run the bots with the games, but it made me run into a question.
Is it possible to emulate a virtual mouse cursor or something similar to run inside the VM?
This way i wouldn't need to let mt pc sitting farming and not utilizing it and the vm would run the bot and the virtual mouse to farm my cryptos.
Is it possible to emulate HID devices for VMs?
Thank you all in advance.

You can use pyautogui to simulate mouse clicks. You can run the python script inside the VM and then let it run in the background and you can freely use the mouse outside VM.
Usage is simple
import pyautogui
pyautogui.click(100, 100)
To know more about mouse functions refer to the docs https://pyautogui.readthedocs.io/en/latest/mouse.html

Related

Handling remote (RDP) mouse clicking via Python

I am using pyautogui to automate some mouse clicking in a script that I created.
This script needs to perform one click to log into a program, nothing else (besides other non-clicking stuff). The idea is that the script will run on a remote Win10 PC via a task scheduler every day at, lets say, at 11PM.
My script works perfectly when run on my own PC but I am running into issues with how to handle the remote RDP resolution to correctly identify the mouse position to click. Furthermore, the script will run on a remote PC that might not have "active user" logged in and I am not even sure if this mouse clicking approach will work. How to identify correctly the "resolution" of the remote PC?
Could you help me?
Thanks.
Pyautogui can be used to interact with remote system the same way a human can by opening the RDP or VNC window identifying elements inside of it and then directly interacting with them. This works but you're now expecting two systems to be in sufficiently consistent state for the automation to work. This does have the advantage that you don't need to know the resolution of the remote system just what the interactable elements look like when rendered through the RDP client on your system.

Is there Python programming to connect to the ssid of a router without using CMD?

Is there Python programming to connect to the ssid of a router without using CMD?
I have programming working that runs cmd batch files or sends "netsh" commands to the cmd window.
CMD is an excellent debugging tool but I can't believe it was intended to be used seriously for using with own software programming as the cmd editor needs to open, be opened or flash every time a command is sent.
It might help to mention that the stick PC I'm using does not have a physical monitor attached but with a hardware adaption to the HDMI output and VNC software installed so the screen can be viewed on any other computer with a VNC viewer. Mouse and keyboard can also control the PC stick with VNC server running.
As the VNC server will not be active until the Windows 10 has installed itself; precautions such as disabling Automatic Repair at start up, Windows Updates paused or anything else in start up that would require what, will be unseen, requests for mouse clicks or keyboard presses.
It needs programming to connect to a portable router, passively poll the connection to see if the router is still connected and reconnect whenever possible. Without Using CMD.
I have had all this working for a while. It's proving reliable to connect and run but not comfortable to watch because the batch file which loops every 10 minutes uses
netsh wlan connect ssid=YOURSSID name=PROFILENAME interface="WIRELESS NETWORK CONNECTION"
and
'name="name_of_wifi" interface="type_of_network_interface" priority=1'
It keeps opening CMD window and the reconnection first closes the VNC server so on the VNC client the VNC viewer has to be started again.
I haven't used Python yet but before I do I want to know if there is programming and/or libraries available to connect to the ssid of a wifi router without CMD.
Any help on this will be appreciated.

Remote bluetooth camera trigger for phone

I would like to build a camera trigger for my phone by simulating a BLE keyboard that sends the Volume Up key to the phone connected by Bluetooth. I want this because I want to trigger the native Camera app, and not an embedded camera view.
I'm agnostic about technology used but ideally for simplicity I'd like it to be a command line utility in my Macbook, with something like Go or Node.js.
I've looked into Noble for Node.js, which doesn't seem to be oriented at emitting, and found projects for arduino, and found a couple of StackOverflow questions asking the same, but nothing definitive yet.
Apparently the Bleno project for Node.js could be better suited, but apparently it's very outdated.
Would someone please point me in the right direction?
Thank you
Edit
I was able to use Bleno to emit 0xEA and 0xE9 (Volume Up and Volume Down apparently), and using the LightBlue app I'm able to inspect that receive those messages, however, connecting to the MacBook through the phone's bluetooth does not increase/decrease volume.
Edit
Found this outdated project written in Swift 3 for reference
Edit Apparently the pybluez project looks like it could be a good option
You should be able to use the terminal for that. Eg. in Windows, you can start the camera app using start microsoft.windows:camera
Something similar should be available even in Mac. Try that out. Otherwise, go to the root directory where the camera app is stored. And then trigger that from code.
You need to create a Bluetooth HID (or HID over GATT) peripheral that your phone can connect to and will receive the key commands from.
There is a project here that did it with a Raspberry Pi:
https://gist.github.com/ukBaz/a47e71e7b87fbc851b27cde7d1c0fcf0#gistcomment-2997623
Unfornately the underlaying Bluetooth library will not move across to your Mac Book.
The HID protocol is documented here: https://github.com/jpbrucker/BLE_HID/blob/master/doc/HID.md
In summary, I think what your saying is that you want to make an cli application which is on your laptop/desktop connect to your phone via Bluetooth and simulate a volume key from your laptop/desktop keyboard.
Android:
To do this you will need:
Python 3.5 or above
PyBluez
Keyboard(Python module/API)
Android Studio
Java Development Kit 8 (preferably 11 or 14)
Android BLE
So in order to do this I would create a cli application with python3 and I would record the key presses on the laptop/desktop machine by using the keyboard module this then gets transmitted(bluetooth) via the PyBluez module to your phone. Your phone then accepts the bluetooth data via Android BLE and then simulates the volume button press.
DISCLAIMER:
This only works when the phone is already paired to your pc and only work on android phones 4.4.4 and above.
Some Links That Could Help You:
Bluetooth lib for python 3 ,
detect key press in python? ,
Create a socket for 4.0 bluetooth transmission
IOS:
To do this you will need:
Python 3.5 or above
PyBluez
Keyboard(Python module/API)
XCode
Swift
Core Bluetooth Module
So in order to do this I would create a cli application with python3 and I would record the key presses on the laptop/desktop machine by using the keyboard module this then gets transmitted(bluetooth) via the PyBluez module to your phone. Your phone then accepts the bluetooth data via Core Blutooth Module in swift and then simulates the volume button press.
DISCLAIMER:
The phone and laptop/desktop must be paired before it runs this might sound obvious but some people might ignore this.
Some Links That Could Help You:
iOS use the volume buttons as input ,
https://developer.apple.com/documentation/corebluetooth/transferring_data_between_bluetooth_low_energy_devices

Script moving the mouse on a virtual machine

I prepared a script which does some operation on a web page, recognize colors and simulate mouse click and keyboard send keys while running. It works fine.
The problem is that I want it to run on a virtual machine (I'm trying greencloudvps) and it works fine as long as have my eyes on it.
As soon as I close the "remote desktop connection" tool, the script crashes, because (I guess) there is no more a monitor where to move the mouse.
I use the following Python code:
win32api.SetCursorPos((x,y))
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,x,y,0,0)
Is there any solution?
UPDATE:i tried to run my script also on Amazon virtual machine but i got the same problem. Which could be the solution?
Basically I need to click with mouse, read pixel colors and send skeys with keyboard automatically on a virtual machine even when I don’t witness the session, using python

How do I make my discord bot stay online

I recently made a music bot in my discord server but the problem I have is that I have to turn on the bot manually etc. and it goes offline when I turn off my computer. How can I make the bot stay online at all times, even when I'm offline?
You need to run the python script on a server, e.g. an EWS linux instance.
To do that you would need to install python on the server and place the script in the home directory and just run it via a screen.
Use a Raspberry Pi with an internet connection. Install all necessary components and then run the script in its terminal. Then, you can switch off the monitor and the bot will continue running. I recommend that solution to run the bot 24/7. If you don't have a Raspberry Pi, buy one (they're quite cheap), or buy a server to run the code on.

Categories

Resources