Guest User

Untitled

a guest
Feb 26th, 2018
472
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 27.98 KB | None | 0 0
  1. ;---------------------------------------------------------------------------------------------------
  2. ; Author: BurgerKing
  3. ;---------------------------------------------------------------------------------------------------
  4. GLOBAL $TITLE = "The Lazy Craftsman"
  5. GLOBAL $VERSION = "(20180226)"
  6.  
  7. GLOBAL $ConfigFile = @AppDataDir & "\" & $TITLE & '.ini'
  8.  
  9. #include <Color.au3>
  10. #include <Math.au3>
  11.  
  12. ;---------------------------------------------------------------------------------------------------
  13. ; Global Coordinates & Variables
  14. ;---------------------------------------------------------------------------------------------------
  15. GLOBAL $ABORT = false
  16. GLOBAL $DoNotDisturb = false
  17.  
  18. Global $InventoryX0, $InventoryY0, $InventoryDX, $InventoryDY
  19. Global $InterfaceX, $InterfaceY
  20. Global $SalvageAnvilX, $SalvageAnvilY, $SalvageOKX, $SalvageOKY
  21. Global $KanaiCubeX0, $KanaiCubeY0, $KanaiCubeDX, $KanaiCubeDY, $KanaiCubeTransmuteX, $KanaiCubeTransmuteY, $KanaiCubeFillX, $KanaiCubeFillY
  22. Global $EnchantStatusX, $EnchantStatusY, $EnchantButtonX, $EnchantButtonY, $EnchantPropertyX0, $EnchantPropertyY0, $EnchantPropertyX1, $EnchantPropertyY1
  23.  
  24. GLOBAL $ItemSize=1
  25. GLOBAL $ItemSizeText[3] = ["Null Item", "Small Item", "Large Item"]
  26.  
  27. ;---------------------------------------------------------------------------------------------------
  28. ; Timing Routines
  29. ;---------------------------------------------------------------------------------------------------
  30. GLOBAL $CLOCK = TimerInit()
  31. func SetTimeOut($t)
  32. return( TimerDiff($CLOCK) + $t )
  33. endfunc
  34.  
  35. func IsTimeOut($t)
  36. return( ($t - TimerDiff($CLOCK)) <= 0 )
  37. endfunc
  38.  
  39. func GetTimeOut($t)
  40. return( $t - TimerDiff($CLOCK) )
  41. endfunc
  42.  
  43. ;---------------------------------------------------------------------------------------------------
  44. ; Mouse and Screen Functions
  45. ;---------------------------------------------------------------------------------------------------
  46. func ClickMouse($button,$x,$y,$c,$s)
  47. MouseMove($x,$y,1)
  48. if $s>0 then sleep($s)
  49. MouseClick($button,$x,$y,$c,0)
  50. endfunc
  51.  
  52. func SearchPixel($x1,$y1,$x2,$y2,$color,$tolerance)
  53. PixelSearch ($x1,$y1,$x2,$y2,$color,$tolerance)
  54. if @error = 1 then
  55. return(0)
  56. else
  57. return(1)
  58. endif
  59. endfunc
  60.  
  61. ;---------------------------------------------------------------------------------------------------
  62. ; GUI Routines
  63. ;---------------------------------------------------------------------------------------------------
  64. #include <GuiListBox.au3>
  65. #include <GUIConstantsEx.au3>
  66. #include <guiconstants.au3>
  67. #include <ColorConstants.au3>
  68. GLOBAL $DimX = 350
  69. GLOBAL $DimY = 265+20+20
  70. GLOBAL $MW = GUICreate($TITLE & " " & $VERSION, $DimX, $DimY)
  71.  
  72. func MakeLabel(ByRef $handle, $text, $x, $y, $w=200, $h=15, $fontface="Courier New", $fontsize=11, $fontweight=400, $fontcolor=0x0000FF)
  73. GUISwitch($handle)
  74. local $label = GUICtrlCreateLabel($text, $x, $y, $w, $h)
  75. GUICtrlSetFont($label, $fontsize, $fontweight, 0, $fontface, 5)
  76. GUICtrlSetColor($label, $fontcolor)
  77. return($y+$h)
  78. endfunc
  79.  
  80. local $iY=0
  81. GUICtrlCreateGroup("", 5, $iY+5, $DimX-10, $DimY-10)
  82. $iY = MakeLabel($MW, $TITLE, 20, $iY, $DImX-75, 25, "Courier New", 14, 800, 0xFF0000)
  83. $iY = MakeLabel($MW, "Ctrl-Alt-K: Kanai's Transmutation", 20, $iY, $DImX-75, 20)
  84. $iY = MakeLabel($MW, "Ctrl-Alt-S: Haedrig's Salvage", 20, $iY, $DimX-40, 20)
  85.  
  86. GUICtrlCreateGroup("", 10, $iY, $DimX-20,95)
  87. $iY = MakeLabel($MW, "Ctrl-Alt-M: Myriam's Enchantment", 20, $iY, $DimX-75, 22)
  88. $iY = MakeLabel($MW, "Property:", 30, $iY, 80, 23)
  89. $iY = MakeLabel($MW, "Value: ", 30, $iY, 80, 23)
  90. $iY = MakeLabel($MW, "Retry: ", 30, $iY, 80, 23)
  91. local $hInput1 = GUICtrlCreateInput("Critical", 115, $iY-69,$DimX-150, 22)
  92. local $hInput2 = GUICtrlCreateInput("50", 115, $iY-46,$DimX-150, 22)
  93. local $hInput3 = GUICtrlCreateInput("100", 115, $iY-23,$DimX-150, 22)
  94.  
  95. $iY += 15
  96. local $iZ = $iY
  97. $iY = MakeLabel($MW, "Ctrl-Alt-A: Abort Current Task", 20, $iY, $DimX-55, 20)
  98. $iY = MakeLabel($MW, "Ctrl-Alt-X: EXIT APPLICATION", 20, $iY, $DimX-55, 20)
  99. $iY = MakeLabel($MW, "Ctrl-Alt-1: Small Item (Single Space)", 20, $iY, $DimX-35, 20)
  100. $iY = MakeLabel($MW, "Ctrl-Alt-2: Large Item (Double Space)", 20, $iY, $DimX-35, 20)
  101. $iY = MakeLabel($MW, "Ctrl-Alt-H: Hide Inventory/Portrait", 20, $iY, $DimX-35, 20)
  102. $iY = MakeLabel($MW, "Ctrl-Alt-I: Initialize", 20, $iY, $DimX-35, 20)
  103. GUICtrlCreateGroup("", 10, $iZ-8, $DimX-20, $iY-$iZ+10)
  104.  
  105. ;Set Fonts
  106. local $fontface = "Courier New"
  107. GUICtrlSetFont($hInput1, 11, 800, 0, $fontface, 5)
  108. GUICtrlSetFont($hInput2, 11, 800, 0, $fontface, 5)
  109. GUICtrlSetFont($hInput3, 11, 800, 0, $fontface, 5)
  110.  
  111. ;---------------------------------------------------------------------------------------------------
  112. ; Multiple Tooltips Functions
  113. ;---------------------------------------------------------------------------------------------------
  114.  
  115. func CreateToolTip($name, $x, $y, $width=200, $height=15, $style=0x01, $bgcolor=0xC0C0C0, $fontsize=11, $fontface="Verdana", $fontcolor=0x0, $fixwidth=1)
  116. ;modified from GtaSpider
  117.  
  118. local $handle[4]
  119. $handle[0] = GUICreate($name, $width, $height, $x, $y, 0x80000000, 128) ;$WS_POPUP = -2147483648, $WS_EX_TOOLWINDOW = 128
  120. GUISetBkColor($bgcolor)
  121.  
  122. $handle[1] = GUICtrlCreateLabel($name, 5, 1, $width, $height, $style) ;Create label with styled text
  123. GUICtrlSetFont ($handle[1], $fontsize, 300, 0, $fontface, 5)
  124. GUICtrlSetColor($handle[1], $fontcolor)
  125.  
  126. GUISetState(@SW_HIDE, $handle[0]) ;No Show
  127. WinSetOnTop($handle[0], "", 1) ;OnTop
  128. WinSetTrans($handle[0], "", 255) ;Transparency
  129.  
  130. $handle[2] = 0
  131. $handle[3] = $fixwidth
  132. return($handle)
  133. endfunc
  134.  
  135. GLOBAL $MainToolTip
  136. GLOBAL $EnchantScreen
  137. GLOBAL $EnchantStatus
  138. GLOBAL $InitToolTip = CreateToolTip("Initialization Tooltip", (@DesktopWidth/2 - 175), (@DesktopHeight/2 - 75), 350, 150, 0x01, 0x000000, 11, "Verdana", 0x6969FF)
  139. GLOBAL $Hidden[4]
  140.  
  141. func InitializeToolTips()
  142. $MainToolTip = CreateToolTip("Main ToolTip", $InterfaceX-200, $InterfaceY-50, 400, 25, 0x01, 0xFFFF00, 14)
  143. $EnchantScreen = CreateToolTip("Enchant Screen", $EnchantStatusX-225, ($EnchantStatusY+$InterfaceY)/2-52, 450, 105, 0x0C, 0x000000, 11, "Verdana", 0x6969FF)
  144. $EnchantStatus = CreateToolTip("Enchant Status", $EnchantStatusX-150, $EnchantStatusY-30, 300, 20, 0x01, 0xC0C0C0, 10, "Courier New")
  145. for $i = 0 to INIRead($ConfigFile, "Inventory", "hidden", 0)
  146. local $x0 = INIRead($ConfigFile, "Inventory", "hidden."&$i&".x0", 0)
  147. local $y0 = INIRead($ConfigFile, "Inventory", "hidden."&$i&".y0", 0)
  148. local $x1 = INIRead($ConfigFile, "Inventory", "hidden."&$i&".x1", 0)
  149. local $y1 = INIRead($ConfigFile, "Inventory", "hidden."&$i&".y1", 0)
  150. $Hidden[$i] = CreateToolTip("", $x0, $y0, $x1-$x0+1, $y1-$y0+1, 0x01, 0x0)
  151. next
  152. endfunc
  153.  
  154. func HideToolTip(ByRef $handle, $fade=0)
  155. GUISwitch($handle[0])
  156. if ($fade>0) then ;if fade is true then disappear
  157. local $step=10
  158. local $delay = int($step*$fade*0.25/250)
  159. if ($delay<1) then $delay=1
  160. sleep($fade*0.75)
  161. for $i=250 to 0 step - $step
  162. WinSetTrans($handle[0], "", $i)
  163. sleep($delay)
  164. next
  165. endif
  166. GUISetState(@SW_HIDE, $handle[0]) ;No Show
  167. $handle[2] = 0
  168. endfunc
  169.  
  170. func PrintToolTip(ByRef $handle, $text, $timeout=5000)
  171. ;local $h = WinGetHandle("[ACTIVE]")
  172. GUISwitch($handle[0])
  173. GUICtrlSetData($handle[1], $text)
  174. GUISetState(@SW_SHOW, $handle[0]) ;Show
  175. $handle[2] = SetTimeOut($timeout)
  176. ;WinActivate($h)
  177. endfunc
  178.  
  179. func DrawBox ($x0,$y0,$x1,$y1,$bgcolor=0x0)
  180. local $handle[3]
  181. local $w = $x1-$x0
  182. local $h = $y1-$y0
  183. $handle[0] = GUICreate("Top", $w, 2, $x0, $y0, 0x80000000, 128) ;$WS_POPUP = -2147483648, $WS_EX_TOOLWINDOW = 128
  184. GUISetBkColor($bgcolor)
  185. $handle[1] = GUICreate("Right", 2, $h, $x1, $y0, 0x80000000, 128) ;$WS_POPUP = -2147483648, $WS_EX_TOOLWINDOW = 128
  186. GUISetBkColor($bgcolor)
  187. $handle[2] = GUICreate("Bottom",$w, 2, $x0, $y1, 0x80000000, 128) ;$WS_POPUP = -2147483648, $WS_EX_TOOLWINDOW = 128
  188. GUISetBkColor($bgcolor)
  189. $handle[3] = GUICreate("Left", 2, $h, $x0, $y0, 0x80000000, 128) ;$WS_POPUP = -2147483648, $WS_EX_TOOLWINDOW = 128
  190. GUISetBkColor($bgcolor)
  191. WinSetOnTop($handle[0], "", 1) ;OnTop
  192. GUISetState(@SW_SHOW, $handle[0]) ;Show
  193. WinSetOnTop($handle[1], "", 1) ;OnTop
  194. GUISetState(@SW_SHOW, $handle[1]) ;Show
  195. WinSetOnTop($handle[2], "", 1) ;OnTop
  196. GUISetState(@SW_SHOW, $handle[2]) ;Show
  197. WinSetOnTop($handle[3], "", 1) ;OnTop
  198. GUISetState(@SW_SHOW, $handle[3]) ;Show
  199. return($handle)
  200. endfunc
  201.  
  202. LoadCoordinates()
  203. InitializeToolTips()
  204.  
  205. ;---------------------------------------------------------------------------------------------------
  206. ; OCR Interface with Capture2Text
  207. ;---------------------------------------------------------------------------------------------------
  208. func OpticalRead($x1,$y1,$x2,$y2,$ws=0,$display=0)
  209. local $text = ""
  210. local $counter=0
  211. ClipPut("")
  212. do
  213. local $PID = 0
  214. local $timeout = SetTimeOut(2000) ;timeout
  215. do
  216. if $display then
  217. PrintToolTip($EnchantStatus, stringformat("Waiting for OCR:%d ", $counter) )
  218. endif
  219. if ($PID=0) then
  220. $PID = Run(stringformat('%s -b --clipboard -s "%d %d %d %d"', 'C:\Capture2Text\Capture2Text_CLI.exe' , $x1, $y1, $x2, $y2), 'C:\Capture2Text\', @SW_HIDE )
  221. endif
  222. sleep(100)
  223. $text = ClipGet()
  224. $counter += 1
  225. until ($text<>"" OR IsTimeOut($timeout))
  226. if ($PID>0) then ProcessClose($PID)
  227. until $text<>""
  228. if ($ws=0) then
  229. $text = StringStripWS($text, 2)
  230. $text = StringStripWS($text, 1)
  231. endif
  232. $text = StringReplace($text,"°/o", "%")
  233. $text = StringReplace($text,"o/o", "%")
  234. $text = StringReplace($text," ,", ",")
  235. $text = StringReplace($text,", ", ",")
  236. HideToolTip($EnchantStatus)
  237. return($text)
  238. endfunc
  239.  
  240. func GetNumber($temp)
  241. $temp = StringRegExpReplace($temp, "(?<=\d)O", "0")
  242. $temp = StringReplace($temp,",","")
  243. $temp = StringReplace($temp,"%","")
  244. local $result = StringRegExp($temp, "(?<=[\( +-])([0-9\.]+)",3)
  245. If @error then
  246. return(0)
  247. elseif UBound($result) = 1 then
  248. return(Number($result[0]))
  249. elseif UBound($result) = 2 then
  250. if ($result[1] > 0) then
  251. return((Number($result[0]) + Number($result[1]))/2)
  252. else
  253. return(Number($result[0]))
  254. endif
  255. endif
  256. endfunc
  257.  
  258. ;---------------------------------------------------------------------------------------------------
  259. ; MAIN
  260. ;---------------------------------------------------------------------------------------------------
  261. func Terminate()
  262. exit(-1)
  263. endfunc
  264. func Stop()
  265. $ABORT = true
  266. endfunc
  267.  
  268. ;HotKeySet( "^!u", "UpgradeRares" )
  269. ;HotKeySet( "^!c", "ConvertMaterial" )
  270. HotKeySet( "^!k", "KanaiCrafting" )
  271. HotKeySet( "^!s", "BlacksmithSalvage" )
  272. HotKeySet( "^!m", "Myriam" )
  273. HotKeySet( "^!a", "Stop" )
  274. HotKeySet( "^!x", "Terminate" )
  275. HotKeySet( "^!1", "SmallItem" )
  276. HotKeySet( "^!2", "LargeItem" )
  277. HotKeySet( "^!h", "HideInventory" )
  278. HotKeySet( "^!i", "Initialize" )
  279. HotKeySet( "^!d", "DebugDisplay" )
  280.  
  281. local $hide = false
  282. func HideInventory()
  283. $hide = NOT $hide
  284. if $hide then
  285. for $i = 0 to INIRead($ConfigFile, "Inventory", "hidden", 0)
  286. PrintToolTip($Hidden[$i],"")
  287. next
  288. else
  289. for $i = 0 to INIRead($ConfigFile, "Inventory", "hidden", 0)
  290. HideToolTip($Hidden[$i])
  291. next
  292. endif
  293. endfunc
  294.  
  295. GUISetState(@SW_SHOW, $MW)
  296. WHILE 1
  297. switch GUIGetMsg()
  298. case $GUI_EVENT_CLOSE
  299. exitloop
  300. endswitch
  301. if (($MainToolTip[2]>0) AND IsTimeOut($MainToolTip[2])) then
  302. HideToolTip($MainToolTip)
  303. endif
  304. if (($EnchantScreen[2]>0) AND IsTimeOut($EnchantScreen[2])) then
  305. HideToolTip($EnchantScreen)
  306. endif
  307. if (($EnchantStatus[2]>0) AND IsTimeOut($EnchantStatus[2])) then
  308. HideToolTip($EnchantStatus)
  309. endif
  310. if (($InitToolTip[2]>0) AND IsTimeOut($InitToolTip[2])) then
  311. HideToolTip($InitToolTip)
  312. endif
  313. sleep(100)
  314. WEND
  315. GUIDelete($MW)
  316. ;---------------------------------------------------------------------------------------------------
  317. ; END of MAIN
  318. ;---------------------------------------------------------------------------------------------------
  319.  
  320.  
  321. ;---------------------------------------------------------------------------------------------------
  322. ; "Empty Box" Functions
  323. ;---------------------------------------------------------------------------------------------------
  324. func IsKanaiEmpty($x,$y)
  325. $x = $KanaiCubeX0 + $KanaiCubeDX * $x
  326. $y = $KanaiCubeY0 + $KanaiCubeDY * $y
  327. local $r=0,$g=0,$b=0,$c=0
  328. for $i = $x-20 to $x+20 step 20
  329. for $j = $y-20 to $y+20 step 20
  330. $c = PixelGetColor($i,$j)
  331. $r = _ColorGetRed ($c)
  332. $g = _ColorGetGreen($c)
  333. $b = _ColorGetBlue ($c)
  334. if $r>24 or $g>24 or $b>16 then ;"empty color" is R<24 G<24 B<16
  335. return(0) ;if one pixel is not an empty color, then it is not empty
  336. endif
  337. next
  338. next
  339. return(1) ;if all pixels are background color, then it is empty
  340. endfunc
  341.  
  342. func IsInventoryEmpty ($x,$y)
  343. local $r=0,$g=0,$b=0,$c=0
  344. MouseMove($x,$y,0) ;move mouse to spot of interest
  345. for $i = $x-20 to $x+20 step 20
  346. for $j = $y-20 to $y+20 step 20
  347. $c = PixelGetColor($i,$j)
  348. $r = _ColorGetRed ($c)
  349. $g = _ColorGetGreen($c)
  350. $b = _ColorGetBlue ($c)
  351. if $r>24 or $g>24 or $b>16 then ;background color is R<24 G<24 B<16
  352. return(0) ;if one pixel is not a background color, then it is not empty
  353. endif
  354. next
  355. next
  356. return(1) ;if all pixels are background color, then it is empty
  357. endfunc
  358.  
  359. ;---------------------------------------------------------------------------------------------------
  360. ; Kanai Transmutation
  361. ;---------------------------------------------------------------------------------------------------
  362.  
  363. func KanaiCrafting()
  364. if $DoNotDisturb then return(0)
  365. $DoNotDisturb = true ;to prevent recursive call
  366. $ABORT = false
  367.  
  368. ;Kanai Coordinates
  369. ;+----+----+----+
  370. ;| 00 | 10 | 20 |
  371. ;+----+----+----+
  372. ;| 01 | 11 | 21 |
  373. ;+----+----+----+
  374. ;| 02 | 12 | 22 |
  375. ;+----+----+----+
  376. for $j = 0 to 5 step 0
  377. for $i = 0 to 9
  378. if $ABORT then exitloop
  379. PrintToolTip($MainToolTip, stringformat("Transmutating (%d,%d)",$i,$j))
  380. local $x = $InventoryX0 + $InventoryDX * $i
  381. local $y = $InventoryY0 + $InventoryDY * $j
  382. if ($i=0 AND $j=5) then
  383. ;reserved space
  384. elseif (IsInventoryEmpty($x,$y)=0) then
  385. ClickMouse("Left", $KanaiCubeFillX, $KanaiCubeFillY, 5, 0)
  386. ClickMouse("Right", $x, $y, 5, 0)
  387. for $k = 1 to 20
  388. if $ABORT then exitloop
  389. ClickMouse("Left", $KanaiCubeTransmuteX, $KanaiCubeTransmuteY, 2, 0)
  390. sleep(250)
  391. if (IsKanaiEmpty(0,0)+IsKanaiEmpty(1,0)+IsKanaiEmpty(1,1)=3) then exitloop
  392. next
  393. endif
  394. next
  395. $j += $ItemSize
  396. next
  397.  
  398. SoundPlay(@WindowsDir & "\media\tada.wav")
  399. if $ABORT then
  400. PrintToolTip($MainToolTip, "Transmutation Aborted")
  401. else
  402. PrintToolTip($MainToolTip, "Transmutation Done")
  403. endif
  404. WinActivate("Diablo III")
  405. $DoNotDisturb = false
  406. $ABORT = false
  407. endfunc
  408.  
  409. ;---------------------------------------------------------------------------------------------------
  410. ; Blacksmith Salvage
  411. ;---------------------------------------------------------------------------------------------------
  412. func BlacksmithSalvage()
  413. if $DoNotDisturb then return(0)
  414. $DoNotDisturb = true ;to prevent recursive call
  415. $ABORT = false
  416. ClickMouse("Left", $SalvageAnvilX, $SalvageAnvilY, 1, 100)
  417. for $j = 0 to 5 step 0
  418. for $i = 0 to 10
  419. if $ABORT then exitloop
  420. local $x = $InventoryX0+$InventoryDX*$i
  421. local $y = $InventoryY0+$InventoryDY*$j
  422. if ($i=0) AND ($j=5) then
  423. ;reserved space
  424. elseif (IsInventoryEmpty($x,$y)=0) then
  425. ClickMouse("Left", $x, $y, 1, 5)
  426. PrintToolTip($MainToolTip, stringformat("Salvaging %s at (%d,%d)", $ItemSizeText[$ItemSize],$i,$j))
  427. sleep(250)
  428. if SearchPixel($SalvageOKX-5, $SalvageOKY-2, $SalvageOKX+5, $SalvageOKY+2, 0xF3AA55, 8) then
  429. ClickMouse("Left", $SalvageOKX, $SalvageOKY, 1, 5)
  430. endif
  431. endif
  432. next
  433. $j += $ItemSize
  434. next
  435.  
  436. SoundPlay(@WindowsDir & "\media\tada.wav")
  437. if $ABORT then
  438. PrintToolTip($MainToolTip, "Salvage Aborted")
  439. else
  440. PrintToolTip($MainToolTip, "Salvage Done")
  441. endif
  442. WinActivate("Diablo III")
  443. $DoNotDisturb = false
  444. $ABORT = false
  445. endfunc
  446.  
  447. ;---------------------------------------------------------------------------------------------------
  448. ; Myriam Reroll
  449. ;---------------------------------------------------------------------------------------------------
  450. #include <Date.au3>
  451. func Myriam()
  452. if $DoNotDisturb then return(0)
  453. $DoNotDisturb = true ;to prevent recursive call
  454. $ABORT = false
  455.  
  456. local $DesiredProperty = GUICtrlRead($hInput1)
  457. local $DesiredNumber = GUICtrlRead($hInput2)
  458. local $Attempts = GUICtrlRead($hInput3)
  459.  
  460. local $text0 = "Select a Property to Replace" ;clean
  461. local $text1 = "Replace a Previously Enchanted Property" ;start of cycle
  462. local $text2 = "Enchanting Item" ;rolls coming in
  463. local $text3 = "Select Replacement Property" ;choose
  464.  
  465. local $RollBar =0, $checksum = 0, $number = -1
  466. local $output = "", $OCR = ""
  467. local $ThisNumber = -1
  468. local $ThisChoice = -1
  469.  
  470. PrintToolTip($MainToolTip, "Now Enchanting...")
  471.  
  472. local $dy = ($EnchantPropertyY1 - $EnchantPropertyY0) / 3
  473. while (($Attempts>0) AND ($ThisNumber<$DesiredNumber))
  474. if $ABORT then exitloop
  475. $checksum = PixelChecksum($EnchantStatusX-80,$EnchantStatusY,$EnchantStatusX+80,$EnchantStatusY)
  476.  
  477. if ($checksum=IniRead($ConfigFile,"Enchant",$text1,0)) then
  478. ClickMouse("left", $EnchantButtonX, $EnchantButtonY, 1, 10)
  479. sleep(100)
  480. elseif ($checksum=IniRead($ConfigFile,"Enchant",$text3,0)) then
  481.  
  482. if ($RollBar=0) then
  483. PrintToolTip($EnchantStatus, "rolls are coming in...")
  484. HideToolTip($EnchantStatus,5000)
  485. $RollBar=PixelChecksum($EnchantPropertyX0,$EnchantPropertyY0,$EnchantPropertyX0,$EnchantPropertyY1)
  486. elseif ($RollBar=PixelChecksum($EnchantPropertyX0,$EnchantPropertyY0,$EnchantPropertyX0,$EnchantPropertyY1)) then
  487.  
  488. $OCR = OpticalRead($EnchantPropertyX0, $EnchantPropertyY0, $EnchantPropertyX1, $EnchantPropertyY1, 1, 1)
  489. local $lines = StringSplit($OCR, @CRLF, 1)
  490.  
  491. $ThisNumber = -1
  492. $ThisChoice = -1
  493. local $x = 0
  494. $output = ""
  495. for $i = 1 to $lines[0]
  496. $number = GetNumber($lines[$i])
  497. if ($number>0 OR StringLen($lines[$i])>20) then
  498. $output &= @CRLF & $i & ": (" & $number & ") " & $lines[$i]
  499. if StringInStr($lines[$i],$DesiredProperty) then
  500. if ($number >= $ThisNumber) then
  501. $ThisChoice = $x
  502. $ThisNumber = $number
  503. endif
  504. endif
  505. $x += 1
  506. endif
  507. next
  508. if ($ThisChoice < 0) then ;pick any
  509. $ThisChoice = random(0,2,1)
  510. endif
  511. $Attempts -= 1
  512. $output = "Counter: " & $Attempts & " Current Value: " & $ThisNumber & "/" & $DesiredNumber & " " & $DesiredProperty & $output
  513. PrintToolTip($EnchantScreen, $output)
  514. while SearchPixel($EnchantPropertyX0, $EnchantPropertyY1-$dy, $EnchantPropertyX1, $EnchantPropertyY1, 0x6969FF, 4) ;while there are still 2 rerolls to choose
  515. ClickMouse("left", ($EnchantPropertyX0 + $EnchantPropertyX1)/2, $EnchantPropertyY0+$dy*(0.4+$ThisChoice), 2, 10)
  516. ClickMouse("left", $EnchantButtonX, $EnchantButtonY, 1, 10)
  517. sleep(1000)
  518. wend
  519. endif
  520. endif
  521. sleep(100)
  522. wend
  523.  
  524. SoundPlay(@WindowsDir & "\media\tada.wav")
  525. if $ABORT then
  526. PrintToolTip($MainToolTip, "Enchantment Aborted")
  527. else
  528. PrintToolTip($MainToolTip, "Enchantment Done")
  529. endif
  530. WinActivate("Diablo III")
  531. $DoNotDisturb = false
  532. $ABORT = false
  533. endfunc
  534.  
  535. func SmallItem ()
  536. $ItemSize=1
  537. endfunc
  538.  
  539. func LargeItem ()
  540. $ItemSize=2
  541. endfunc
  542.  
  543. func Initialize()
  544. local $x[4], $y[4], $z[4]
  545.  
  546. ; Character Inventory Coordinates
  547. local $LastLine = @CRLF&@CRLF & "Click 'END' key to continue."
  548.  
  549. 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.')
  550. sleep(5000)
  551. ; Salvage NPC Interface and Coordinates
  552. PrintToolTip($InitToolTip,'Where is Blacksmith Anvil button?' &@CRLF&@CRLF& '1. Go to Blacksmith.' &@CRLF& '2. Point Mouse at center of "Anvil" button.' & $LastLine)
  553. ClickENDToContinue()
  554. INIWrite($ConfigFile, "Salvage", "anvil.x", MouseGetPos(0))
  555. INIWrite($ConfigFile, "Salvage", "anvil.y", MouseGetPos(1))
  556. PrintToolTip($InitToolTip,'Where is the "OK" button?' &@CRLF&@CRLF& '1. Point Mouse at center of "OK" button.' & $LastLine)
  557. ClickENDToContinue()
  558. INIWrite($ConfigFile, "Salvage", "ok.x", MouseGetPos(0))
  559. INIWrite($ConfigFile, "Salvage", "ok.y", MouseGetPos(1))
  560. send("{ESC}")
  561.  
  562. PrintToolTip($InitToolTip,'Where is Inventory?' &@CRLF&@CRLF& '1. Mark all area of your inventory.')
  563. $z = SelectArea()
  564. INIWrite($ConfigFile, "Inventory", "x0", $z[0])
  565. INIWrite($ConfigFile, "Inventory", "y0", $z[1])
  566. INIWrite($ConfigFile, "Inventory", "x1", $z[2])
  567. INIWrite($ConfigFile, "Inventory", "y1", $z[3])
  568. INIWrite($ConfigFile, "Inventory", "dx", ($z[2]-$z[0])/10)
  569. INIWrite($ConfigFile, "Inventory", "dy", ($z[3]-$z[1])/6)
  570.  
  571. ; Kanai's Cube NPC Interface and Coordinates
  572. 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)
  573. ClickENDToContinue()
  574. INIWrite($ConfigFile, "Kanai's Cube", "transmute.x", MouseGetPos(0))
  575. INIWrite($ConfigFile, "Kanai's Cube", "transmute.y", MouseGetPos(1))
  576.  
  577. PrintToolTip($InitToolTip, 'Where is Fill button?' &@CRLF&@CRLF& '1. Open Recipe Book.' &@CRLF& '2. Point Mouse at center of "FILL" button.' & $LastLine)
  578. ClickENDToContinue()
  579. INIWrite($ConfigFile, "Kanai's Cube", "fill.x", MouseGetPos(0))
  580. INIWrite($ConfigFile, "Kanai's Cube", "fill.y", MouseGetPos(1))
  581.  
  582. PrintToolTip($InitToolTip,"Where is Kanai's Cube cells?" &@CRLF&@CRLF& "1. Mark all area of cube.")
  583. $z = SelectArea()
  584. INIWrite($ConfigFile, "Kanai's Cube", "x0", $z[0])
  585. INIWrite($ConfigFile, "Kanai's Cube", "y0", $z[1])
  586. INIWrite($ConfigFile, "Kanai's Cube", "x1", $z[2])
  587. INIWrite($ConfigFile, "Kanai's Cube", "y1", $z[3])
  588. INIWrite($ConfigFile, "Kanai's Cube", "dx", ($z[2]-$z[0])/3)
  589. INIWrite($ConfigFile, "Kanai's Cube", "dy", ($z[3]-$z[1])/3)
  590.  
  591. ; Myriam NPC Interface and Coordinates
  592. 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)
  593. ClickENDToContinue()
  594. $x[2] = MouseGetPos(0)
  595. $y[2] = MouseGetPos(1)
  596. INIWrite($ConfigFile, "Enchant", "status.x", $x[2])
  597. INIWrite($ConfigFile, "Enchant", "status.y", $y[2])
  598. MouseMove($x[2]+100,$y[2],0)
  599. sleep(250)
  600. $checksum = PixelChecksum($x[2]-80,$y[2],$x[2]+80,$y[2])
  601. INIWrite($ConfigFile, "Enchant", "Replace a Previously Enchanted Property", $checksum)
  602.  
  603. PrintToolTip($InitToolTip,"Where is Myriam's Enchant button?" &@CRLF&@CRLF& '1. Point and Click at center of "Enchant" button.' & $LastLine)
  604. ClickENDToContinue()
  605. INIWrite($ConfigFile, "Enchant", "button.x", MouseGetPos(0))
  606. INIWrite($ConfigFile, "Enchant", "button.y", MouseGetPos(1))
  607.  
  608. local $text = "Please Wait"
  609. for $i=1 to 15
  610. PrintToolTip($InitToolTip,$text)
  611. $text &= "."
  612. sleep(200)
  613. next
  614.  
  615. 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.')
  616. $z = SelectArea()
  617. INIWrite($ConfigFile, "Enchant", "property.x0", $z[0])
  618. INIWrite($ConfigFile, "Enchant", "property.y0", $z[1])
  619. INIWrite($ConfigFile, "Enchant", "property.x1", $z[2])
  620. INIWrite($ConfigFile, "Enchant", "property.y1", $z[3])
  621. $checksum = PixelChecksum($x[2]-80,$y[2],$x[2]+80,$y[2])
  622. INIWrite($ConfigFile, "Enchant", "Select Replacement Property", $checksum)
  623.  
  624. send("{ESC}")
  625. send("i")
  626.  
  627. for $i = 0 to 3
  628. PrintToolTip($InitToolTip, "You can hide 4 areas." &@CRLF& "Please mark area "& $i+1 & " of 4." )
  629. $z = SelectArea()
  630. INIWrite($ConfigFile, "Inventory", "hidden."&$i&".x0", $z[0])
  631. INIWrite($ConfigFile, "Inventory", "hidden."&$i&".y0", $z[1])
  632. INIWrite($ConfigFile, "Inventory", "hidden."&$i&".x1", $z[2])
  633. INIWrite($ConfigFile, "Inventory", "hidden."&$i&".y1", $z[3])
  634. INIWrite($ConfigFile, "Inventory", "hidden", $i)
  635. next
  636. PrintToolTip($InitToolTip,'Initialization DONE.')
  637. SoundPlay(@WindowsDir & "\media\tada.wav")
  638. LoadCoordinates()
  639. InitializeToolTips()
  640. endfunc
  641.  
  642. func LoadCoordinates()
  643.  
  644. $InventoryDX = INIRead($ConfigFile, "Inventory", "dx",0)
  645. $InventoryDY = INIRead($ConfigFile, "Inventory", "dy",0)
  646. $InventoryX0 = INIRead($ConfigFile, "Inventory", "x0",0) + 0.5 * $InventoryDX
  647. $InventoryY0 = INIRead($ConfigFile, "Inventory", "y0",0) + 0.5 * $InventoryDY
  648.  
  649. $SalvageAnvilX = INIRead($ConfigFile, "Salvage", "anvil.x",0)
  650. $SalvageAnvilY = INIRead($ConfigFile, "Salvage", "anvil.y",0)
  651.  
  652. $SalvageOKX = INIRead($ConfigFile, "Salvage", "ok.x",0)
  653. $SalvageOKY = INIRead($ConfigFile, "Salvage", "ok.y",0)
  654.  
  655. $KanaiCubeDX = INIRead($ConfigFile, "Kanai's Cube", "dx",0)
  656. $KanaiCubeDY = INIRead($ConfigFile, "Kanai's Cube", "dy",0)
  657. $KanaiCubeX0 = INIRead($ConfigFile, "Kanai's Cube", "x0",0) + 0.5 * $KanaiCubeDX
  658. $KanaiCubeY0 = INIRead($ConfigFile, "Kanai's Cube", "y0",0) + 0.5 * $KanaiCubeDY
  659.  
  660. $KanaiCubeTransmuteX = INIRead($ConfigFile, "Kanai's Cube", "transmute.x",0)
  661. $KanaiCubeTransmuteY = INIRead($ConfigFile, "Kanai's Cube", "transmute.y",0)
  662. $KanaiCubeFillX = INIRead($ConfigFile, "Kanai's Cube", "fill.x",0)
  663. $KanaiCubeFillY = INIRead($ConfigFile, "Kanai's Cube", "fill.y",0)
  664.  
  665. $EnchantStatusX = INIRead($ConfigFile, "Enchant", "status.x",0)
  666. $EnchantStatusY = INIRead($ConfigFile, "Enchant", "status.y",0)
  667.  
  668. $EnchantButtonX = INIRead($ConfigFile, "Enchant", "button.x",0)
  669. $EnchantButtonY = INIRead($ConfigFile, "Enchant", "button.y",0)
  670.  
  671. $EnchantPropertyX0 = INIRead($ConfigFile, "Enchant", "property.x0",0)
  672. $EnchantPropertyY0 = INIRead($ConfigFile, "Enchant", "property.y0",0)
  673. $EnchantPropertyX1 = INIRead($ConfigFile, "Enchant", "property.x1",0)
  674. $EnchantPropertyY1 = INIRead($ConfigFile, "Enchant", "property.y1",0)
  675.  
  676. $InterfaceX = $KanaiCubeX0 + $KanaiCubeDX
  677. $InterfaceY = $SalvageAnvilY / 2
  678. endfunc
  679.  
  680. #include <Misc.au3>
  681.  
  682. func SelectArea()
  683. local $temp
  684. local $coordinates[4]
  685.  
  686. local $hMask, $hMaster_Mask
  687.  
  688. ; Create transparent GUI with Cross cursor
  689. local $hCross_GUI = GUICreate("Test", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP, $WS_EX_TOPMOST)
  690. WinSetTrans($hCross_GUI, "", 8)
  691. GUISetState(@SW_SHOW, $hCross_GUI)
  692. GUISetCursor(3, 1, $hCross_GUI)
  693. local $hRectangle_GUI = GUICreate("", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP, $WS_EX_TOOLWINDOW + $WS_EX_TOPMOST)
  694. GUISetBkColor(0x000000)
  695.  
  696. ; Wait until mouse button pressed
  697. while Not _IsPressed("01")
  698. Sleep(10)
  699. wend
  700. ; Get first mouse position
  701. $coordinates[0] = MouseGetPos(0)
  702. $coordinates[1] = MouseGetPos(1)
  703.  
  704. ; Draw rectangle while mouse button pressed
  705. while _IsPressed("01")
  706. $coordinates[2] = MouseGetPos(0)
  707. $coordinates[3] = MouseGetPos(1)
  708. $hMaster_Mask = _WinAPI_CreateRectRgn(0, 0, 0, 0)
  709. $hMask = _WinAPI_CreateRectRgn($coordinates[0], $coordinates[1], $coordinates[2], $coordinates[3])
  710. _WinAPI_CombineRgn($hMaster_Mask, $hMask, $hMaster_Mask, 2)
  711. _WinAPI_DeleteObject($hMask)
  712. _WinAPI_SetWindowRgn($hRectangle_GUI, $hMaster_Mask)
  713. if WinGetState($hRectangle_GUI) < 15 then GUISetState()
  714. sleep(10)
  715. wend
  716.  
  717. ; Set in correct order if required
  718. if $coordinates[2] < $coordinates[0] then
  719. $temp = $coordinates[2]
  720. $coordinates[2] = $coordinates[0]
  721. $coordinates[0] = $temp
  722. endif
  723. if $coordinates[3] < $coordinates[1] then
  724. $temp = $coordinates[3]
  725. $coordinates[3] = $coordinates[1]
  726. $coordinates[1] = $temp
  727. endif
  728.  
  729. GUIDelete($hRectangle_GUI)
  730. GUIDelete($hCross_GUI)
  731.  
  732. return($coordinates)
  733. endfunc ;==>Mark_Rect
  734.  
  735. func ClickENDToContinue($wait=0)
  736. while not _IsPressed("23")
  737. sleep(10)
  738. wend
  739. while _IsPressed("23")
  740. sleep(10)
  741. wend
  742. if ($wait>0) then sleep($wait)
  743. return(1)
  744. endfunc
  745.  
  746. func DebugDisplay()
  747. endfunc
Add Comment
Please, Sign In to add comment