Is there a way to emulate keystrokes and mouse-clicks in a Linux OS such as Raspbian? - python-3.x

I am working on a project that edits photos of mine and then uploads those photos to a google site. I'm using Selenium to upload the photos to the portfolio site, but I need a way to select the image I want to upload from the file manager.
The idea is that this project will run on my Raspberry Pi 3b without any need for human intervention. Is it even possible to emulate human interactions with the OS?
I have done some research and have come across the program AutoKey, but I am not entirely sure if this will work for what I need on Raspbian. Any help would be greatly appreciated.
Update:
I attempted to install autokey on to my raspberry pi, and even though the install seemed successful, I am unable to open or use the application. It seems I may be missing some dependencies or that autokey just isn't compatible on Raspbian. All I really need is a way for me to navigate to the path of the photo I want to upload and to select it.
Second Update:
While searching through the selenium documentation I found this https://selenium-python.readthedocs.io/faq.html#how-to-upload-files-into-file-inputs which seems like it could be a solution. I have not yet had time to try this out yet on both my Macbook and Raspberry Pi.
Final Update
I was able to upload the file using selenium, but part of the process is jerry-rigged to work. I am curious to know if there is another, more professional way to do this so I will leave the question up in the meantime.

Related

All node usb libraries do not work and all give some kind of error

I'm developing a VSCode Extension where you can develop CircuitPython code. I want it to be able to upload your code to your pico, or whatever microcontroller you're using.
For this I need to detect all usb drives that are connected, I've tried libraries like node-usb, usb-detection, etc. But they always give some kind of error, for usb-detection for example you need to rebuild the library with this command:
./node_modules/.bin/electron-rebuild
But then I get greeted with this:
text here: https://pastebin.com/E7bjtWgP
I have absolutely no idea what anything of this means, I've installed vs build tools 2022, 2017 and even added it to my community installation.
After that I tried the usb library. Which again, greets me very kindly with:
I've also tried some other libraries but they all give a similar result. Some do this:
And I've also seen some very questionable things like this:
I've been googling, and debugging now for roughly 4 hours and atm I'm tired so I'll probably try again in a couple of hours.
EDIT:
I've made an entirely new project, moved over all the code and it now works. I have absolutely no idea what the problem was but at least its working now.

libVNC implement remote desktop

I am trying to implement remote desktop server using libvnc, I have downloaded the libvnc and build the library and able to run sample code. And in the example code I can see the function rfbGetScreen http://libvnc.github.io/doc/html/libvncserver_doc.html which display plain background not the desktop. Does that mean I have to find some other library to get desktop and share using vnc, or vnc has some inbuilt function to do this.
it does seem so. You need to put into rfbScreenInfoPtr::framebuffer screenshots. I've never saw any inbuilt functions yet. May be I've poorly searched.
Try SDL2. May be it will help.

Node.js - Writing an image to a USB/SD on Windows

So I've written a program in Electron that will download the latest version of our image and then write it to the selected device.
I've got this working fine for Linux and OSX as I'm able to call a sub process and just run the dd command directly.
My issues come when trying to make this work on Windows, I've not been able to find a node package that does dd or something similar, and natively writing it for Windows doesn't want to work due to the chaining of commands etc.
Does anyone have any suggestions? My next idea would be to write a .bat script that is called by the sub process and try to do it that way. However if there is a platform universal approach with node that would be ideal! Thanks.
I wouldn't start rolling my own approach for this using Node.
Rufus is the current go-to app on Windows for burning images to various media. It has limited command line support – the author says you should try rufus -h to see what's possible.
There's also Etcher CLI, which is "experimental, proceed with caution and report issues". (Also, the Etcher GUI is actually an Electron app, so you might want to peek into what it's doing. https://github.com/resin-io/etcher)
Hope these help.

Linino (openWRT) on arduino Yun & nodejs - Nodejs Serial module not working

