Com obj loop help Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Chewi3

Com obj loop help

19 Sep 2018, 00:42

Hi, So I have a script that extracts list of name words in a page that scrapes every page when looped, the problem is that when it tries loading the next page, it repeats the names extracted on the first page. I use a debug window to keep track of what name is being appended. What it does is that it loads the first page, extracts 25 names through loop, then loops loads second page and repeat... but same names

Heres the code, I marked down the section that i need help with

Code: Select all

SetWorkingDir %A_ScriptDir% 
#SingleInstance, Force

Pagenumbers = 50
InputBox, Pages, OSRS Scraper, This is the last page used. `r`n `r`nPlease enter your new desired page numbers press enter to use the previously used one, ,,,,,,, %Pagenumbers%

Gui +AlwaysOnTop
Gui, Add, Edit, Readonly x10 y10 w125 h700 vDebug
Gui, Show, x150 y40 w145 h720, DebugWindow

URL := ComObjCreate( "InternetExplorer.Application" )

;==========================================================help here============================================
Loop,
{
URL.Navigate("https://secure.runescape.com/m=hiscore_oldschool/overall.ws?table=0&page=%A_Index%")
if (A_Index = Pages)
{
	MsgBox, done!
	ExitApp
	break
}
While ( URL.Busy || URL.ReadyState != 4 )
sleep, 100
loop, 25
{
text := URL.document.getElementsByClassName("left").item(A_Index).innerText
DebugAppend(Text)
DebugAppend("`r`n")
FileAppend, %Text%`r`n, Scrapped.txt
}
}
;==========================================================help here============================================

DebugAppend(Data)
{
	GuiControlGet, Debug
	GuiControl,, Debug, %Debug%%Data%
}
DebugMessage(str)
{
	global h_stdout
	DebugConsoleInitialize()
	str .= "`n"
	DllCall("WriteFile", "uint", h_Stdout, "uint", &str, "uint", StrLen(str), "uint*", BytesWritten, "uint", NULL)
	WinSet, Bottom,, ahk_id %h_stout%
}
DebugConsoleInitialize()
{
	global h_Stdout
	static is_open = 0
	if (is_open = 1)
		return
	is_open := 1
	DllCall("AttachConsole", int, -1, int)
	DllCall("AllocConsole", int)
	dllcall("SetConsoleTitle", "str","Paddy Debug Console")
	h_Stdout := DllCall("GetStdHandle", "int", -11)
	WinSet, Bottom,, ahk_id %h_stout%
	WinActivate,Lightroom
	return
}

~ESC::ExitApp
User avatar
nnnik
Posts: 4500
Joined: 30 Sep 2013, 01:01
Location: Germany

Re: Com obj loop help  Topic is solved

19 Sep 2018, 01:04

If you make the IntrnetExplorer window visible you will see the problem.
"https://secure.runescape.com/m=hiscore_ ... e=%A_Index%"
Will go to the url:
https://secure.runescape.com/m=hiscore_ ... e=%A_Index%
And wont replace %A_Index% with the current value of A_Index.
To do that you need to write:
"https://secure.runescape.com/m=hiscore_ ... le=0&page=" . A_Index
Recommends AHK Studio

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: inseption86, jaka1, metallizer, Rohwedder and 319 guests