From 6befc8ce11c03c0ed5065df941f211437470cc58 Mon Sep 17 00:00:00 2001 From: Sanoris <58455437+Sanoris@users.noreply.github.com> Date: Tue, 18 Jun 2024 23:00:09 -0500 Subject: [PATCH 1/6] Added multiple random attribute support --- Dark and Darker/Auction Pricer.ahk | 36 +++++++++++++++++------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/Dark and Darker/Auction Pricer.ahk b/Dark and Darker/Auction Pricer.ahk index cbab563..b834616 100644 --- a/Dark and Darker/Auction Pricer.ahk +++ b/Dark and Darker/Auction Pricer.ahk @@ -1,6 +1,6 @@ #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 @@ -8,16 +8,16 @@ F3:: { ocrResult := OCR.FromRect(1333, 140, 577, 890, , scale:=1).Text ; Scans Stash area in auction window for item - + ;ToolTip(ocrResult) rarity := GetItemRarity(ocrResult) itemName := GetItemName(ocrResult) - + ;Sleep(100000) if (itemName = "") { ToolTip("Item not found, try again.") return } - enchantment := GetItemEnchantments(ocrResult) + enchantmentArr := GetItemEnchantments(ocrResult) ; TODO ; We could use OCR for most of the following steps. @@ -52,17 +52,22 @@ F3:: Sleep(100) MouseClick("Left", 150, 275, , ) ; Click item 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 + for index, enchantmentL in enchantmentArr { + MouseClick("Left", 1500, 250, , ) ; Click enchantment name search box + Sleep(250) + ;Send("^a{BS}") ; Clear textbox + ;Sleep(100) + Send(enchantmentL) ; Type enchantment name + Sleep(100) + enchantmentPos := (index * 25) + (250) + ;ToolTip("" . enchantmentPos) + ;Sleep(1000) + MouseClick("Left", 1500, enchantmentPos, , ) ; Click enchantment name + Sleep(100) + } + Sleep(100) MouseClick("Left", 1800, 275, , ) ; Click search } @@ -133,8 +138,9 @@ GetItemEnchantments(ocrResult) { enchantmentsText .= ", " } } - ; ToolTip(itemName . " " . rarity . " (" . enchantmentsText . ")") ; Easy debug + ;ToolTip(enchantmentsFound) ; Easy debug + ;sleep(50000) } - return enchantment + return enchantmentsFound } From 525464a9779137f931abfe508093fecaae1d8600 Mon Sep 17 00:00:00 2001 From: Sanoris <58455437+Sanoris@users.noreply.github.com> Date: Thu, 20 Jun 2024 19:06:49 -0500 Subject: [PATCH 2/6] Added rings, necklaces, and lockpick. Item adding has proven tedious --- Dark and Darker/Helper.ahk | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/Dark and Darker/Helper.ahk b/Dark and Darker/Helper.ahk index 52472be..a31ea63 100644 --- a/Dark and Darker/Helper.ahk +++ b/Dark and Darker/Helper.ahk @@ -37,7 +37,9 @@ ENCHANTMENTS := [ "Memory Capacity Add", "Memory Capacity Bonus", "Luck", - "Additional Weapon Damage" + "Additional Weapon Damage", + "Max Health", + "Armor Rating" ] ITEMS := [ @@ -282,5 +284,30 @@ 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", + "Pheonix Choker", + "Rat Pendant", + "Torq of Soul", + "Wind Locket", + + "Lockpick" ] From 203c4042538a7d4191789b2f25ca33efb5b3ce3e Mon Sep 17 00:00:00 2001 From: Sanoras1 Date: Thu, 19 Sep 2024 11:56:57 -0500 Subject: [PATCH 3/6] Update Helper.ahk changed order of enchantments to search for other rolls because damage rolls can only roll 1. Added missing enchantments. --- Dark and Darker/Helper.ahk | 59 ++++++++++++++++++++++++-------------- 1 file changed, 37 insertions(+), 22 deletions(-) diff --git a/Dark and Darker/Helper.ahk b/Dark and Darker/Helper.ahk index a31ea63..ff1a99d 100644 --- a/Dark and Darker/Helper.ahk +++ b/Dark and Darker/Helper.ahk @@ -1,45 +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" + "Armor Rating", + "Max Health Bonus", + "Additional Physical Damage", + "True Physical Damage", + "Additional Weapon Damage", + "True Magical Damage", + "Additional Magical Damage", + ] ITEMS := [ @@ -64,6 +56,7 @@ ITEMS := [ "Divine Rod", "Divine Staff", "Light Bringer", + "Flanged Mace", "Rod of Righteousness", "Staff of Righteousness", "Sterling Rod", @@ -304,10 +297,32 @@ ITEMS := [ "Necklace of Peace", "Owl Pendant", "Ox Pendant", - "Pheonix Choker", + "Phoenix Choker", "Rat Pendant", "Torq of Soul", "Wind Locket", - "Lockpick" + "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", + + ] From d87b94160e4ac68c2a358b5700a9ba0d1ac75665 Mon Sep 17 00:00:00 2001 From: Sanoras1 Date: Sat, 28 Sep 2024 01:17:14 -0500 Subject: [PATCH 4/6] Add files via upload Made a new function to get coordinates for the stash tab. This will later be used to also get the coordinates required to search on different resolution. --- Dark and Darker/Auction Pricer.ahk | 77 +++++++++++++++++++++++++----- 1 file changed, 64 insertions(+), 13 deletions(-) diff --git a/Dark and Darker/Auction Pricer.ahk b/Dark and Darker/Auction Pricer.ahk index b834616..ec249ad 100644 --- a/Dark and Darker/Auction Pricer.ahk +++ b/Dark and Darker/Auction Pricer.ahk @@ -2,16 +2,72 @@ #Requires AutoHotkey v2.0+ #include .\OCR.ahk ; https://github.com/Descolada/OCR #include .\Helper.ahk +#include .\ScreenCapture.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 - ;ToolTip(ocrResult) + + + + +; Declare coordinate variables at the top +global x1 := 0, y1 := 0, x2 := 0, y2 := 0 + +; 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(2000) + + 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(2000) + + 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(2000) + + 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(2000) + + return {x1: x1, y1: y1, x2: x2, y2: y2} +} + +; Hotkey to set the coordinates +F9:: { + coordinates := CaptureCoordinates() + MsgBox("Coordinates for OCR.FromRect:`nX1: " coordinates.x1 "`nY1: " coordinates.y1 "`nX2: " coordinates.x2 "`nY2: " coordinates.y2) +} + +; 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) - ;Sleep(100000) + if (itemName = "") { ToolTip("Item not found, try again.") return @@ -19,10 +75,6 @@ F3:: enchantmentArr := GetItemEnchantments(ocrResult) - ; TODO - ; We could use OCR for most of the following steps. - - ; Now we swap to view market tab MouseClick("Left", 850, 115, ,) ; View Market button Sleep(500) @@ -54,16 +106,13 @@ F3:: Sleep(100) 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("^a{BS}") ; Clear textbox - ;Sleep(100) Send(enchantmentL) ; Type enchantment name Sleep(100) enchantmentPos := (index * 25) + (250) - ;ToolTip("" . enchantmentPos) - ;Sleep(1000) MouseClick("Left", 1500, enchantmentPos, , ) ; Click enchantment name Sleep(100) } @@ -73,6 +122,8 @@ F3:: } + + GetItemRarity(ocrResult) { rarity := "" if InStr(ocrResult, "Uncommon") { From 367a025b318bea06a482071e2cb0d8b96a00f180 Mon Sep 17 00:00:00 2001 From: Sanoras1 Date: Sat, 28 Sep 2024 03:29:24 -0500 Subject: [PATCH 5/6] Add files via upload fixed small problems with the coordinate finder function --- Dark and Darker/Auction Pricer.ahk | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Dark and Darker/Auction Pricer.ahk b/Dark and Darker/Auction Pricer.ahk index ec249ad..3b49e9a 100644 --- a/Dark and Darker/Auction Pricer.ahk +++ b/Dark and Darker/Auction Pricer.ahk @@ -40,15 +40,18 @@ CaptureCoordinates() { KeyWait("LButton", "D") MouseGetPos(&x1, &y2) Tooltip("Bottom Left corner set at: " x1 ", " y2) - Sleep(2000) + Sleep(2000) + + setTimer(RemoveTooltip, 3000) + RemoveTooltip() { + Tooltip("") ; Clear the tooltip + } - return {x1: x1, y1: y1, x2: x2, y2: y2} } ; Hotkey to set the coordinates F9:: { coordinates := CaptureCoordinates() - MsgBox("Coordinates for OCR.FromRect:`nX1: " coordinates.x1 "`nY1: " coordinates.y1 "`nX2: " coordinates.x2 "`nY2: " coordinates.y2) } ; F3 hotkey for auction pricing logic @@ -70,6 +73,10 @@ F3:: { if (itemName = "") { ToolTip("Item not found, try again.") + SetTimer(RemoveTooltip, 3000) ; Set timer for 3000 milliseconds (3 seconds) + RemoveTooltip() { + Tooltip("") ; Clear the tooltip + } return } @@ -119,6 +126,7 @@ F3:: { Sleep(100) MouseClick("Left", 1800, 275, , ) ; Click search + } From eabaaa84cbc88b83f728e28583af75368ea0b693 Mon Sep 17 00:00:00 2001 From: Sanoras1 Date: Mon, 30 Sep 2024 19:39:55 -0500 Subject: [PATCH 6/6] Fixed issue with duplicate item names/ capturecoordinate function --- Dark and Darker/Auction Pricer.ahk | 81 +++++++++++++++++++----------- 1 file changed, 52 insertions(+), 29 deletions(-) diff --git a/Dark and Darker/Auction Pricer.ahk b/Dark and Darker/Auction Pricer.ahk index 3b49e9a..e20a51d 100644 --- a/Dark and Darker/Auction Pricer.ahk +++ b/Dark and Darker/Auction Pricer.ahk @@ -2,7 +2,6 @@ #Requires AutoHotkey v2.0+ #include .\OCR.ahk ; https://github.com/Descolada/OCR #include .\Helper.ahk -#include .\ScreenCapture.ahk ; https://github.com/MonzterDev/AHK-Game-Scripts @@ -11,7 +10,7 @@ ; Declare coordinate variables at the top -global x1 := 0, y1 := 0, x2 := 0, y2 := 0 +global x1 := 1344, y1 := 123, x2 := 1891, y2 := 1055 ; Function to get coordinates CaptureCoordinates() { @@ -22,25 +21,25 @@ CaptureCoordinates() { KeyWait("LButton", "D") MouseGetPos(&x1, &y1) Tooltip("Top Left corner set at: " x1 ", " y1) - Sleep(2000) + 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(2000) + 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(2000) + 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(2000) + Sleep(1000) setTimer(RemoveTooltip, 3000) RemoveTooltip() { @@ -69,9 +68,9 @@ F3:: { 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() { @@ -88,6 +87,16 @@ F3:: { 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") { @@ -103,14 +112,6 @@ 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 - Sleep(100) MouseClick("Left", 1500, 200, , ) ; Click random attributes Sleep(100) @@ -149,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. @@ -203,3 +225,4 @@ GetItemEnchantments(ocrResult) { return enchantmentsFound } +