});

Win10 & Android Auto

Plan to turn smartphones into workers.

Automate Windows with AHK

send email using AHK

API (App password) Set up ref: {Link}
Script Ref: {Forum Link}

auto hot key

Advantages: AHK use way less computation resources than python scripts.

I mainly use it to replace repetitive works like data inputing or skipping error dialog. The challenge is most reference online now are for AHK 1.0, while 2.0 has more rigorous syntax (rather than a command lines in AHK 1.0). I may share my code as an example here later. Comment below to let me know if you d like to see. 

Here are some quick demos

AHK relies on GUI, which necessitate an active graphic session when remoting a windows server. A round about to keep GUI rendering is below. Save it to a .cmd file and run as admin. Replace %% with % if running in command line.

Automatic win10

Imitate user input

Python imitate users\’ operations on Win10: CSDN
Realized by PyUserInput package.

Using Pycharm to develop a simple simulator of Mouse and Keyboard Input.
And wrap it up to window executable file: .exe!!! (Believe me. This is much harder than coding itself)

Keyboard & Mouse Simulation

Package: pynput
Chinese Introduction: https://www.jb51.net/article/155520.htm
Official doc: https://pypi.org/project/pynput/

The basic idea of using pynput is
listen to the event of a real user with pynput.mouse.Listener or pynput.keyboard.Listener

Then do the step automatically by
pynput.mouse.Controler and pynput.keyboard.Controler

Notice!!!

If you are a windows user
Make sure you install pynput 1.6.8 version. Or you will not be able to wrap it to a exe file.
The code is shown below. (Type it in the cmd)

You can facilitate the wrapping by putting the external package imported in the .py scripts into the same directory.
In my case, I put ‘pynput’ into the same directory.

Another hint for wrapping is about import.
Import pacakge as ‘from … import …‘ will import the method or class independently, which can reduce your .exe file size in most cases.
E.g.

.py to .exe

The popular version

Package: pyinstaller
If you use any third-party package, such as NumPy, pandas, etc., you should copy their package files to the same directory as the .py file going to be packed. 【Pic_Ref
Locate CMD to the directory ready to be packed with all files and packages inside, and type in the command as the example shown below.

Frequently used commands are listed in the table below.

FunctionShort CodeLong code
wrap in one file (Suitable for simple scripts)-F–onefile
wrap in one directory (Easy to maintain)-D–onedir
run with a console (Good for debugging)-c–console
run without a console-w–windowed
attach icon (.ico file)-i ./img.ico–icon=./img.ico
For more

A beginer-friendly GUI version

Package: auto-py-to-exe
Video tutorial from PythonSimplified: https://www.youtube.com/watch?v=Y0HN9tdLuJo

Pycharm GUI interactive design (Not referred this time)

Package: QtGUI, etc.
Link: https://www.cnblogs.com/lightbc/p/14650292.html

Source Code of this trial

Miscellaneous

This is my first project done on PyCharm.
It will create a new virtual environment each time, which will keep the base env and package tidy.
What impressed me most is the auto-reformation. (Alt+Enter+F12)
The window layout with console, terminal, etc, is born for large project development like web or software.
I really like it as a development tool.
But I also realize I don’t need it for most works I need to do at the current stage. And it is hungry for my computational resources.
So I guess the best way is to learn from the format of coding and windows layout combination.

Schedule run

Set schedule program in win10: 简书
With GUI !

Create## Automatic Android

Android Auto

scrcpy电脑控制手机

[项目源-github]
【快速入门-知乎】
下方自带的readme就已经足够详细了

手机端先开启所有USB调试相关选项

Release中下载最新版后,此处以win10为例

常用参考

js常用运算规则:
https://www.cnblogs.com/hujinzhong/p/11549615.html

判断变量类型
type of [Var]

入门与部署:
该链接中的apk下载已经失效【AutoJS部署入门-CSDN】

该文包含AutoJS免费版下载链接【AutoJS实现淘宝自动看广告收喵币-知乎】

运行

运行时可以加入环境变量或是每次都需要先进入当前所在路径打开cmd或powershell
按照对应连接方式,输入命令,并即时在手机上通过验证

也可以将对应路径增加到系统环境变量下

添加至环境变量(可选)

 图形界面(user-friendly)

【图形界面设置环境变量-百度百科】
运行输入sysdm.cpl<code>进入</code>高级设置(Advanced)<code>修改</code>环境变量(Environment Variables)<code>,点击</code>Path,添加adb和scrcpy所在的根路径即可

命令行(Geek最爱)

【利用CMD设置环境变量-脚本之家】

追加完切记重启cmd后才能生效。

其他参考内容:

【ABD Installer-脚本之家】
【win10配置JAVA环境-CSDN】
【scrcpy使用教程简介-CSDN】

常用快捷键

MOD默认代表左Alt,可自行修改
常用如下

完整版输入.\scrcpy.exe --help命令查看

常用scrcpy consoler命令

完整版输入命令同样见–help指令结果


实战:抖音自动脚本开发

点击Auto.js悬浮窗后选择出现的蓝色按钮,点击布局范围分析后选择领喵币按钮查看控件信息

核心是实现文字识别和导出,下列为参考:

  1. 【AutoJS识别微信聊天记录】
  2. 【淘宝喵币&蚂蚁森林】
  3. 【文件操作】
  4. 【AutoJS官方文档】便于查找对应函数的操作
  5. 【javascripts的主要数据类型与运用】 包含较多适合我这样的初学者的讲述

分析他人代码时,用Notepad++(结合Astyle实现自动排版)。
【Astyle使用-CSDN】

最佳的编写和调试方式:局域网下的VSCode电脑编写,远程推送手机运行
【VSCode的配置】
【VSCode入门教程-CSDN】
包含安装和git版本控制。
【VSCode官方下载地址与文档】

个人感想

代码的学习方式,就是通过案例了解大致功能,官方文档查询具体的实现方法,最后通过编程验证。

With AndroidViewClient & Culebra

Analogous to Marco in MS-Office.
Intuitive Graphic interface & user operation recording.
鲲鹏数据抓取

Android Debug Bridge (ADB)

ADB link to Android, control with Python: CSDN

/

Battery & Charging

Battery has the best life span using between 50% to 80%.

ASUS battery health patch. I am using UX370UAF, Flip. It should support Battery Health app, but i cannot find the patch in MS store. Thanks to this {Zhihu post} which shares the patch from official customer support {download link}

Amazfit band

You may find many post about myamazfit.ru, the website is closed {see this reddit post}. However, a more convenient website shows up allow online compilation of ROM {https://amazfitbip.ngxson.com/}. Thanks to MNVolkov {Github page}

To write the ROM, following apps are needed:
Paid:
Tools&Amazfit
Notify for Amazfit (tested can connect and claim can get Auth Key but haven’t got it)
Free:
GadgetBridge (need Auth Key)

A general hint is do this with a backup device as these app requires so many permissions that may comprise your data privacy.