Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;---------------------------------------------------------------------------------------------------
- ; Author: BurgerKing
- ;---------------------------------------------------------------------------------------------------
- GLOBAL $TITLE = "The Lazy Craftsman"
- GLOBAL $VERSION = "(20180226)"
- GLOBAL $ConfigFile = @AppDataDir & "\" & $TITLE & '.ini'
- #include <Color.au3>
- #include <Math.au3>
- ;---------------------------------------------------------------------------------------------------
- ; Global Coordinates & Variables
- ;---------------------------------------------------------------------------------------------------
- GLOBAL $ABORT = false
- GLOBAL $DoNotDisturb = false
- Global $InventoryX0, $InventoryY0, $InventoryDX, $InventoryDY
- Global $InterfaceX, $InterfaceY
- Global $SalvageAnvilX, $SalvageAnvilY, $SalvageOKX, $SalvageOKY
- Global $KanaiCubeX0, $KanaiCubeY0, $KanaiCubeDX, $KanaiCubeDY, $KanaiCubeTransmuteX, $KanaiCubeTransmuteY, $KanaiCubeFillX, $KanaiCubeFillY
- Global $EnchantStatusX, $EnchantStatusY, $EnchantButtonX, $EnchantButtonY, $EnchantPropertyX0, $EnchantPropertyY0, $EnchantPropertyX1, $EnchantPropertyY1
- GLOBAL $ItemSize=1
- GLOBAL $ItemSizeText[3] = ["Null Item", "Small Item", "Large Item"]
- ;---------------------------------------------------------------------------------------------------
- ; Timing Routines
- ;---------------------------------------------------------------------------------------------------
- GLOBAL $CLOCK = TimerInit()
- func SetTimeOut($t)
- return( TimerDiff($CLOCK) + $t )
- endfunc
- func IsTimeOut($t)
- return( ($t - TimerDiff($CLOCK)) <= 0 )
- endfunc
- func GetTimeOut($t)
- return( $t - TimerDiff($CLOCK) )
- endfunc
- ;---------------------------------------------------------------------------------------------------
- ; Mouse and Screen Functions
- ;---------------------------------------------------------------------------------------------------
- func ClickMouse($button,$x,$y,$c,$s)
- MouseMove($x,$y,1)
- if $s>0 then sleep($s)
- MouseClick($button,$x,$y,$c,0)
- endfunc
- func SearchPixel($x1,$y1,$x2,$y2,$color,$tolerance)
- PixelSearch ($x1,$y1,$x2,$y2,$color,$tolerance)
- if @error = 1 then
- return(0)
- else
- return(1)
- endif
- endfunc
- ;---------------------------------------------------------------------------------------------------
- ; GUI Routines
- ;---------------------------------------------------------------------------------------------------
- #include <GuiListBox.au3>
- #include <GUIConstantsEx.au3>
- #include <guiconstants.au3>
- #include <ColorConstants.au3>
- GLOBAL $DimX = 350
- GLOBAL $DimY = 265+20+20
- GLOBAL $MW = GUICreate($TITLE & " " & $VERSION, $DimX, $DimY)
- func MakeLabel(ByRef $handle, $text, $x, $y, $w=200, $h=15, $fontface="Courier New", $fontsize=11, $fontweight=400, $fontcolor=0x0000FF)
- GUISwitch($handle)
- local $label = GUICtrlCreateLabel($text, $x, $y, $w, $h)
- GUICtrlSetFont($label, $fontsize, $fontweight, 0, $fontface, 5)
- GUICtrlSetColor($label, $fontcolor)
- return($y+$h)
- endfunc
- local $iY=0
- GUICtrlCreateGroup("", 5, $iY+5, $DimX-10, $DimY-10)
- $iY = MakeLabel($MW, $TITLE, 20, $iY, $DImX-75, 25, "Courier New", 14, 800, 0xFF0000)
- $iY = MakeLabel($MW, "Ctrl-Alt-K: Kanai's Transmutation", 20, $iY, $DImX-75, 20)
- $iY = MakeLabel($MW, "Ctrl-Alt-S: Haedrig's Salvage", 20, $iY, $DimX-40, 20)
- GUICtrlCreateGroup("", 10, $iY, $DimX-20,95)
- $iY = MakeLabel($MW, "Ctrl-Alt-M: Myriam's Enchantment", 20, $iY, $DimX-75, 22)
- $iY = MakeLabel($MW, "Property:", 30, $iY, 80, 23)
- $iY = MakeLabel($MW, "Value: ", 30, $iY, 80, 23)
- $iY = MakeLabel($MW, "Retry: ", 30, $iY, 80, 23)
- local $hInput1 = GUICtrlCreateInput("Critical", 115, $iY-69,$DimX-150, 22)
- local $hInput2 = GUICtrlCreateInput("50", 115, $iY-46,$DimX-150, 22)
- local $hInput3 = GUICtrlCreateInput("100", 115, $iY-23,$DimX-150, 22)
- $iY += 15
- local $iZ = $iY
- $iY = MakeLabel($MW, "Ctrl-Alt-A: Abort Current Task", 20, $iY, $DimX-55, 20)
- $iY = MakeLabel($MW, "Ctrl-Alt-X: EXIT APPLICATION", 20, $iY, $DimX-55, 20)
- $iY = MakeLabel($MW, "Ctrl-Alt-1: Small Item (Single Space)", 20, $iY, $DimX-35, 20)
- $iY = MakeLabel($MW, "Ctrl-Alt-2: Large Item (Double Space)", 20, $iY, $DimX-35, 20)
- $iY = MakeLabel($MW, "Ctrl-Alt-H: Hide Inventory/Portrait", 20, $iY, $DimX-35, 20)
- $iY = MakeLabel($MW, "Ctrl-Alt-I: Initialize", 20, $iY, $DimX-35, 20)
- GUICtrlCreateGroup("", 10, $iZ-8, $DimX-20, $iY-$iZ+10)
- ;Set Fonts
- local $fontface = "Courier New"
- GUICtrlSetFont($hInput1, 11, 800, 0, $fontface, 5)
- GUICtrlSetFont($hInput2, 11, 800, 0, $fontface, 5)
- GUICtrlSetFont($hInput3, 11, 800, 0, $fontface, 5)
- ;---------------------------------------------------------------------------------------------------
- ; Multiple Tooltips Functions
- ;---------------------------------------------------------------------------------------------------
- func CreateToolTip($name, $x, $y, $width=200, $height=15, $style=0x01, $bgcolor=0xC0C0C0, $fontsize=11, $fontface="Verdana", $fontcolor=0x0, $fixwidth=1)
- ;modified from GtaSpider
- local $handle[4]
- $handle[0] = GUICreate($name, $width, $height, $x, $y, 0x80000000, 128) ;$WS_POPUP = -2147483648, $WS_EX_TOOLWINDOW = 128
- GUISetBkColor($bgcolor)
- $handle[1] = GUICtrlCreateLabel($name, 5, 1, $width, $height, $style) ;Create label with styled text
- GUICtrlSetFont ($handle[1], $fontsize, 300, 0, $fontface, 5)
- GUICtrlSetColor($handle[1], $fontcolor)
- GUISetState(@SW_HIDE, $handle[0]) ;No Show
- WinSetOnTop($handle[0], "", 1) ;OnTop
- WinSetTrans($handle[0], "", 255) ;Transparency
- $handle[2] = 0
- $handle[3] = $fixwidth
- return($handle)
- endfunc
- GLOBAL $MainToolTip
- GLOBAL $EnchantScreen
- GLOBAL $EnchantStatus
- GLOBAL $InitToolTip = CreateToolTip("Initialization Tooltip", (@DesktopWidth/2 - 175), (@DesktopHeight/2 - 75), 350, 150, 0x01, 0x000000, 11, "Verdana", 0x6969FF)
- GLOBAL $Hidden[4]
- func InitializeToolTips()
- $MainToolTip = CreateToolTip("Main ToolTip", $InterfaceX-200, $InterfaceY-50, 400, 25, 0x01, 0xFFFF00, 14)
- $EnchantScreen = CreateToolTip("Enchant Screen", $EnchantStatusX-225, ($EnchantStatusY+$InterfaceY)/2-52, 450, 105, 0x0C, 0x000000, 11, "Verdana", 0x6969FF)
- $EnchantStatus = CreateToolTip("Enchant Status", $EnchantStatusX-150, $EnchantStatusY-30, 300, 20, 0x01, 0xC0C0C0, 10, "Courier New")
- for $i = 0 to INIRead($ConfigFile, "Inventory", "hidden", 0)
- local $x0 = INIRead($ConfigFile, "Inventory", "hidden."&$i&".x0", 0)
- local $y0 = INIRead($ConfigFile, "Inventory", "hidden."&$i&".y0", 0)
- local $x1 = INIRead($ConfigFile, "Inventory", "hidden."&$i&".x1", 0)
- local $y1 = INIRead($ConfigFile, "Inventory", "hidden."&$i&".y1", 0)
- $Hidden[$i] = CreateToolTip("", $x0, $y0, $x1-$x0+1, $y1-$y0+1, 0x01, 0x0)
- next
- endfunc
- func HideToolTip(ByRef $handle, $fade=0)
- GUISwitch($handle[0])
- if ($fade>0) then ;if fade is true then disappear
- local $step=10
- local $delay = int($step*$fade*0.25/250)
- if ($delay<1) then $delay=1
- sleep($fade*0.75)
- for $i=250 to 0 step - $step
- WinSetTrans($handle[0], "", $i)
- sleep($delay)
- next
- endif
- GUISetState(@SW_HIDE, $handle[0]) ;No Show
- $handle[2] = 0
- endfunc
- func PrintToolTip(ByRef $handle, $text, $timeout=5000)
- ;local $h = WinGetHandle("[ACTIVE]")
- GUISwitch($handle[0])
- GUICtrlSetData($handle[1], $text)
- GUISetState(@SW_SHOW, $handle[0]) ;Show
- $handle[2] = SetTimeOut($timeout)
- ;WinActivate($h)
- endfunc
- func DrawBox ($x0,$y0,$x1,$y1,$bgcolor=0x0)
- local $handle[3]
- local $w = $x1-$x0
- local $h = $y1-$y0
- $handle[0] = GUICreate("Top", $w, 2, $x0, $y0, 0x80000000, 128) ;$WS_POPUP = -2147483648, $WS_EX_TOOLWINDOW = 128
- GUISetBkColor($bgcolor)
- $handle[1] = GUICreate("Right", 2, $h, $x1, $y0, 0x80000000, 128) ;$WS_POPUP = -2147483648, $WS_EX_TOOLWINDOW = 128
- GUISetBkColor($bgcolor)
- $handle[2] = GUICreate("Bottom",$w, 2, $x0, $y1, 0x80000000, 128) ;$WS_POPUP = -2147483648, $WS_EX_TOOLWINDOW = 128
- GUISetBkColor($bgcolor)
- $handle[3] = GUICreate("Left", 2, $h, $x0, $y0, 0x80000000, 128) ;$WS_POPUP = -2147483648, $WS_EX_TOOLWINDOW = 128
- GUISetBkColor($bgcolor)
- WinSetOnTop($handle[0], "", 1) ;OnTop
- GUISetState(@SW_SHOW, $handle[0]) ;Show
- WinSetOnTop($handle[1], "", 1) ;OnTop
- GUISetState(@SW_SHOW, $handle[1]) ;Show
- WinSetOnTop($handle[2], "", 1) ;OnTop
- GUISetState(@SW_SHOW, $handle[2]) ;Show
- WinSetOnTop($handle[3], "", 1) ;OnTop
- GUISetState(@SW_SHOW, $handle[3]) ;Show
- return($handle)
- endfunc
- LoadCoordinates()
- InitializeToolTips()
- ;---------------------------------------------------------------------------------------------------
- ; OCR Interface with Capture2Text
- ;---------------------------------------------------------------------------------------------------
- func OpticalRead($x1,$y1,$x2,$y2,$ws=0,$display=0)
- local $text = ""
- local $counter=0
- ClipPut("")
- do
- local $PID = 0
- local $timeout = SetTimeOut(2000) ;timeout
- do
- if $display then
- PrintToolTip($EnchantStatus, stringformat("Waiting for OCR:%d ", $counter) )
- endif
- if ($PID=0) then
- $PID = Run(stringformat('%s -b --clipboard -s "%d %d %d %d"', 'C:\Capture2Text\Capture2Text_CLI.exe' , $x1, $y1, $x2, $y2), 'C:\Capture2Text\', @SW_HIDE )
- endif
- sleep(100)
- $text = ClipGet()
- $counter += 1
- until ($text<>"" OR IsTimeOut($timeout))
- if ($PID>0) then ProcessClose($PID)
- until $text<>""
- if ($ws=0) then
- $text = StringStripWS($text, 2)
- $text = StringStripWS($text, 1)
- endif
- $text = StringReplace($text,"°/o", "%")
- $text = StringReplace($text,"o/o", "%")
- $text = StringReplace($text," ,", ",")
- $text = StringReplace($text,", ", ",")
- HideToolTip($EnchantStatus)
- return($text)
- endfunc
- func GetNumber($temp)
- $temp = StringRegExpReplace($temp, "(?<=\d)O", "0")
- $temp = StringReplace($temp,",","")
- $temp = StringReplace($temp,"%","")
- local $result = StringRegExp($temp, "(?<=[\( +-])([0-9\.]+)",3)
- If @error then
- return(0)
- elseif UBound($result) = 1 then
- return(Number($result[0]))
- elseif UBound($result) = 2 then
- if ($result[1] > 0) then
- return((Number($result[0]) + Number($result[1]))/2)
- else
- return(Number($result[0]))
- endif
- endif
- endfunc
- ;---------------------------------------------------------------------------------------------------
- ; MAIN
- ;---------------------------------------------------------------------------------------------------
- func Terminate()
- exit(-1)
- endfunc
- func Stop()
- $ABORT = true
- endfunc
- ;HotKeySet( "^!u", "UpgradeRares" )
- ;HotKeySet( "^!c", "ConvertMaterial" )
- HotKeySet( "^!k", "KanaiCrafting" )
- HotKeySet( "^!s", "BlacksmithSalvage" )
- HotKeySet( "^!m", "Myriam" )
- HotKeySet( "^!a", "Stop" )
- HotKeySet( "^!x", "Terminate" )
- HotKeySet( "^!1", "SmallItem" )
- HotKeySet( "^!2", "LargeItem" )
- HotKeySet( "^!h", "HideInventory" )
- HotKeySet( "^!i", "Initialize" )
- HotKeySet( "^!d", "DebugDisplay" )
- local $hide = false
- func HideInventory()
- $hide = NOT $hide
- if $hide then
- for $i = 0 to INIRead($ConfigFile, "Inventory", "hidden", 0)
- PrintToolTip($Hidden[$i],"")
- next
- else
- for $i = 0 to INIRead($ConfigFile, "Inventory", "hidden", 0)
- HideToolTip($Hidden[$i])
- next
- endif
- endfunc
- GUISetState(@SW_SHOW, $MW)
- WHILE 1
- switch GUIGetMsg()
- case $GUI_EVENT_CLOSE
- exitloop
- endswitch
- if (($MainToolTip[2]>0) AND IsTimeOut($MainToolTip[2])) then
- HideToolTip($MainToolTip)
- endif
- if (($EnchantScreen[2]>0) AND IsTimeOut($EnchantScreen[2])) then
- HideToolTip($EnchantScreen)
- endif
- if (($EnchantStatus[2]>0) AND IsTimeOut($EnchantStatus[2])) then
- HideToolTip($EnchantStatus)
- endif
- if (($InitToolTip[2]>0) AND IsTimeOut($InitToolTip[2])) then
- HideToolTip($InitToolTip)
- endif
- sleep(100)
- WEND
- GUIDelete($MW)
- ;---------------------------------------------------------------------------------------------------
- ; END of MAIN
- ;---------------------------------------------------------------------------------------------------
- ;---------------------------------------------------------------------------------------------------
- ; "Empty Box" Functions
- ;---------------------------------------------------------------------------------------------------
- func IsKanaiEmpty($x,$y)
- $x = $KanaiCubeX0 + $KanaiCubeDX * $x
- $y = $KanaiCubeY0 + $KanaiCubeDY * $y
- local $r=0,$g=0,$b=0,$c=0
- for $i = $x-20 to $x+20 step 20
- for $j = $y-20 to $y+20 step 20
- $c = PixelGetColor($i,$j)
- $r = _ColorGetRed ($c)
- $g = _ColorGetGreen($c)
- $b = _ColorGetBlue ($c)
- if $r>24 or $g>24 or $b>16 then ;"empty color" is R<24 G<24 B<16
- return(0) ;if one pixel is not an empty color, then it is not empty
- endif
- next
- next
- return(1) ;if all pixels are background color, then it is empty
- endfunc
- func IsInventoryEmpty ($x,$y)
- local $r=0,$g=0,$b=0,$c=0
- MouseMove($x,$y,0) ;move mouse to spot of interest
- for $i = $x-20 to $x+20 step 20
- for $j = $y-20 to $y+20 step 20
- $c = PixelGetColor($i,$j)
- $r = _ColorGetRed ($c)
- $g = _ColorGetGreen($c)
- $b = _ColorGetBlue ($c)
- if $r>24 or $g>24 or $b>16 then ;background color is R<24 G<24 B<16
- return(0) ;if one pixel is not a background color, then it is not empty
- endif
- next
- next
- return(1) ;if all pixels are background color, then it is empty
- endfunc
- ;---------------------------------------------------------------------------------------------------
- ; Kanai Transmutation
- ;---------------------------------------------------------------------------------------------------
- func KanaiCrafting()
- if $DoNotDisturb then return(0)
- $DoNotDisturb = true ;to prevent recursive call
- $ABORT = false
- ;Kanai Coordinates
- ;+----+----+----+
- ;| 00 | 10 | 20 |
- ;+----+----+----+
- ;| 01 | 11 | 21 |
- ;+----+----+----+
- ;| 02 | 12 | 22 |
- ;+----+----+----+
- for $j = 0 to 5 step 0
- for $i = 0 to 9
- if $ABORT then exitloop
- PrintToolTip($MainToolTip, stringformat("Transmutating (%d,%d)",$i,$j))
- local $x = $InventoryX0 + $InventoryDX * $i
- local $y = $InventoryY0 + $InventoryDY * $j
- if ($i=0 AND $j=5) then
- ;reserved space
- elseif (IsInventoryEmpty($x,$y)=0) then
- ClickMouse("Left", $KanaiCubeFillX, $KanaiCubeFillY, 5, 0)
- ClickMouse("Right", $x, $y, 5, 0)
- for $k = 1 to 20
- if $ABORT then exitloop
- ClickMouse("Left", $KanaiCubeTransmuteX, $KanaiCubeTransmuteY, 2, 0)
- sleep(250)
- if (IsKanaiEmpty(0,0)+IsKanaiEmpty(1,0)+IsKanaiEmpty(1,1)=3) then exitloop
- next
- endif
- next
- $j += $ItemSize
- next
- SoundPlay(@WindowsDir & "\media\tada.wav")
- if $ABORT then
- PrintToolTip($MainToolTip, "Transmutation Aborted")
- else
- PrintToolTip($MainToolTip, "Transmutation Done")
- endif
- WinActivate("Diablo III")
- $DoNotDisturb = false
- $ABORT = false
- endfunc
- ;---------------------------------------------------------------------------------------------------
- ; Blacksmith Salvage
- ;---------------------------------------------------------------------------------------------------
- func BlacksmithSalvage()
- if $DoNotDisturb then return(0)
- $DoNotDisturb = true ;to prevent recursive call
- $ABORT = false
- ClickMouse("Left", $SalvageAnvilX, $SalvageAnvilY, 1, 100)
- for $j = 0 to 5 step 0
- for $i = 0 to 10
- if $ABORT then exitloop
- local $x = $InventoryX0+$InventoryDX*$i
- local $y = $InventoryY0+$InventoryDY*$j
- if ($i=0) AND ($j=5) then
- ;reserved space
- elseif (IsInventoryEmpty($x,$y)=0) then
- ClickMouse("Left", $x, $y, 1, 5)
- PrintToolTip($MainToolTip, stringformat("Salvaging %s at (%d,%d)", $ItemSizeText[$ItemSize],$i,$j))
- sleep(250)
- if SearchPixel($SalvageOKX-5, $SalvageOKY-2, $SalvageOKX+5, $SalvageOKY+2, 0xF3AA55, 8) then
- ClickMouse("Left", $SalvageOKX, $SalvageOKY, 1, 5)
- endif
- endif
- next
- $j += $ItemSize
- next
- SoundPlay(@WindowsDir & "\media\tada.wav")
- if $ABORT then
- PrintToolTip($MainToolTip, "Salvage Aborted")
- else
- PrintToolTip($MainToolTip, "Salvage Done")
- endif
- WinActivate("Diablo III")
- $DoNotDisturb = false
- $ABORT = false
- endfunc
- ;---------------------------------------------------------------------------------------------------
- ; Myriam Reroll
- ;---------------------------------------------------------------------------------------------------
- #include <Date.au3>
- func Myriam()
- if $DoNotDisturb then return(0)
- $DoNotDisturb = true ;to prevent recursive call
- $ABORT = false
- local $DesiredProperty = GUICtrlRead($hInput1)
- local $DesiredNumber = GUICtrlRead($hInput2)
- local $Attempts = GUICtrlRead($hInput3)
- local $text0 = "Select a Property to Replace" ;clean
- local $text1 = "Replace a Previously Enchanted Property" ;start of cycle
- local $text2 = "Enchanting Item" ;rolls coming in
- local $text3 = "Select Replacement Property" ;choose
- local $RollBar =0, $checksum = 0, $number = -1
- local $output = "", $OCR = ""
- local $ThisNumber = -1
- local $ThisChoice = -1
- PrintToolTip($MainToolTip, "Now Enchanting...")
- local $dy = ($EnchantPropertyY1 - $EnchantPropertyY0) / 3
- while (($Attempts>0) AND ($ThisNumber<$DesiredNumber))
- if $ABORT then exitloop
- $checksum = PixelChecksum($EnchantStatusX-80,$EnchantStatusY,$EnchantStatusX+80,$EnchantStatusY)
- if ($checksum=IniRead($ConfigFile,"Enchant",$text1,0)) then
- ClickMouse("left", $EnchantButtonX, $EnchantButtonY, 1, 10)
- sleep(100)
- elseif ($checksum=IniRead($ConfigFile,"Enchant",$text3,0)) then
- if ($RollBar=0) then
- PrintToolTip($EnchantStatus, "rolls are coming in...")
- HideToolTip($EnchantStatus,5000)
- $RollBar=PixelChecksum($EnchantPropertyX0,$EnchantPropertyY0,$EnchantPropertyX0,$EnchantPropertyY1)
- elseif ($RollBar=PixelChecksum($EnchantPropertyX0,$EnchantPropertyY0,$EnchantPropertyX0,$EnchantPropertyY1)) then
- $OCR = OpticalRead($EnchantPropertyX0, $EnchantPropertyY0, $EnchantPropertyX1, $EnchantPropertyY1, 1, 1)
- local $lines = StringSplit($OCR, @CRLF, 1)
- $ThisNumber = -1
- $ThisChoice = -1
- local $x = 0
- $output = ""
- for $i = 1 to $lines[0]
- $number = GetNumber($lines[$i])
- if ($number>0 OR StringLen($lines[$i])>20) then
- $output &= @CRLF & $i & ": (" & $number & ") " & $lines[$i]
- if StringInStr($lines[$i],$DesiredProperty) then
- if ($number >= $ThisNumber) then
- $ThisChoice = $x
- $ThisNumber = $number
- endif
- endif
- $x += 1
- endif
- next
- if ($ThisChoice < 0) then ;pick any
- $ThisChoice = random(0,2,1)
- endif
- $Attempts -= 1
- $output = "Counter: " & $Attempts & " Current Value: " & $ThisNumber & "/" & $DesiredNumber & " " & $DesiredProperty & $output
- PrintToolTip($EnchantScreen, $output)
- while SearchPixel($EnchantPropertyX0, $EnchantPropertyY1-$dy, $EnchantPropertyX1, $EnchantPropertyY1, 0x6969FF, 4) ;while there are still 2 rerolls to choose
- ClickMouse("left", ($EnchantPropertyX0 + $EnchantPropertyX1)/2, $EnchantPropertyY0+$dy*(0.4+$ThisChoice), 2, 10)
- ClickMouse("left", $EnchantButtonX, $EnchantButtonY, 1, 10)
- sleep(1000)
- wend
- endif
- endif
- sleep(100)
- wend
- SoundPlay(@WindowsDir & "\media\tada.wav")
- if $ABORT then
- PrintToolTip($MainToolTip, "Enchantment Aborted")
- else
- PrintToolTip($MainToolTip, "Enchantment Done")
- endif
- WinActivate("Diablo III")
- $DoNotDisturb = false
- $ABORT = false
- endfunc
- func SmallItem ()
- $ItemSize=1
- endfunc
- func LargeItem ()
- $ItemSize=2
- endfunc
- func Initialize()
- local $x[4], $y[4], $z[4]
- ; Character Inventory Coordinates
- local $LastLine = @CRLF&@CRLF & "Click 'END' key to continue."
- PrintToolTip($InitToolTip, 'This procedure will teach "The Lazy Craftsman"' &@CRLF& 'all coordinates used.' &@CRLF&@CRLF& 'You will need a Legendary Item for testing.' &@CRLF&@CRLF& 'Should you make a mistake,' &@CRLF& 'you can repeat this procedure.')
- sleep(5000)
- ; Salvage NPC Interface and Coordinates
- PrintToolTip($InitToolTip,'Where is Blacksmith Anvil button?' &@CRLF&@CRLF& '1. Go to Blacksmith.' &@CRLF& '2. Point Mouse at center of "Anvil" button.' & $LastLine)
- ClickENDToContinue()
- INIWrite($ConfigFile, "Salvage", "anvil.x", MouseGetPos(0))
- INIWrite($ConfigFile, "Salvage", "anvil.y", MouseGetPos(1))
- PrintToolTip($InitToolTip,'Where is the "OK" button?' &@CRLF&@CRLF& '1. Point Mouse at center of "OK" button.' & $LastLine)
- ClickENDToContinue()
- INIWrite($ConfigFile, "Salvage", "ok.x", MouseGetPos(0))
- INIWrite($ConfigFile, "Salvage", "ok.y", MouseGetPos(1))
- send("{ESC}")
- PrintToolTip($InitToolTip,'Where is Inventory?' &@CRLF&@CRLF& '1. Mark all area of your inventory.')
- $z = SelectArea()
- INIWrite($ConfigFile, "Inventory", "x0", $z[0])
- INIWrite($ConfigFile, "Inventory", "y0", $z[1])
- INIWrite($ConfigFile, "Inventory", "x1", $z[2])
- INIWrite($ConfigFile, "Inventory", "y1", $z[3])
- INIWrite($ConfigFile, "Inventory", "dx", ($z[2]-$z[0])/10)
- INIWrite($ConfigFile, "Inventory", "dy", ($z[3]-$z[1])/6)
- ; Kanai's Cube NPC Interface and Coordinates
- PrintToolTip($InitToolTip,"Where is Kanai's Cube Transmute button?" &@CRLF&@CRLF& "1. Go to Kanai's Cube. " &@CRLF& "2. Point Mouse at center of" &@CRLF& '"TRANSMUTE" button.' & $LastLine)
- ClickENDToContinue()
- INIWrite($ConfigFile, "Kanai's Cube", "transmute.x", MouseGetPos(0))
- INIWrite($ConfigFile, "Kanai's Cube", "transmute.y", MouseGetPos(1))
- PrintToolTip($InitToolTip, 'Where is Fill button?' &@CRLF&@CRLF& '1. Open Recipe Book.' &@CRLF& '2. Point Mouse at center of "FILL" button.' & $LastLine)
- ClickENDToContinue()
- INIWrite($ConfigFile, "Kanai's Cube", "fill.x", MouseGetPos(0))
- INIWrite($ConfigFile, "Kanai's Cube", "fill.y", MouseGetPos(1))
- PrintToolTip($InitToolTip,"Where is Kanai's Cube cells?" &@CRLF&@CRLF& "1. Mark all area of cube.")
- $z = SelectArea()
- INIWrite($ConfigFile, "Kanai's Cube", "x0", $z[0])
- INIWrite($ConfigFile, "Kanai's Cube", "y0", $z[1])
- INIWrite($ConfigFile, "Kanai's Cube", "x1", $z[2])
- INIWrite($ConfigFile, "Kanai's Cube", "y1", $z[3])
- INIWrite($ConfigFile, "Kanai's Cube", "dx", ($z[2]-$z[0])/3)
- INIWrite($ConfigFile, "Kanai's Cube", "dy", ($z[3]-$z[1])/3)
- ; Myriam NPC Interface and Coordinates
- PrintToolTip($InitToolTip,"Where is Myriam's Enchant status?" &@CRLF&@CRLF& '1. Go to Myriam.' &@CRLF& '2. Put an "already enchanted" item.' &@CRLF& '3. Point Mouse at center of text:' &@CRLF& '"Replace a Previously Enchanted Property".' & $LastLine)
- ClickENDToContinue()
- $x[2] = MouseGetPos(0)
- $y[2] = MouseGetPos(1)
- INIWrite($ConfigFile, "Enchant", "status.x", $x[2])
- INIWrite($ConfigFile, "Enchant", "status.y", $y[2])
- MouseMove($x[2]+100,$y[2],0)
- sleep(250)
- $checksum = PixelChecksum($x[2]-80,$y[2],$x[2]+80,$y[2])
- INIWrite($ConfigFile, "Enchant", "Replace a Previously Enchanted Property", $checksum)
- PrintToolTip($InitToolTip,"Where is Myriam's Enchant button?" &@CRLF&@CRLF& '1. Point and Click at center of "Enchant" button.' & $LastLine)
- ClickENDToContinue()
- INIWrite($ConfigFile, "Enchant", "button.x", MouseGetPos(0))
- INIWrite($ConfigFile, "Enchant", "button.y", MouseGetPos(1))
- local $text = "Please Wait"
- for $i=1 to 15
- PrintToolTip($InitToolTip,$text)
- $text &= "."
- sleep(200)
- next
- PrintToolTip($InitToolTip,"Where are the Enchantment Text?" &@CRLF&@CRLF& '1. Mark the area where OCR will scan.' &@CRLF& 'Also include the bullets on the left.' &@CRLF& 'But not outside the boundary/frame.')
- $z = SelectArea()
- INIWrite($ConfigFile, "Enchant", "property.x0", $z[0])
- INIWrite($ConfigFile, "Enchant", "property.y0", $z[1])
- INIWrite($ConfigFile, "Enchant", "property.x1", $z[2])
- INIWrite($ConfigFile, "Enchant", "property.y1", $z[3])
- $checksum = PixelChecksum($x[2]-80,$y[2],$x[2]+80,$y[2])
- INIWrite($ConfigFile, "Enchant", "Select Replacement Property", $checksum)
- send("{ESC}")
- send("i")
- for $i = 0 to 3
- PrintToolTip($InitToolTip, "You can hide 4 areas." &@CRLF& "Please mark area "& $i+1 & " of 4." )
- $z = SelectArea()
- INIWrite($ConfigFile, "Inventory", "hidden."&$i&".x0", $z[0])
- INIWrite($ConfigFile, "Inventory", "hidden."&$i&".y0", $z[1])
- INIWrite($ConfigFile, "Inventory", "hidden."&$i&".x1", $z[2])
- INIWrite($ConfigFile, "Inventory", "hidden."&$i&".y1", $z[3])
- INIWrite($ConfigFile, "Inventory", "hidden", $i)
- next
- PrintToolTip($InitToolTip,'Initialization DONE.')
- SoundPlay(@WindowsDir & "\media\tada.wav")
- LoadCoordinates()
- InitializeToolTips()
- endfunc
- func LoadCoordinates()
- $InventoryDX = INIRead($ConfigFile, "Inventory", "dx",0)
- $InventoryDY = INIRead($ConfigFile, "Inventory", "dy",0)
- $InventoryX0 = INIRead($ConfigFile, "Inventory", "x0",0) + 0.5 * $InventoryDX
- $InventoryY0 = INIRead($ConfigFile, "Inventory", "y0",0) + 0.5 * $InventoryDY
- $SalvageAnvilX = INIRead($ConfigFile, "Salvage", "anvil.x",0)
- $SalvageAnvilY = INIRead($ConfigFile, "Salvage", "anvil.y",0)
- $SalvageOKX = INIRead($ConfigFile, "Salvage", "ok.x",0)
- $SalvageOKY = INIRead($ConfigFile, "Salvage", "ok.y",0)
- $KanaiCubeDX = INIRead($ConfigFile, "Kanai's Cube", "dx",0)
- $KanaiCubeDY = INIRead($ConfigFile, "Kanai's Cube", "dy",0)
- $KanaiCubeX0 = INIRead($ConfigFile, "Kanai's Cube", "x0",0) + 0.5 * $KanaiCubeDX
- $KanaiCubeY0 = INIRead($ConfigFile, "Kanai's Cube", "y0",0) + 0.5 * $KanaiCubeDY
- $KanaiCubeTransmuteX = INIRead($ConfigFile, "Kanai's Cube", "transmute.x",0)
- $KanaiCubeTransmuteY = INIRead($ConfigFile, "Kanai's Cube", "transmute.y",0)
- $KanaiCubeFillX = INIRead($ConfigFile, "Kanai's Cube", "fill.x",0)
- $KanaiCubeFillY = INIRead($ConfigFile, "Kanai's Cube", "fill.y",0)
- $EnchantStatusX = INIRead($ConfigFile, "Enchant", "status.x",0)
- $EnchantStatusY = INIRead($ConfigFile, "Enchant", "status.y",0)
- $EnchantButtonX = INIRead($ConfigFile, "Enchant", "button.x",0)
- $EnchantButtonY = INIRead($ConfigFile, "Enchant", "button.y",0)
- $EnchantPropertyX0 = INIRead($ConfigFile, "Enchant", "property.x0",0)
- $EnchantPropertyY0 = INIRead($ConfigFile, "Enchant", "property.y0",0)
- $EnchantPropertyX1 = INIRead($ConfigFile, "Enchant", "property.x1",0)
- $EnchantPropertyY1 = INIRead($ConfigFile, "Enchant", "property.y1",0)
- $InterfaceX = $KanaiCubeX0 + $KanaiCubeDX
- $InterfaceY = $SalvageAnvilY / 2
- endfunc
- #include <Misc.au3>
- func SelectArea()
- local $temp
- local $coordinates[4]
- local $hMask, $hMaster_Mask
- ; Create transparent GUI with Cross cursor
- local $hCross_GUI = GUICreate("Test", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP, $WS_EX_TOPMOST)
- WinSetTrans($hCross_GUI, "", 8)
- GUISetState(@SW_SHOW, $hCross_GUI)
- GUISetCursor(3, 1, $hCross_GUI)
- local $hRectangle_GUI = GUICreate("", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP, $WS_EX_TOOLWINDOW + $WS_EX_TOPMOST)
- GUISetBkColor(0x000000)
- ; Wait until mouse button pressed
- while Not _IsPressed("01")
- Sleep(10)
- wend
- ; Get first mouse position
- $coordinates[0] = MouseGetPos(0)
- $coordinates[1] = MouseGetPos(1)
- ; Draw rectangle while mouse button pressed
- while _IsPressed("01")
- $coordinates[2] = MouseGetPos(0)
- $coordinates[3] = MouseGetPos(1)
- $hMaster_Mask = _WinAPI_CreateRectRgn(0, 0, 0, 0)
- $hMask = _WinAPI_CreateRectRgn($coordinates[0], $coordinates[1], $coordinates[2], $coordinates[3])
- _WinAPI_CombineRgn($hMaster_Mask, $hMask, $hMaster_Mask, 2)
- _WinAPI_DeleteObject($hMask)
- _WinAPI_SetWindowRgn($hRectangle_GUI, $hMaster_Mask)
- if WinGetState($hRectangle_GUI) < 15 then GUISetState()
- sleep(10)
- wend
- ; Set in correct order if required
- if $coordinates[2] < $coordinates[0] then
- $temp = $coordinates[2]
- $coordinates[2] = $coordinates[0]
- $coordinates[0] = $temp
- endif
- if $coordinates[3] < $coordinates[1] then
- $temp = $coordinates[3]
- $coordinates[3] = $coordinates[1]
- $coordinates[1] = $temp
- endif
- GUIDelete($hRectangle_GUI)
- GUIDelete($hCross_GUI)
- return($coordinates)
- endfunc ;==>Mark_Rect
- func ClickENDToContinue($wait=0)
- while not _IsPressed("23")
- sleep(10)
- wend
- while _IsPressed("23")
- sleep(10)
- wend
- if ($wait>0) then sleep($wait)
- return(1)
- endfunc
- func DebugDisplay()
- endfunc
Add Comment
Please, Sign In to add comment