Jump to content

_WinHttpSimpleFormFill alternative


AutID
 Share

Recommended Posts

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

 

Link to comment
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?

Link to comment
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...

 

Link to comment
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...

Link to comment
Share on other sites

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
Link to comment
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?

Link to comment
Share on other sites

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
Link to comment
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.

Link to comment
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?

Link to comment
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.

Link to comment
Share on other sites

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...