Anyway, I'm stumped on parsing text from a webpage to get data, specifically copying all text on the page and trying to perform math on a number found from the parsing. Here's some code for example:
Code: Select all
autoCraft(craftSkill) {
if(craftSkill == "Weapon") {
itemType = 14
} else if(craftSkill == "Armor") {
itemType = 20
} else if(craftSkill == "Bow") {
itemType = 12
} else if(craftSkill == "Spell") {
itemType = 17
} else if(craftSkill == "Relic") {
itemType = 11
} else {
return
}
sendText("/cr") ; Displays Tradeskills Ranks
craftLevel := findText(craftSkill . "crafting:")
item := craftLevel / 10
}
findText(string) {
Send ^a^c
page := clipboard
Loop parse,page,`n%A_Tab%,%A_Space%
{
line := A_LoopField
if(InStr(line,string)) {
prefix := StrLen(string) + 1
StringTrimLeft line,line,prefix
StringReplace line,line,`,,,All
break
}
}
; To deselect text
WinGetPos,,,Xmax,Ymax,A
Ycenter := Ymax/2
Send, {ALTDOWN}
ControlClick, x10 y%Ycenter%, A
Send, {ALTUP}
return line
}
Trade Skills Rank: Taskmate
Weaponcrafting: 88
Armorcrafting: 400
Bowcrafting: 11
Spellcrafting: 18
Reliccrafting: 4
Chantcrafting: 4
Metalworking: 400
Leatherworking: 400
Woodworking: 82
Glassworking: 19
Gemworking: 22
Runeworking: 6
It seems intermittent whether or not craftLevel will resolve to show 88 or some other odd text or nothing at all. And when it does resolve correctly I can never get the division to work properly either. What am I doing wrong?