MIKE LEVIN AI SEO

Future-proof your skills with Linux, Python, vim & git as I share with you the most timeless and love-worthy tools in tech through my two great projects that work great together.

Use Python to Cycle Your IP with HMA VPN Software and Windows Automation

In October 2021, I discovered a solution to cycle my IP using Python, HMA VPN Software, and Windows Automation. With this code, I was able to connect and disconnect the VPN, change the IP address, and check the VPN state - all found on Stack Overflow. Come find out how I did it!

Discover How I Used Python to Cycle My IP with HMA VPN Software and Windows Automation

By Michael Levin

Thursday, August 11, 2022

Wow wee! This is not a nut I thought I’d crack. Actually, someone else cracked the nut and it was October of 2021. I wish I was staying on top of this topic to spot it sooner, but automating stuff on the Windows desktop isn’t too hard using pywinauto. I actually try to avoid it because it’s a lot like web browser automation, but without the cross-platform advantage and ability to run it headlessly on a server. But sometimes you just have to automate Windows… in order to get a new IP from your HMA VPN software, LOL! Read into that whatever you want, but I am an SEO (search engine optimizer) after all. The solution this problem is here:

https://stackoverflow.com/questions/69705923/control-windows-app-hma-vpn-using-pywinauto

…and the actual code that he posted is:

from pywinauto import Desktop,Application
vpn_app = Application(backend="uia").start('C:\Program Files\Privax\HMA VPN\Vpn.exe')
dialog=Desktop(backend="uia").HMA
panel0=dialog.Pane
# Command to connect / disconnect the VPN: connect_button.click()
connect_button=panel0.ConnectButton
# Command to change the IP address: changeIP.click()
changeIP=panel0.Button5
# Check VPN state:
# 0 if disconnected
# 1 if connected
print(connect_button.get_toggle_state())

# Command to connect / disconnect the VPN: connect_button.click()
connect_button=panel0.ConnectButton
connect_button.click()

# Command to change the IP address: changeIP.click()
changeIP=panel0.Button5
changeIP.click()

# Check VPN state:
# 0 if disconnected
# 1 if connected
print(connect_button.get_toggle_state())

Categories