Help is needed with Set Widget Value action

I don’t think it’s quite enough to just match _Hidden. If you have more than 1 HTML Widget, you need to dig deeper to match the correct Widget, but the IE Object in this case has no Title. There must be something within the IE Object that differentiates it from another IE Object.

2 Likes

Got the Widget…

SetTitleMatchMode, 1 ; Title must start with string


if not WinExist("ahk_class Internet Explorer_Hidden")
{
   MsgBox IE not found
   return
}


widget_id:= WinExist("ahk_class Internet Explorer_Hidden")


WinGet, widget_id


WinActivate, ahk_id %widget_id%
WinGetClass, this_class, ahk_id %widget_id%
WinGetTitle, this_title, ahk_id %widget_id%
WinGetText, this_text, ahk_id %widget_id%
MsgBox, 4, , ahk_id %widget_id%`nahk_class %this_class%`nTitle %this_title%`nText %this_text%`n`nContinue?
1 Like

Do you think it could work?

Still working on it.

Then I stumble on this… probably what you need for this scenario almost exactly…

http://www.autohotkey.com/board/topic/113013-how-to-do-logins-using-the-winhttprequest-com/

;Prepare our WinHttpRequest object
HttpObj := ComObjCreate("WinHttp.WinHttpRequest.5.1")
;HttpObj.SetProxy(2,"localhost:8888") ;Send data through Fiddler
HttpObj.SetTimeouts(6000,6000,6000,6000) ;Set timeouts to 6 seconds
;HttpObj.Option(6) := False ;disable location-header rediects

;Set our URLs
loginURL := "http://reports.mishloha.co.il/login.php"

;Set our login data
username := "Brutosozialprodukt"
password := "xxxxxxxxxxxxxx"
autologin := "on"

;Step 1
loginBody := "username=" username "&password=" password "&autologin=" autologin "&login=Login"

;Step 2/3
HttpObj.Open("POST",loginURL)
HttpObj.SetRequestHeader("Content-Type","application/x-www-form-urlencoded")
HttpObj.Send(loginBody)

;Step 4
If (InStr(HttpObj.ResponseText,"<title>Login"))
    MsgBox, The login failed!
Else
    MsgBox, Login was successfull!
2 Likes

@QMcKay,
This is what happens when I run the file

:frowning:

Yes, it has something to do with the character set used on the page. The response looks like the following, and the check for success is looking at the <title> which contains <title>??????

Erase the success check (step 4), and perhaps sleep before post, since the page load is slow…

;Step 2/3
HttpObj.Open("POST",loginURL)
HttpObj.SetRequestHeader("Content-Type","application/x-www-form-urlencoded")
sleep 20000
HttpObj.Send(loginBody)
sleep 5000
resp := HttpObj.ResponseText
MsgBox, %resp%

;Step 4
;If (InStr(HttpObj.ResponseText,"<title>Login"))
;    MsgBox, The login failed!
;Else
;    MsgBox, Login was successfull!

@QMcKay,

Still no luck


Be sure to get AHK from here:

http://ahkscript.org

The other site (http://www.autohotkey.com) contains an outdated version that is no longer maintained.

I know I’m close, because I can get the Widget Handle. But I can’t control it. I’m missing something simple

As soon as I can get control of it, we got this thing licked.

2 Likes

Okay, what does that mean?

It just means the Response did not contain <title>Login.
My test showed that as well, though we both know that the supplied username/password were invalid.

You need to make your Success check look for something else.

1 Like

@emre, Is it possible to implement it?

Here it is. It will need some tweaking for different pages, but this lets you alter values on a page…

I moved this post to another Topic (Tutorial) for a fresh start…

@QMcKay Where from am I supposed to download the file

Acc Library:

Here: http://www.autohotkey.com/board/topic/77303-acc-library-ahk-l-updated-09272012/

More directly, here: https://copy.com/oiLspOmEi0xVCg1F/Acc.ahk?download=1

What am I doing wrong?

@QMcKay,
Update: I managed to run the script and the site opens in HTML Viewer Widget
But where do I set the user name and Password to auto fill?

Just finished working that out too…

page.Document.getElementById("username").Value := "yourusername"
page.Document.getElementById("password").Value := "yourpassword"
page.Document.getElementById("loginForm").Submit()

You can take out the Navigate function in the script if the Widget already has that set - in fact, I recommend it, since it will take time for the page to load. Also, you may want to preceed the above with a sleep function like:

Sleep 10000

Also, if the Submit() doesn’t work (it may not, I can’t find the FORM name in the page), instead try:

page.Document.getElementById("login-button").Click()

or

page.Document.getElementById("form").Submit()
1 Like

Okay thank you I’ll wait you finish
And tell me where to place it
I would love if you could check my site if it fills the fields user name and Password when it will be finished
Thanks again.

WoW I love you @QMcKay I have been working on that very thing for TimeTrex. YOu saved me a major headache… I almost had mine working… you made me realize my mistake haha. I was using .Submit() this entire time it was .Click() I did not look that it was a button…

I had given up on using AHK because of it… so I was interested and watching this thread. The method of getting the widget you used was different than what i was using but yours is a lot easier… So I am switching over to it.

@pizzaeilat4

Just replace

page.Navigate(“http://www.google.com”)

With

page.Document.getElementById(“username”).Value := “yourusername”
page.Document.getElementById(“password”).Value := “yourpassword”
page.Document.getElementById(“loginForm”).Submit()

Make sure your widget is set to load the Webpage already. This will not only auto populate but it will even auto log in just like roboform.

@QMcKay now that you helped me get this working… this will open up an entire new level of interaction with TimeTrex…