Sign in to follow this  
Followers 0
AutID

_WinHttpSimpleFormFill alternative

17 posts in this topic

Hello,
 

I am trying to make an auto log in script that will log in on our server with all the accounts read from the database(arround 20 accounts). The reason for this is everyone to recive update e-mail.
We recive update e-mail everytime time we log in so that is the reason that i am creating this.
Here is a small reproducer:

#include "WinHttp.au3"
OnAutoItExitRegister("_sExit")
Global $sRead, $hOpen, $hConnect
Global Const $sUsername[3] = ["name1", "name2", "name3"]
Global Const $sPassword[3] = ["pass1", "pass2", "pass3"]
Global Const $sUrl = "https://www.myServer.com/"
Global Const $sUserAgent = "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0)"
Local $a
Local $b
$hOpen = _WinHttpOpen($sUserAgent)
$hConnect = _WinHttpConnect($hOpen, $sUrl)
For $i = 0 To UBound($sUsername)-1
 $a = $sUsername[$i]
 For $j = 0 To UBound($sPassword)-1
  $b = $sPassword[$i]
  ExitLoop
 Next
  $sRead = _WinHttpSimpleFormFill($hConnect, _
   Default, _
   "login_1", _
   "name:name", $a, _
   "name:pass", $b)
   If @error Then
    ConsoleWrite(@error & @LF)
   Else
    If StringInStr($sRead, $a) Then ConsoleWrite($a & " succesfully logged in." & @LF)
   EndIf
Next

Func _sExit()
 _WinHttpCloseHandle($hConnect)
 _WinHttpCloseHandle($hOpen)
EndFunc
This work but not very good. The script will log in succesfully with the first 5-10 accounts but then it will return _WinHttpSimpleFormFill will return an error because of the fast log in on the server.

 

Is there an other way to do this without filling the form with data and submiting it? Like a simple request that will load the http with the credentials without doing the classic form fill?

Cheers

 

Share this post


Link to post
Share on other sites



It seems like you are approaching this from the wrong POV. Can't you come up with a way to send the emails without automating the website login?

The 2nd For...Next loop in your script doesn't do anything.

 

The script will log in succesfully with the first 5-10 accounts but then it will return _WinHttpSimpleFormFill will return an error because of the fast log in on the server.

 

Not sure what this means. What error is returned?

Share this post


Link to post
Share on other sites

It seems like you are approaching this from the wrong POV. Can't you come up with a way to send the emails without automating the website login?

The 2nd For...Next loop in your script doesn't do anything.

 

Not sure what this means. What error is returned?

It was a sample which i created here. It actually does ;)

If i log in with the accounts, the first 5 to 10 accounts will log in succesfully but the rest will not. WinHttpSimpleFormFill will propably return error 1 that there are no forms in the handle.

If i call $hOpen and $hConnect within the for loop it will work but it will take a lot of time for all the accounts.

So i was wondering if there is another way to do it...

 

Share this post


Link to post
Share on other sites

You said there were like 20 accounts... I can't imagine that it would take *that* long if you modified the code to call _WinHttpConnect / _WinHttpCloseHandle as part of your loop.

Share this post


Link to post
Share on other sites

It would actually take. It would take more than 1 min without the fail tries. If i add retry function which will retry the account after some seconds in case it fails it will take much longer. And all this time my project is paused...
I don't know very well winhttp but there must be a way to load the html with the credentials without doing the entire log in...

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Each user has their own credentials.

Even if there were a way to login with another users credentials, that would be a controversial subject here.

What?

Please read the topic and don't make comments like these on my topics again.

If you need some attention go get a pet.

 

Edited by AutID

Share this post


Link to post
Share on other sites

No reason to get hostile. I'm sure that JohnOne was only trying to help.

Share this post


Link to post
Share on other sites

Maybe you would have better results with _WinHttpOpenRequest and _WinHttpSendRequest. <shrug>

As previously stated, I don't see what the big deal is if it takes a minute or two to run your script using _WinHttpConnect / _WinHttpCloseHandle as part of your loop. You have failed to explain why this is an issue. How often will you be running this script?

If you want additional help, then I suggest that you provide more details regarding what you are trying to accomplish. Is there a reason that you can't write a script to send the desired email to each user without requiring interaction with a website?

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

