diff --git a/Dark and Darker/Auction Pricer.ahk b/Dark and Darker/Auction Pricer.ahk index cbab563..e20a51d 100644 --- a/Dark and Darker/Auction Pricer.ahk +++ b/Dark and Darker/Auction Pricer.ahk @@ -1,34 +1,102 @@ #SingleInstance force #Requires AutoHotkey v2.0+ -#include ..\Libs\OCR.ahk ; https://github.com/Descolada/OCR +#include .\OCR.ahk ; https://github.com/Descolada/OCR #include .\Helper.ahk ; https://github.com/MonzterDev/AHK-Game-Scripts -F3:: -{ - ocrResult := OCR.FromRect(1333, 140, 577, 890, , scale:=1).Text ; Scans Stash area in auction window for item + + + + +; Declare coordinate variables at the top +global x1 := 1344, y1 := 123, x2 := 1891, y2 := 1055 + +; Function to get coordinates +CaptureCoordinates() { + ; Use global variables + global x1, y1, x2, y2 + + Tooltip("Move your mouse to the Top Left corner of stash and click.") + KeyWait("LButton", "D") + MouseGetPos(&x1, &y1) + Tooltip("Top Left corner set at: " x1 ", " y1) + Sleep(1000) + + Tooltip("Move your mouse to the Top Right corner of stash and click.") + KeyWait("LButton", "D") + MouseGetPos(&x2, &y1) + Tooltip("Top Right corner set at: " x2 ", " y1) + Sleep(1000) + + Tooltip("Move your mouse to the Bottom Right corner of stash and click.") + KeyWait("LButton", "D") + MouseGetPos(&x2, &y2) + Tooltip("Bottom Right corner set at: " x2 ", " y2) + Sleep(1000) + + Tooltip("Move your mouse to the Bottom Left corner of stash and click.") + KeyWait("LButton", "D") + MouseGetPos(&x1, &y2) + Tooltip("Bottom Left corner set at: " x1 ", " y2) + Sleep(1000) + + setTimer(RemoveTooltip, 3000) + RemoveTooltip() { + Tooltip("") ; Clear the tooltip + } + +} + +; Hotkey to set the coordinates +F9:: { + coordinates := CaptureCoordinates() +} + +; F3 hotkey for auction pricing logic +F3:: { + ; Access global variables + global x1, y1, x2, y2 + + ; Check if the coordinates are valid + if (x1 = 0 && y1 = 0 && x2 = 0 && y2 = 0) { + MsgBox("Invalid coordinates. Please run the coordinate finder first.") + return + } + + ; Use the coordinates in OCR.FromRect + ocrResult := OCR.FromRect(x1, y1, x2 - x1, y2 - y1, , scale := 1).Text rarity := GetItemRarity(ocrResult) - itemName := GetItemName(ocrResult) + somethingElse := GetItemName(ocrResult) - if (itemName = "") { + if (somethingElse[2] = "") { ToolTip("Item not found, try again.") + SetTimer(RemoveTooltip, 3000) ; Set timer for 3000 milliseconds (3 seconds) + RemoveTooltip() { + Tooltip("") ; Clear the tooltip + } return } - enchantment := GetItemEnchantments(ocrResult) - - ; TODO - ; We could use OCR for most of the following steps. + enchantmentArr := GetItemEnchantments(ocrResult) - ; Now we swap to view market tab MouseClick("Left", 850, 115, ,) ; View Market button Sleep(500) MouseClick("Left", 1785, 200, ,) ; Reset Filters button Sleep(400) + + MouseClick("Left", 150, 200, , ) ; Click item name selection + Sleep(100) + MouseClick("Left", 150, 250, , ) ; Click item name search box + Sleep(200) + Send(somethingElse[2]) ; Type item name + Sleep(100) + MouseClick("Left", 150, 250 + (somethingElse[1] * 27), , ) ; Click item name + Sleep(100) + MouseClick("Left", 400, 200, , ) ; Click rarity selection Sleep(100) if (rarity = "Uncommon") { @@ -44,30 +112,27 @@ F3:: } Sleep(100) - MouseClick("Left", 150, 200, , ) ; Click item name selection - Sleep(100) - MouseClick("Left", 150, 250, , ) ; Click item name search box - Sleep(200) - Send(itemName) ; Type item name - Sleep(100) - MouseClick("Left", 150, 275, , ) ; Click item name + MouseClick("Left", 1500, 200, , ) ; Click random attributes Sleep(100) + for index, enchantmentL in enchantmentArr { + MouseClick("Left", 1500, 250, , ) ; Click enchantment name search box + Sleep(250) + Send(enchantmentL) ; Type enchantment name + Sleep(100) + enchantmentPos := (index * 25) + (250) + MouseClick("Left", 1500, enchantmentPos, , ) ; Click enchantment name + Sleep(100) + } - MouseClick("Left", 1500, 200, , ) ; Click random attributes - Sleep(100) - MouseClick("Left", 1500, 250, , ) ; Click enchantment name search box - Sleep(250) - Send("^a{BS}") ; Clear textbox - Sleep(100) - Send(enchantment) ; Type enchantment name - Sleep(100) - MouseClick("Left", 1500, 275, , ) ; Click enchantment name Sleep(100) MouseClick("Left", 1800, 275, , ) ; Click search + } + + GetItemRarity(ocrResult) { rarity := "" if InStr(ocrResult, "Uncommon") { @@ -85,27 +150,48 @@ GetItemRarity(ocrResult) { return rarity } + GetItemName(ocrResult) { - itemName := "" - ; TODO - ; I tried using a while loop here because sometimes the OCR cannot detect the text. - ; This didn't actually solve the issue. For now, just use hotkey again. - while (itemName = "" && A_Index <= 3) { - for i, item in ITEMS { - if InStr(ocrResult, item) { - itemName := item - break - } + itemName := "" + superSet := "" + returnArray := [] + returnArray.Push(0) + returnArray.Push("") + + + + + + for i, item in ITEMS { + if InStr(ocrResult, item) { + itemName := item + break } + } - if (itemName = "") { - Sleep(100) + for i, item in ITEMS{ + if InStr(item, itemName) { + superSet .= item .= "|" + } + } + sortedString := Sort(superSet, "D|") + itemArray := StrSplit(sortedString,"|") + + ; Check for matches + for i, BigItem in itemArray { + if BigItem = itemName { + returnArray[1] := i + returnArray[2] := BigItem + break } } + Sleep(100) - return itemName + + return returnArray } + GetItemEnchantments(ocrResult) { ; Enchantments (Random Attributes) can be distinguished from the static attributes by the "+" sign and number on the left side of the enchantment name. ; For example, "+5 Magical Damage" is an enchantment, while "Magical Damage 5" is a static attribute. @@ -133,8 +219,10 @@ GetItemEnchantments(ocrResult) { enchantmentsText .= ", " } } - ; ToolTip(itemName . " " . rarity . " (" . enchantmentsText . ")") ; Easy debug + ;ToolTip(enchantmentsFound) ; Easy debug + ;sleep(50000) } - return enchantment + return enchantmentsFound } + diff --git a/Dark and Darker/Helper.ahk b/Dark and Darker/Helper.ahk index 52472be..ff1a99d 100644 --- a/Dark and Darker/Helper.ahk +++ b/Dark and Darker/Helper.ahk @@ -1,43 +1,37 @@ ENCHANTMENTS := [ + "Move Speed Bonus", + "Additional Move Speed", "Strength", "Agility", "Dexterity", "Will", "Knowledge", "Vigor", - "Resourcefulness", "Armor Penetration", - "Additional Physical Damage", - "True Physical Damage", "Physical Damage Bonus", - "Physical Weapon Damage Add", "Physical Power", "Magic Penetration", - "Additional Magical Damage", - "True Magical Damage", "Magical Damage Bonus", "Magical Power", - "Armor Rating Add", - "Magic Resistance Add", + "Additional Armor Rating", + "Magic Resistance", "Physical Damage Reduction", "Magical Damage Reduction", - "Projectile Reduction Mod", "Action Speed", - "Move Speed Add", - "Move Speed Bonus", "Regular Interaction Speed", - "Magical Interaction Speed", "Spell Casting Speed", - "Max Health Add", - "Max Health Bonus", - "Physical Healing", "Magical Healing", - "Buff Duration Bonus", - "Debuff Duration Bonus", "Memory Capacity Add", - "Memory Capacity Bonus", "Luck", - "Additional Weapon Damage" + "Max Health", + "Armor Rating", + "Max Health Bonus", + "Additional Physical Damage", + "True Physical Damage", + "Additional Weapon Damage", + "True Magical Damage", + "Additional Magical Damage", + ] ITEMS := [ @@ -62,6 +56,7 @@ ITEMS := [ "Divine Rod", "Divine Staff", "Light Bringer", + "Flanged Mace", "Rod of Righteousness", "Staff of Righteousness", "Sterling Rod", @@ -282,5 +277,52 @@ ITEMS := [ "Splendid Cloak", "Tattered Cloak", "Vigilant Cloak", - "Watchman Cloak" + "Watchman Cloak", + + "Ring of Courage", + "Ring of Quickness", + "Ring of Resolve", + "Ring of Vitality", + "Ring of Wisdom", + "Ring of Finesse", + "Ring of Survival", + "Grimsmile Ring", + + "Badger Pendant", + "Bear Pendant", + "Fangs of Death Necklace", + "Fox Pendant", + "Frost Amulet", + "Monkey Pendant", + "Necklace of Peace", + "Owl Pendant", + "Ox Pendant", + "Phoenix Choker", + "Rat Pendant", + "Torq of Soul", + "Wind Locket", + + "Lockpick", + "Froststone Ore", + "Froststone Ingot", + "Wolf Pelt", + "Bone", + "Lantern", + "Troll Pelt", + "Troll's Blood", + "Throwing Knife", + "Bandage", + "Potion of Healing", + "Magic Protection Potion", + "Potion of Protection", + "Potion of Invisibility", + "Explosive Bottle", + "Gold Ore", + "Gold Ingot", + "Surgical Kit", + "Golden Key", + "Lyre", + "Enchanted Dark Fabric", + + ]