AutoHotkey Community

It is currently May 27th, 2012, 8:22 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 26 posts ]  Go to page Previous  1, 2
Author Message
 Post subject:
PostPosted: April 13th, 2011, 9:42 pm 
Apparenly my subtle hint was too subtle - read through this Tutorial to learn about automating IE.


Report this post
Top
  
Reply with quote  
 Post subject: need help please
PostPosted: February 1st, 2012, 3:48 pm 
hi the i cant seem to figure out how to populate certain cell in a webpage buy getting the data from a excel file.So to try and explain it a bit better i have the same field in excel for and same in the webpage what i want it to do is when i update the excel sheet the site must update by itself

SOME 1 PLEASE HELP ME


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 1st, 2012, 8:40 pm 
Offline
User avatar

Joined: April 4th, 2009, 8:19 pm
Posts: 1143
Location: Croatia
Fill B1 and B2 cells in Excel and watch Internet Explorer.
Code:
;===========================
oExcel := ComObjCreate("Excel.Application")
oWorkbook := oExcel.Workbooks.Add
oWorkSheet1 := oWorkbook.Worksheets(1)
oWorkSheet1.Range("A1").Value := "Keywords:"
oWorkSheet1.Range("A2").Value := "Author:"
oWorkSheet1.Columns("A").AutoFit
oWorkSheet1.Range("B1").Select
ComObjConnect(oWorkSheet1, "oWorkSheet1_")
;===========================
oIE := ComObjCreate("InternetExplorer.Application")
oIE.Navigate("http://www.autohotkey.com/forum/search.php")
;===========================
oIE.Visible := 1
oExcel.Visible := 1
WinMove, % "ahk_id " oExcel.hwnd, ,0,0, A_ScreenWidth/2
WinMove, % "ahk_id " oIE.hwnd, , A_ScreenWidth/2, 0, A_ScreenWidth/2
return
;===========================
oWorkSheet1_Change(oChangedRange){
   global oIE
   Address := oChangedRange.Address
   StringReplace, Address, Address, $,,All
   if (Address = "B1")
      oIE.document.all.search_keywords.value := oChangedRange.Value
   else if (Address = "B2")
      oIE.document.all.search_author.value := oChangedRange.Value
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject: thanks
PostPosted: February 2nd, 2012, 10:40 am 
thanks but what must i put in b1 andb2 cell

Moderator's Note: Modified post for readability. ~ sinkfaze


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 2nd, 2012, 10:46 am 
@zack10: just use the reply button not the quote button, and also don't type your question in the subject line as hardly anyone will see it. Thanks.

For the others: Zack10's question is "Thanks but what must i put in b1 and b2 cell"


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 2nd, 2012, 10:02 pm 
Offline
User avatar

Joined: April 4th, 2009, 8:19 pm
Posts: 1143
Location: Croatia
zack10 wrote:
Thanks but what must i put in b1 and b2 cell
Hi zack10, you can type anything you want in those cells, and appropriate field in Internet Explorer will be updated.
For example, type word test in B1 cell in Excel, press enter (or focus another cell) and watch Search for Keywords field in Internet Explorer.

And you must first run this script with AutoHotkey_L, and wait Excel and Internet Explorer to appear, of course.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 3rd, 2012, 8:24 am 
Offline
User avatar

Joined: May 24th, 2009, 5:35 am
Posts: 2099
Location: Iowa, USA
A fairly strait-forward example:
Code:
; Open Excel
   XL := ComObjCreate("Excel.Application")
   Book := XL.WorkBooks.Add
   for cell in Book.ActiveSheet.Range("A1:G50")
      cell.value := A_Index
   XL.Visible := true
; Open WebBrowser Object
   html :=   "<label>Cell (ex. A1):<input id='CellAddr' type='text'></label>"
      .   "<input id='button' type='button' value='Get Value'/></br></br>"
      .   "<span id='CellValue' style='font-size: 20pt'/>"
   Gui, +hwndID
   Gui, Add, ActiveX, x12 y10 w180 h150 vDoc, MSHTML: %html%
   ComObjConnect(button:=Doc.all.button, "Button_")
   Gui, Show, w200 h180, Get Excel Data
   return
; Clean Up
   GuiClose:
      try   Book.Close(false)
      try   XL.Quit
      ExitApp

; Capture Button Click
   Button_OnClick() {
      global XL, Doc
      try
         Doc.all.CellValue.innerText := XL.Range(Doc.all.CellAddr.Value).Value
      catch
         MsgBox Cannot Access Cell
   }
; Enable enter buttons to get value
   #If WinActive("ahk_id" ID)
   NumPadEnter::
   Enter::
      Button_OnClick()

_________________
Image
Recommended: AutoHotkey_L
Basic Webpage Controls


Report this post
Top
 Profile  
Reply with quote  
PostPosted: May 3rd, 2012, 12:52 am 
Offline

Joined: May 3rd, 2012, 12:42 am
Posts: 2
Did anyone ever figure out a easy solution for this?

I'm looking to take data from a specific fields in a excel spreadsheet and place them in specific field within a web page. Can this be done?

I've read through the threads and it seems the question was totally overlooked and it ran off to a million other ideas.

I've tinkered with a few of the tools, but i am not a programmer. Just wanted to know if there was something in here that works in regards to the initial request of this post.


Report this post
Top
 Profile  
Reply with quote  
PostPosted: May 3rd, 2012, 7:20 am 
Offline
User avatar

Joined: February 28th, 2012, 11:13 pm
Posts: 59
Location: Denmark
Yeah the solution is in the posts of this topic its just some example ways of doing the same thing !
Code:
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
;xxxxxxxxxxxxxxxxxxxxxxxxxxx Open Excel xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
oExcel := ComObjCreate("Excel.Application")
oWorkbook := oExcel.Workbooks.Add
oWorkSheet1 := oWorkbook.Worksheets(1)
oExcel.Visible := 1
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
;xxxxxxxxxxxxx Fill cells in Excel and store in var's xxxxxxxxxxxxxxx
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
oWorkSheet1.Range("A1").Value := "Some keywords"            ;Fill in cell A1 with 'Some keywords'
oWorkSheet1.Range("A2").Value := "Some author's name"       ;Fill in cell A2 with 'Some author's name'

A1 := oWorkSheet1.Range("A1").Value                         ;store the value of cell A1 in var 'A1'
A2 := oWorkSheet1.Range("A2").Value                         ;store the value of cell A2 in var 'A2'
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
;xxxxxxxxxxxxxxxxxxxxxxxxxxx Open IE xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
oIE := ComObjCreate("InternetExplorer.Application")
oIE.Navigate("http://www.autohotkey.com/forum/search.php")
oIE.Visible := 1
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
;xxxxxxxxxxxxxxxxx Wait for IE to be done loading xxxxxxxxxxxxxxxxxxx
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
While oIE.readyState!=4 || oIE.document.readyState!="complete" || oIE.busy
   Sleep 50
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
;xxxxxxxxxxxxxxxxxxxx Fill fields in IE xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
oIE.document.getElementsByTagName("input")[0].value := A1     ;paste the value from var 'A1' to the input field number 0 found with iwb2 learner
oIE.document.getElementsByTagName("input")[3].value := A2     ;paste the value from var 'A2' to the input field number 3 found with iwb2 learner
return

As you can se its all in the other posts... :)

