Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Problem inserting text into web form


Best Answer Jackie Sztuk _Blackholyman , 19 May 2013 - 08:42 PM

Go to the full post »


  • Please log in to reply
9 replies to this topic
CKBlack007
  • Members
  • 3 posts
  • Last active: May 04 2015 03:14 AM
  • Joined: 12 Apr 2013

I have been using AHK to scrape balances from sites that do not integrate with Mint.  I have used it successfully in two scenarios, but this third one eludes me.  Because they do not use ID's, I cannot call them and using {tab} has had inconsistent results.  I hate to ask but I can't develop a consistent product.   Any assistance would be appreciated.

 

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
#Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
SetKeyDelay, 500

;step 0.5 set universals
AppName := A_ScriptName
TodayDate = %A_YYYY%-%A_MM%-%A_DD%
Makelog(Name,Date,Status,Message)
{
  FileAppend,%Name%`t%Date%`t%Status%`t%Message%`n,C:\Users\CKBlack007\Documents\Projects\realbalance\trans\log.txt
}

;step 1 - archive the old 529 file
FileCopy, C:\529.txt, C:\%A_YYYY%-%A_MM%-%A_DD%_529.txt

;step 2 - check internet connection
url=www.google.com
RunWait, ping.exe %url% -n 1,, Hide UseErrorlevel
If Errorlevel
     Makelog(AppName,TodayDate,"Failure","100 - Internet Unreachable"),ExitApp
Else ;MsgBox,,,%url% Destination Reachable

;step 3 - fire up ie and get the data
Pwb := ComObjCreate("InternetExplorer.Application")
Pwb.Visible := True
Pwb.Navigate("schwab529.529.com/swatpl/auth/loginFormAction.do")
While pwb.Busy
Sleep, 2000
ControlSend,Internet Explorer_Server1,{Tab 2},ahk_class IEFrame
Sleep, 500
ControlSend,Internet Explorer_Server1,MyLogin{Enter},ahk_class IEFrame
while !instr(pwb.document.documentElement.innerText , "logging")
Sleep, 1000
ControlSend,Internet Explorer_Server1,{Tab 2},ahk_class IEFrame
Sleep, 1000
ControlSend,Internet Explorer_Server1,MyPassword{Enter},ahk_class IEFrame
sleep 5000
;these do not work
;Pwb.document.forms[0].elements[0].value := "MyLogin"
;Pwb.Document.All.username.Value := "MyLogin"
;Pwb.Document.login.username.value := "MyLogin"
;Pwb.document.getElementsByName("username").Value := "MyLogin"
;ControlSend,Internet Explorer_Server1,MyPassword,ahk_class IEFrame
;ControlSend,Internet Explorer_Server1,{Enter},ahk_class IEFrame
 



Jackie Sztuk _Blackholyman
  • Spam Officer
  • 3757 posts
  • Last active: Apr 03 2016 08:47 PM
  • Joined: 28 Feb 2012
