Your question 'Can this be changed?' seemed to imply that this code above actually
currently works with
IE COM and the
Instagram website... but the IDs seem to be wrong, among other problems.
You could still try to use
Chrome.ahk or the
Selenium Webdriver (afaik, both will have to start your Chrome browser in debugging mode, but that's not so bad.).
This is some
Chrome.ahk code that will "fill" the boxes for
username and
password, but I don't think that the Instagram login interface actually fancies automation like this, as it doesn't seem to react properly to this kind of actions (the text appears in the boxes, but the prompts/cue banners don't move out of the way like they would during actual human input).
I can't really test it since I don't use Instagram, but I think the whole javascript-react.js-stuff on the login page won't allow you to actually login this way:
Code: Select all
#NoEnv
#Include chrome.ahk ; https://www.autohotkey.com/boards/viewtopic.php?f=6&t=42890
SetBatchLines, -1
SetTitleMatchMode 2
url := "https://www.instagram.com/"
; --- Create a new Chrome instance ---
FileCreateDir, ChromeProfile
Browser := new Chrome("ChromeProfile")
WinWait, Chrome
; --- Connect to the page ---
Page := Browser.GetPage()
Page.Call("Page.navigate", {url : url})
Page.waitForLoad()
while !success
{
try
if (Page.evaluate("document.querySelectorAll('input._2hvTZ.pexuQ.zyHYP');") != "")
success := true
sleep 250
}
Page.evaluate("document.querySelectorAll('input._2hvTZ.pexuQ.zyHYP')[2].value = 'test';")
Page.evaluate("document.querySelectorAll('input._2hvTZ.pexuQ.zyHYP')[3].value = 'testpass';")
So what are the alternatives? Well, afaik, Chrome.ahk (and Selenium, I think) also offers ways to simulate "trusted" keystrokes/inputs - but at the moment, I don't have the time to whip out an example; and it might work or not... I could
try later, though.
The Instagram API, which exists, seems to be mainly for registered app developers.
Of course, you could try some old-style tabbing and sending... or
perhaps the
Acc.ahk library could help, but I am not very familiar with it.
Perhaps I also missed some other alternative
.
But my
guess is that this kind of automation is not ok with Instagram's terms of service. So whatever you do, make sure that you don't get banned
Edit: The best way to login is probably to let Chrome (or some plugin) save and then
autofill your user credentials for Instagram, like you could as a human user (
if that works on the Instagram login site).
With Chrome.ahk (or to be more precise: the
Chrome debugging protocol) it is actually possible to always use the same user profile and make use of 'remember me' cookies etc... that's much better/easier than on IE. But make sure that you really login on the specific user profile that you then use with Chrome.ahk.
Of course, further (legitimate
) automation of the website would still need some work with Chrome.ahk (or Selenium or whatever).