hope it helps

_________________
VariemClick()
Recommended: AutoHotkey_L


Report this post
Top
 Profile  
Reply with quote  
PostPosted: May 3rd, 2012, 3:29 pm 
Offline

Joined: May 3rd, 2012, 12:42 am
Posts: 2
Thank you for your reply.

Sorry for asking but where are you getting the input # from. The Source Code?

If so, my issue may be a little complex and the source code for the line items i need to populate do not house these #'s.

I ran the web learner tool and could not locate the values for the line item inputs.

Also, I will already have my worksheet and webpage open, how could the code be changed to just access the open spreadsheet, store the values and paste them to the active web page.

Thanks in advance for your help.


Report this post
Top
 Profile  
Reply with quote  
PostPosted: May 3rd, 2012, 9:37 pm 
Offline
User avatar

Joined: February 28th, 2012, 11:13 pm
Posts: 59
Location: Denmark
Hmm lets see the numbers from IE

Frist drag the cross from iwb2 learner to the IE field, that you need the ("tag name") and [number] of like this
Image


Then you'll get the <tag name> and index [#] from here

Image

A way to your already open Excel, could look like this
Code:
oExcel := ComObjActive("Excel.Application") ;creates a handle to your currently active excel application
And here is a way to access an IE object by Window/Tab Name:
Code:
; AutoHotkey_L:

oIE := IEGet() ; creates a handle to your currently active Internet Explore Window/Tab


;Function code:
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
} ;written by Jethrow


Hope it helps :D

_________________
VariemClick()
Recommended: AutoHotkey_L


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 26 posts ]  Go to page Previous  1, 2

All times are UTC [ DST ]


Who is online

Users browsing this forum: BrandonHotkey, hyper_, immunity, migz99, sjc1000 and 74 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group