✓  Best Answer
this works for my on the login page (i'd need a login to help with the password)
LoginVar := "MyLogin"

;step 3 - fire up ie and get the data
wb := ComObjCreate("InternetExplorer.Application")
wb.Visible := True
wb.Navigate("schwab529.529.com/swatpl/auth/loginFormAction.do")
While wb.readyState != 4 || wb.document.readyState != "complete" || wb.busy ; wait for the page to load
	Sleep, 10
Form := wb.Document.forms[0]
Form.getElementsByTagName("input")[1].value := LoginVar
Form.submit()
While wb.readyState != 4 || wb.document.readyState != "complete" || wb.busy ; wait for the page to load
	Sleep, 10
msgbox % "and then the password page"
Hope it helps
Helping%20you%20learn%20autohotkey.jpg?d

[AHK] Version. 1.1+ [CLOUD] DropBox ; Copy [WEBSITE] Blog ; About

CKBlack007
  • Members
  • 3 posts
  • Last active: May 04 2015 03:14 AM
  • Joined: 12 Apr 2013

Thank you very much.  That was a very big help to my project



sv270190
  • Members
  • 19 posts
  • Last active: Jul 30 2017 04:42 PM
  • Joined: 05 Jul 2013

suppose that the i.e is already open

 

web page is ready with forms

 

how should i code so that on the press of a hot key

 

the form is filled with data from txt file



Jackie Sztuk _Blackholyman
  • Spam Officer
  • 3757 posts
  • Last active: Apr 03 2016 08:47 PM
  • Joined: 28 Feb 2012
With out knowing more, hard to say

Look up the IEget function in the tut Subforum
Helping%20you%20learn%20autohotkey.jpg?d

[AHK] Version. 1.1+ [CLOUD] DropBox ; Copy [WEBSITE] Blog ; About

sv270190
  • Members
  • 19 posts
  • Last active: Jul 30 2017 04:42 PM
  • Joined: 05 Jul 2013

sir

 

IE is open   the required webs page is also open

 

how to access web page that is open  

 

and fill the web page form with some data

 

i.e using ieget()  or something like that

 

i know how to open ie navigate to the desired address

 

and then fill the form 



Jackie Sztuk _Blackholyman
  • Spam Officer
  • 3757 posts
  • Last active: Apr 03 2016 08:47 PM
  • Joined: 28 Feb 2012
IEGet:
IEGet(name="") {
   IfEqual, Name,, WinGetTitle, Name, ahk_class IEFrame     ;// Get active window if no parameter
   Name := (Name="New Tab - Windows Internet Explorer")? "about:Tabs":RegExReplace(Name, " - (Windows|Microsoft) Internet Explorer")
   for wb in ComObjCreate("Shell.Application").Windows
      if wb.LocationName=Name and InStr(wb.FullName, "iexplore.exe")
         return wb
}
Then just use it to get a handle to your open IE windows active tab
wb := IEGet()
Wb.document.all.length
;... And so on ...
Return

IEGet(name="") {
   IfEqual, Name,, WinGetTitle, Name, ahk_class IEFrame     ;// Get active window if no parameter
   Name := (Name="New Tab - Windows Internet Explorer")? "about:Tabs":RegExReplace(Name, " - (Windows|Microsoft) Internet Explorer")
   for wb in ComObjCreate("Shell.Application").Windows
      if wb.LocationName=Name and InStr(wb.FullName, "iexplore.exe")
         return wb
}

Helping%20you%20learn%20autohotkey.jpg?d

[AHK] Version. 1.1+ [CLOUD] DropBox ; Copy [WEBSITE] Blog ; About

sv270190
  • Members
  • 19 posts
  • Last active: Jul 30 2017 04:42 PM
  • Joined: 05 Jul 2013
i could get little success with
 
wb := ieget("Finacle Prelogin")  &
 
wb := ieget("Oracle | PeopleSoft Enterprise Sign-in")
 
but when it comes to
 
wb := ieget("UBILAPS    " "270190" "RAILWAY FEEDER ROAD - RAJAPALAYAM" "")
 
my programme  fails to update/fill the fields
 
here is the code
 
 f5::
 
 {
 
wb := ieget("UBILAPS    " "270190" "RAILWAY FEEDER ROAD - RAJAPALAYAM" "")
 
ieget(wb)

wb.document.GetElementSByNAME("txtcomcust_phone").value := 270190
 
  
 }
 
 return
 
IEGet(name="") {
 
   IfEqual, Name,, WinGetTitle, Name, ahk_class IEFrame     ;// Get active window if no parameter
 
   Name := (Name="New Tab - Windows Internet Explorer")? "about:Tabs":RegExReplace(Name, " - (Windows|Microsoft) Internet Explorer")
 
   for wb in ComObjCreate("Shell.Application").Windows
 
      if wb.LocationName=Name and InStr(wb.FullName, "iexplore.exe")
 
         return wb
 
 
questions:
 
1.  can we modify  IEGET(name="")  function so that regardless of the title  it access the only active visible  web page
 
or
 
2. can we modify  IEGET(name="") function so that if we mention a sub string of the title of the window instead of full exact title
it is enough to access the existing web page
 


Jackie Sztuk _Blackholyman
  • Spam Officer
  • 3757 posts
  • Last active: Apr 03 2016 08:47 PM
  • Joined: 28 Feb 2012
wb := IEGet()

Just use it like that to get the last active ie tab

No need to use the title if you just need the active tab
Helping%20you%20learn%20autohotkey.jpg?d

[AHK] Version. 1.1+ [CLOUD] DropBox ; Copy [WEBSITE] Blog ; About

sv270190
  • Members
  • 19 posts
  • Last active: Jul 30 2017 04:42 PM
  • Joined: 05 Jul 2013

what is the problem in the title of the window

 

wb := ieget("UBILAPS    " "270190" "RAILWAY FEEDER ROAD - RAJAPALAYAM" "")
 
my script fails   whereis
 
it gives the desired result in
 
wb := ieget("Finacle Prelogin")  &
 
wb := ieget("Oracle | PeopleSoft Enterprise Sign-in")