Jump to content

Steam Website Login Automation


Recommended Posts

I am trying to automate the login process for the steam community website, however steam guard keeps getting in my way, I am fine with asking the user to enter their steam code, however I can't get the script to enter the code into the form, and click submit. Due to it being unable to find the input box. Below is the code I have.

 

; Trap COM errors so that 'Back' and 'Forward'
; outside of history bounds does not abort script
; (expect COM errors to be sent to the console)

#include <GUIConstantsEx.au3>
#include <GuiConstants.au3>
#include <IE.au3>
#include <WindowsConstants.au3>

$oBtn = 1

GUICreate("Forum Login Automator", 1024, 768, "", "", $WS_OVERLAPPEDWINDOW + $WS_CLIPSIBLINGS + $WS_CLIPCHILDREN)

GUICtrlCreateTab(10, 10, 200, 100)


GUICtrlCreateTabItem("Steam Poster")
Local $oIE = _IECreateEmbedded()
GUICtrlCreateObj($oIE, 10, 40, 1010, 500)
Local $login = GUICtrlCreateButton("Start Login", 10, 555, 100, 30)
Local $user = GUICtrlCreateInput("Username", 120, 555, 100, 30)
;~ Local $pass = GUICtrlCreateInput("Password", 230, 555, 100, 30, $ES_PASSWORD)
Local $pass = GUICtrlCreateInput("Password", 230, 555, 100, 30)
GUICtrlSetLimit(-1, 50)
Local $message = GUICtrlCreateEdit("", 10, 600, 320, 150)
GUICtrlSetColor(-1, 0xff0000)

GUISetState(@SW_SHOW) ;Show GUI

_IENavigate($oIE, "https://steamcommunity.com/login/home/?goto=discussions%2F")
$hwnd = WinGetHandle("Forum Automator", $oIE)
If @error Then
    MsgBox("", "", "Failed HWID")
EndIf
_IEAction($oIE, "stop")

Func steamLogin()
    _IENavigate($oIE, "https://steamcommunity.com/login/home/?goto=discussions%2F")
    Sleep(1000)
    Local $oSubmit = _IEGetObjById($oIE, "steamAccountName")
    _IEAction($oSubmit, "focus")
    ControlSend($hwnd, "", "", GUICtrlRead($user) & "{TAB}")

    If @error Then
        MsgBox("", "", "Failed")
    EndIf

    ControlSend($hwnd, "", "", GUICtrlRead($pass) & "{ENTER}")
    Sleep(5000)

;I want to check if the steamguard pop over is there if so then ask for them to input their code, otherwise proceed. I am not using an if statement due to not being able to even detect the pop up yet, but that does need to be added.
    $oBtn = _IEGetObjById($oIE, "auth_buttonset_entercode")
    $authCode = InputBox("Auth Code", "Please Enter Steam Auth Code For Login", "")
    _IEFormElementSetValue($oBtn, $authCode)
    sleep(2500)

;This part check to see if they were logged in / redirected to the forum page as I am wanting.
    If Not _IEGetObjById($oIE, "GlobalDiscussionSearchForm") Then
        MsgBox("", "Error Logging In", "Please Fix User Name Or Password Then Try Logging In Again!")
    EndIf

EndFunc   ;==>steamLogin

; Waiting for user to close the window
While 1
    Local $iMsg = GUIGetMsg()
    Select
        Case $iMsg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $iMsg = $login
            steamLogin()
    EndSelect
WEnd

 

 

*Edit Forgot Code

Edited by rm4453
Link to comment
Share on other sites

Add "Login" to this Line:

$hwnd = WinGetHandle("Forum Automator", $oIE)

Example: $hwnd = WinGetHandle("Forum Login Automator", $oIE)

That way you can access the fields in the Steam form.

Alternatively you could remove "Login" from the GuiCreate line.

An even better way to do it in my opinion is to return the handle directly from the GuiCreate.

Something like this:

; Trap COM errors so that 'Back' and 'Forward'
; outside of history bounds does not abort script
; (expect COM errors to be sent to the console)

#include <GUIConstantsEx.au3>
#include <GuiConstants.au3>
#include <IE.au3>
#include <WindowsConstants.au3>

$oBtn = 1