I'm just wondering why you would need to log into 20 email accounts to send email updates. There are surely easier methods to send an email to an individual or even 20 people at once without logging in 20 times.

anyways.  this is from the help file "In case form requires redirection and $hInternet is internet handle, this handle will be closed and replaced with new and required one. "

hence the hWnd is subject to change and its defined outside of your loop so once it changes its invalid

 

Something else I find amusing is the fact that this seems like a time sensitive process.  Doesn't that kinda defeat the purpose of automation.  press the button let it run, go take a jog, smoke a cig, ect....

Edited by markyrocks

Share this post


Link to post
Share on other sites

Maybe you would have better results with _WinHttpOpenRequest and _WinHttpSendRequest. <shrug>

As previously stated, I don't see what the big deal is if it takes a minute or two to run your script using _WinHttpConnect / _WinHttpCloseHandle as part of your loop. You have failed to explain why this is an issue. How often will you be running this script?

I haven't failed to explain why that is an issue. As i said above this will pause my project till all accounts have logged in. This is the issue. Maybe you don't find it a problem but i do.

And this is the reason i am asking if there is an other way.

For your last question, yes, there is a reason. It is not me sending the emails. Our server does it automatically everytime we log in. I think i am saying this to the 1st post :/

I'm just wondering why you would need to log into 20 email accounts to send email updates. There are surely easier methods to send an email to an individual or even 20 people at once without logging in 20 times.

I am not sighining in with 20 email accounts. I know that there ways to send emails to 20 people. But you don't know what my first post is saying. WE recive emails everytime we log in with the latest updates. I don't want to send any kind of emails.

Share this post


Link to post
Share on other sites

Good luck!

Share this post


Link to post
Share on other sites

I haven't failed to explain why that is an issue. As i said above this will pause my project till all accounts have logged in. This is the issue. Maybe you don't find it a problem but i do.

And this is the reason i am asking if there is another way

1. No your screwed. 2. Just let the users sign in manually 3. Back to my original point about automating. Stop drinking so much coffee starring at ur pc chewing your nails. Let the thing do its thing. If the answers you received aren't satifactory then I'd say dig into the help file, Google, or learn another programming language that specializes in Internet protocol.

Last but not least everyone in here is confused because what your saying this script is for makes no sense. If the server generates emails automatically when a user logs on why do they need you to log in for them?

Share this post


Link to post
Share on other sites

1. No your screwed. 2. Just let the users sign in manually 3. Back to my original point about automating. Stop drinking so much coffee starring at ur pc chewing your nails. Let the thing do its thing. If the answers you received aren't satifactory then I'd say dig into the help file, Google, or learn another programming language that specializes in Internet protocol.

Last but not least everyone in here is confused because what your saying this script is for makes no sense. If the server generates emails automatically when a user logs on why do they need you to log in for them?

Ok thank you for your help. Now go away and please do me a favor. Dont reply on my threads again.

If you here just to act smart keep it for yourself.

Share this post


Link to post
Share on other sites

AutID,

Neither you nor I can prevent people from posting in your threads, but you can prevent their replies from being visible to you (although everyone else will see them). Open the dropdown by your name and select "My Settings" - then select "'Ignore' Preferences" from the menu on the left. Once set, you do not see the full responses from the "ignored" members - unless you wish to as I believe there is a button which makes the post visible. :)

This thread is now well past its "best by" date so I am locking it. :rolleyes:

markyrocks,

Even if you feel that the question is nonsense, there is no need to get quite so ratty in your responses - just walk away if you do not want to participate further. ;)

JohnOne,