I'm using my arduino yun board to try a protocol I've made to control a robot I'm making using arduino.
The same job, using a raspberry pi for the previous project, worked pretty well and I had no issues with anything at all.
Basically, my environment WAS:
Raspberry PI
Arduino mega (board)
NodeJS
NodeJS serial module
Aaaand I had literally no problems, but since I was very confident with the arduino yun board, I decided to try doing basically the same thing but, instead of using my raspberry pi, I wanted to use only my arduino yun board.
After correctly configuring the arduino yun board, compiling, and installing nodejs following this guide, I correctly can run node:
Cool.
Now, npm, unluckily doesn't work (as expected from the above tutorial):
Since npm is not working, I proceded this way:
Under /www/, I've made a directory called "nodejsTEST":
cd www
mkdir nodejsTEST
accessed it, and made a pretty basic server.js file:
The above code works perfectly, and by accessing at arduino.local/nodejsTEST it actually outputs "Ohay :)".
Now, next step:
I downloaded the same library I was using on the raspberry pi:
https://github.com/voodootikigod/node-serialport
and, since I can't use npm, I've copied it to the nodejsTEST folder but, when I'm requiring it from nodejs (I've looked around here in stackoverflow about how to include it correctly) keeps telling that some modules are missing, suchs as this one:
I've tried downloading the module itself but it doesn't work at all, so what I was wondering is where all the modules were stored, since there usually is a /usr/local/bin/node folder.
Surprisingly, there literally is no trace about node.
Even by printing its path and trying to access it, it's telling me the path does not exists:
Any idea of how to solve this issue? I'm really looking forward to be able to use the serial port library with nodejs, since I had a really positive experience on my previous project both from the point of view of the performance and from the point of view of its stability.
Thanks.
After looking around for (quite long) while, I came up with this link:
http://blog.arduino.cc/2014/05/06/time-to-expand-your-yun-disk-space-and-install-node-js/
Which actually allows you to use your external SD card as available space either for linino and for storing basicly anything and, moreover, it actually even allows you to install both Nodejs and the Nodejs-serialport module.

Porting a markdown-live-preview-in-vim plugin from *nix to Windows

I need your help. Because I've no idea what I'm doing.
There is this nice plugin vim-instant-markdown I recently stumbled onto. Basically, it's a live preview in a browser, running in the background, while you're writing your text in markdown plugin, and I like the concept.
So, I've tried to get it to work on Windows,
installed Ruby (rubyinstaller-1.9.3-p125)
installed Ruby-DevKit (DevKit-tdm-32-4.5.2-20111229-1559-sfx)
followed instructions on https://github.com/oneclick/rubyinstaller/wiki/Development-Kit
gem install redcarpet pygments.rb
installed node (node-v0.6.10)
npm -g install instant-markdown-d
So far so good,
I open a markdown file in Vim, and it opens (pause button works here) a command line window with my text inside. Browser not seen anywhere.
In the plugin there is an /dev/null "thing" (I'm not an unix guy, more than I needed to be, which wasn't very much - just an ordinary user for most part). /dev doesn't exist on Windows.
To put long story short, my question is - can this be made to work on Windows, the way it should work, or is it a waste of effort even to try it to get it to work?
I'm welcoming all constructive ideas and suggestions.
glad you found this useful enough to want a Windows port! I think it definitely can be done, you just might need more dependencies and hackage.
First of all, understand that there's a server component that is used apart from the actual .vim file to make this work, which is started and stopped on demand. You will definitely need to look at its code, which can be found here.
The server uses open on OSX and xdg-open on Linux to open a browser window, neither of which exist on Windows. On Windows, you can use start (more here). Try to find a way to make the browser window open in the background, and not steal focus, otherwise it will be very annoying.
Also, curl is used to send commands to the server, and curl doesn't exist for Windows. Indeed, I don't think anything similar exists. There is a curl Windows port, though IMO it kinda sucks to add such a thing as a requirement for the plugin...
It seems that you've taken this on at least partially as a learning experience, so I hope you can make it work and send back a pull request! (Of course feel free to keep asking questions if you're stuck) But in the (hopefully unlikely) event that you lose interest or give up, create an issue in github requesting Windows compatibility, and I'll see if I have time to implement it. Also, keep in mind that some questions/comments will be better suited to the project's issues area than here.
Good luck!

Resources