$hwnd = GUICreate("Forum Login Automator", 1024, 768, "", "", $WS_OVERLAPPEDWINDOW + $WS_CLIPSIBLINGS + $WS_CLIPCHILDREN)

GUICtrlCreateTab(10, 10, 200, 100)


GUICtrlCreateTabItem("Steam Poster")
Local $oIE = _IECreateEmbedded()
GUICtrlCreateObj($oIE, 10, 40, 1010, 500)
Local $login = GUICtrlCreateButton("Start Login", 10, 555, 100, 30)
Local $user = GUICtrlCreateInput("Username", 120, 555, 100, 30)
;~ Local $pass = GUICtrlCreateInput("Password", 230, 555, 100, 30, $ES_PASSWORD)
Local $pass = GUICtrlCreateInput("Password", 230, 555, 100, 30)
GUICtrlSetLimit(-1, 50)
Local $message = GUICtrlCreateEdit("", 10, 600, 320, 150)
GUICtrlSetColor(-1, 0xff0000)

GUISetState(@SW_SHOW) ;Show GUI

_IENavigate($oIE, "https://steamcommunity.com/login/home/?goto=discussions%2F")
;$hwnd = WinGetHandle("Forum Login Automator", $oIE)
If @error Then
    MsgBox("", "", "Failed HWID")
EndIf
_IEAction($oIE, "stop")

Func steamLogin()
    _IENavigate($oIE, "https://steamcommunity.com/login/home/?goto=discussions%2F")
    Sleep(1000)
    Local $oSubmit = _IEGetObjById($oIE, "steamAccountName")
    _IEAction($oSubmit, "focus")
    ConsoleWrite(GUICtrlRead($user))
    ControlSend($hwnd, "", "", GUICtrlRead($user) & "{TAB}")

    If @error Then
        MsgBox("", "", "Failed")
    EndIf

    ControlSend($hwnd, "", "", GUICtrlRead($pass) & "{ENTER}")
    Sleep(5000)

;I want to check if the steamguard pop over is there if so then ask for them to input their code, otherwise proceed. I am not using an if statement due to not being able to even detect the pop up yet, but that does need to be added.
    $oBtn = _IEGetObjById($oIE, "auth_buttonset_entercode")
    $authCode = InputBox("Auth Code", "Please Enter Steam Auth Code For Login", "")
    _IEFormElementSetValue($oBtn, $authCode)
    sleep(2500)

;This part check to see if they were logged in / redirected to the forum page as I am wanting.
    If Not _IEGetObjById($oIE, "GlobalDiscussionSearchForm") Then
        MsgBox("", "Error Logging In", "Please Fix User Name Or Password Then Try Logging In Again!")
    EndIf

EndFunc   ;==>steamLogin

; Waiting for user to close the window
While 1
    Local $iMsg = GUIGetMsg()
    Select
        Case $iMsg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $iMsg = $login
            steamLogin()
    EndSelect
WEnd

(Two lines were modified)

I changed the GuiCreate line to return the handle.

I remarked the hwnd = WinGetHandle line.

It seems to work just fine that way.

Edited by Xandy
Link to comment
Share on other sites

51 minutes ago, Xandy said:

Add "Login" to this Line:

$hwnd = WinGetHandle("Forum Automator", $oIE)

Example: $hwnd = WinGetHandle("Forum Login Automator", $oIE)

That way you can access the fields in the Steam form.

Alternatively you could remove "Login" from the GuiCreate line.

An even better way to do it in my opinion is to return the handle directly from the GuiCreate.

Something like this:

; Trap COM errors so that 'Back' and 'Forward'
; outside of history bounds does not abort script
; (expect COM errors to be sent to the console)

#include <GUIConstantsEx.au3>
#include <GuiConstants.au3>
#include <IE.au3>
#include <WindowsConstants.au3>

$oBtn = 1

$hwnd = GUICreate("Forum Login Automator", 1024, 768, "", "", $WS_OVERLAPPEDWINDOW + $WS_CLIPSIBLINGS + $WS_CLIPCHILDREN)

GUICtrlCreateTab(10, 10, 200, 100)


