In regards to this example that you gave about bluetooth, where the user simply wants to open a control panel and select the correct headphone, throwing them to a bluetooth Python library could be beyond complexity overkill. From their simple code, such a Python library would likely be very problematic, not to mention the massive setup headache.malcev wrote: ↑16 Nov 2020, 18:14For example this topic
https://www.autohotkey.com/boards/viewtopic.php?f=76&t=83224
Ahk does not have bluetooth wrapper.
Therefore Topicstarter has 3 choices.
1) Read msdn, count sizes of structures and write wrapper by himself
2) Use imagesearch popular solution of any problem
3) use python library with examples
https://github.com/pybluez/pybluez
What's best for a casual or intermediate coder, might not be the same as for an advanced coder. And even for an advanced coder, there can be several ways to solve a problem, and which route taken depends on preference.
From this simple code...
Code: Select all
#SingleInstance,force
NumpadPgDn:: ;3 on Numpad
Run, bthprops.cpl
Sleep, 2000
Send, {tab}{tab}{enter}{tab}{enter}
Sleep, 200
Send,!{Tab}
return
Note- ControlSend or ControlClick might possibly work too.
Send {TAB 6}
https://www.autohotkey.com/docs/commands/Send.htm#Repeating_or_Holding_Down_a_Key
(Repeating_or_Holding_Down_a_Key)
The next level of escalating complexity, would arguably have been to have them use the built-in ImageSearch, which clearly you also knew. That would have also solved their problem. Maybe, if you wanted to be fancier about it, could have them convert the .jpg image to Base64, so that that no external file is needed or possibly point them to/show them FindText as well.
https://www.autohotkey.com/docs/commands/ImageSearch.htm
(ImageSearch)
https://www.autohotkey.com/boards/viewtopic.php?t=35964
(Base64 encoder/decoder for Binary data)
https://www.autohotkey.com/boards/viewtopic.php?t=17834&p=86799
(FindText by FeiYue)
Another possibility could have been something dealing with AHKHID
https://github.com/SBRK/bluetooth-windows-play-pause-ahk
(bluetooth-windows-play-pause-ahk)
(script for having the play/pause of bluetooth wireless headphones work in Windows)
Also, if we dig a bit deeper into that Python Bluetooth library, very likely some C/C++ code will reveal itself. Meaning that an AHK coder or group of coders could do similar in creating such for AutoHotkey. There are also a number of scripts dealing with Bluetooth, doing DllCalls to bthprops.cpl, etc...