I appreciate the provocation, but I would also appreciate a slightly less profane retort next time. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  
Followers 0

  • Similar Content

    • DaLiMan
      By DaLiMan
      I'm trying to download a file from our server at work which requires a login.
      InetGet is not working so I was looking round for another method.
      I came across winhttp.au3 but it seems like this is not shipped with the Autoit ZIP I have. (v3.3.14) 
      Anyone have any ideas of where to get it, because I can't find it.
      I also searched the forum, thinking it was trancexx who made it. (maybe I'm wrong here....)
      Or is it obsolete and is there another / better way?
      Any suggestions?
       
    • souldjer777
      By souldjer777
      Good Morning AutoIT Geniuses! 
      Now, it could be that I've been away for a while - but I can get source from just about any website except adobe using InetGetSource.
      I have no idea why...   error: 13
      https://helpx.adobe.com/security.html
      https://helpx.adobe.com/security.html?promoid=HRYCM
      Thanks!
      #include <Inet.au3> HttpSetUserAgent("Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko") Local $sOpenAdobe_URLSecurityUpdates = 'https://helpx.adobe.com/security.html' Local $OpenSSL01 = _INetGetSource($sOpenAdobe_URLSecurityUpdates) WinHttp.au3 is returning results - I just don't get it...
      Thanks! 
      #include "WinHttp.au3" Opt("MustDeclareVars", 1) ; Initialize and get session handle Global $hOpen = _WinHttpOpen() ; Get connection handle Global $hConnect = _WinHttpConnect($hOpen, "helpx.adobe.com") ; Make a request Global $hRequest = _WinHttpSimpleSendRequest($hConnect, Default, "/security.html?promoid=HRYCM") If $hRequest Then ; Simple-read... ConsoleWrite(_WinHttpSimpleReadData($hRequest) & @CRLF) MsgBox(64, "Okey do!", "Returned source is print to concole. Check it.") Else MsgBox(48, "Error", "Error ocurred for _WinHttpSimpleSendRequest, Error number is " & @error) EndIf ; Close handles _WinHttpCloseHandle($hRequest) _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen)  
    • AutID
      By AutID
      Hello,
      It is the second time I am running to this problem again. First time I used simple form fill function from winhttp.au3. And I added a sleep between logins to make it work but this solution sucks.
      So I am wondering again, is there an other solution to perform a log in on website other than simple form fill?
      I just want to check credentials so I need to perform log in and then check for the username in the results.
      Here is an example with simple form fill

      #include "WinHttp.au3" Global $sRead, $hOpen, $hConnect Global $sUsername, $sPassword, $sName Global $sUrl = "https://www.facebook.com/" Global $sUserAgent = "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0)" $hOpen = _WinHttpOpen($sUserAgent) $hConnect = _WinHttpConnect($hOpen, $sUrl) $sRead = _WinHttpSimpleFormFill($hConnect, _   Default, _   "login_form", _   "name:email", $sUsername, _   "name:pass", $sPassword) If @error Then  MsgBox(0, "Error", "Error: " & @error) ElseIf StringInStr($sRead, $sName) = True Then  MsgBox(0, "", $sName & "'s credentials are correct.") Else  MsgBox(0, "", "Wrong credentials, please try again.") EndIf _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen)
    • AutID
      By AutID
      Hello,
       
      I am trying to make an auto log in script that will log in on our server with all the accounts of the people working on our domain read from the database(arround 20 accounts). The reason for this is everyone to recive update e-mail.
      We recive update e-mail with the latest updates everytime time we log in so that is the reason that i am creating this.
      Here is a small reproducer:

      #include "WinHttp.au3" OnAutoItExitRegister("_sExit") Global $sRead, $hOpen, $hConnect Global Const $sUsername[3] = ["name1", "name2", "name3"] Global Const $sPassword[3] = ["pass1", "pass2", "pass3"] Global Const $sUrl = "https://www.myServer.com/" Global Const $sUserAgent = "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0)" Local $a Local $b $hOpen = _WinHttpOpen($sUserAgent) $hConnect = _WinHttpConnect($hOpen, $sUrl) For $i = 0 To UBound($sUsername)-1  $a = $sUsername[$i]   $b = $sPassword[$i]   $sRead = _WinHttpSimpleFormFill($hConnect, _    Default, _    "login_1", _    "name:name", $a, _    "name:pass", $b)    If @error Then     ConsoleWrite(@error & @LF)    Else     If StringInStr($sRead, $a) Then ConsoleWrite($a & " succesfully logged in." & @LF)    EndIf Next Func _sExit()  _WinHttpCloseHandle($hConnect)  _WinHttpCloseHandle($hOpen) EndFunc If i put the $hOpen and $hConnect within the For/Next loop it will work but it will take more than 1 min to log in on our server with all the accounts.
      If not it won't work for all the accounts. If i use $hOpen and $hConnect only once then the server will fire error after 4-5 log ins and the winhttpsimpleformfill function will return that there are no forms, @error 1.
      Any other way to perform a log in without filling the form with data and submitting it?

      Cheers.