GUICtrlCreateTabItem("Steam Poster")
Local $oIE = _IECreateEmbedded()
GUICtrlCreateObj($oIE, 10, 40, 1010, 500)
Local $login = GUICtrlCreateButton("Start Login", 10, 555, 100, 30)
Local $user = GUICtrlCreateInput("Username", 120, 555, 100, 30)
;~ Local $pass = GUICtrlCreateInput("Password", 230, 555, 100, 30, $ES_PASSWORD)
Local $pass = GUICtrlCreateInput("Password", 230, 555, 100, 30)
GUICtrlSetLimit(-1, 50)
Local $message = GUICtrlCreateEdit("", 10, 600, 320, 150)
GUICtrlSetColor(-1, 0xff0000)

GUISetState(@SW_SHOW) ;Show GUI

_IENavigate($oIE, "https://steamcommunity.com/login/home/?goto=discussions%2F")
;$hwnd = WinGetHandle("Forum Login Automator", $oIE)
If @error Then
    MsgBox("", "", "Failed HWID")
EndIf
_IEAction($oIE, "stop")

Func steamLogin()
    _IENavigate($oIE, "https://steamcommunity.com/login/home/?goto=discussions%2F")
    Sleep(1000)
    Local $oSubmit = _IEGetObjById($oIE, "steamAccountName")
    _IEAction($oSubmit, "focus")
    ConsoleWrite(GUICtrlRead($user))
    ControlSend($hwnd, "", "", GUICtrlRead($user) & "{TAB}")

    If @error Then
        MsgBox("", "", "Failed")
    EndIf

    ControlSend($hwnd, "", "", GUICtrlRead($pass) & "{ENTER}")
    Sleep(5000)

;I want to check if the steamguard pop over is there if so then ask for them to input their code, otherwise proceed. I am not using an if statement due to not being able to even detect the pop up yet, but that does need to be added.
    $oBtn = _IEGetObjById($oIE, "auth_buttonset_entercode")
    $authCode = InputBox("Auth Code", "Please Enter Steam Auth Code For Login", "")
    _IEFormElementSetValue($oBtn, $authCode)
    sleep(2500)

;This part check to see if they were logged in / redirected to the forum page as I am wanting.
    If Not _IEGetObjById($oIE, "GlobalDiscussionSearchForm") Then
        MsgBox("", "Error Logging In", "Please Fix User Name Or Password Then Try Logging In Again!")
    EndIf

EndFunc   ;==>steamLogin

; Waiting for user to close the window
While 1
    Local $iMsg = GUIGetMsg()
    Select
        Case $iMsg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $iMsg = $login
            steamLogin()
    EndSelect
WEnd

(Two lines were modified)

I changed the GuiCreate line to return the handle.

I remarked the hwnd = WinGetHandle line.

It seems to work just fine that way.

 

Did you end up having to deal with steam guard? should look something like the image at this link: http://imgur.com/a/05ZAl

Link to comment
Share on other sites

After a bit I started just using test data.  So I wasn't really logging in but the error report started to come from Steam directly, after I made the changes I mentioned.  

How do you intend to deal with the guard?  It sends an email.  User will copy data from email manually?

Edited by Xandy
Link to comment
Share on other sites

1 minute ago, Xandy said:

After a bit I started just using test data.  How do you intend to deal with the guard?  It sends an email.  User will copy data from email manually?

yeah im wanting so if it detects steam guard it will pop up an inputbox asking for the code then put it in when they submit the inputbox and click sumbit if that makes sense

Link to comment
Share on other sites

2 minutes ago, Xandy said:

But okay your Inputbox method should work for that too.

the part im having issues with is detecting the steamguard pop over as it doesn't all ways show up when logging in... im pretty sure as soon as i am able to detect the pop over i can find a way to input into the pop over the code that they put into the inpubox and then click submit

Link to comment
Share on other sites

My first thought (I'm not at all a web guy)

Can we read the source of the page to figure that out?

Do me a favor test if the html source changes depending on whether the guard comes up.

 

I can do it if the source changes

Edited by Xandy
Link to comment
Share on other sites

@Xandy

do you have an steam account? and do you have steam guard enabled? if so I know how to force steam guard pop over to show up when logging in, all you have to do is try and login inside an incognito window. *if you have a steam but steam guard isn't enabled it is fairly easy to enable it simple google search* if you want i can get a full copy of the html source for the steam login page before submitting login info, after with and after without the steamguard pop over..... * http://steamcommunity.com/login *

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...