Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Constants.au3>
- #include <Misc.au3>
- ; Default how-to-use instructions
- ; Move mouse cursor over 'Pick A Card's spell icon (where it's colored)
- ; and press 'ctrl + ]'. After that is done. Press 'w' to start pick a card
- ; and the script will automatically pick a gold card. If you wish to change
- ; what card it automatically picks. Then press 'ctrl + z' to set it to blue,
- ; 'ctrl + x' to set to red, and 'ctrl + c' for gold.
- ; The initialization (ctrl+]) only needs to be done after the script is started.
- ; If you do not initialize after starting up the script, it will not work.
- ; Maybe even break.
- ;
- ; In short:
- ; 'ctrl + ]' on color of Pick a Card spell icon
- ; 'w' and have card picked automatically
- ; 'ctrl+z' for blue
- ; 'ctrl+x' for red
- ; 'ctrl+c' for gold
- ;
- ; If you need the auto select to be a different key, change the value:
- ; $PAC_SPELL_HOTKEY to the appropriate key value.
- ; If you wish to change the calibrate hotkey:
- ; $CALIBRATE_HOTKEY
- ; For the color picks:
- ; $PICK_BLUE_HOTKEY | $PICK_RED_HOTKEY | $PICK_GOLD_HOTKEY
- ; Modifiers are listed below. And if you wish to remove a modifier,
- ; set it to be the same value as the hotkey.
- ; constants
- ; Modifiers for key sends:
- ; ! for alt
- ; + for shift
- ; ^ for ctrl
- ; # for winkey
- ; To get more information visit the following reference:
- ; https://www.autoitscript.com/autoit3/docs/functions/Send.htm
- ; This should be the key for casting Pick a Card.
- Global $PAC_SPELL_HOTKEY = "w"
- ; hotkeys
- ; Modifiers for hotkeys:
- ; 12 for alt
- ; 10 for shift
- ; 11 for ctrl
- ; 5B for lwinkey
- ; 5C for rwinkey
- ; For further hotkey details visit the following reference:
- ; http://msdn.microsoft.com/en-us/library/windows/desktop/dd375731%28v=vs.85%29.aspx
- Global $PICK_BLUE_HOTKEY = "5A"
- Global $PICK_BLUE_MOD1 = "5A"
- Global $PICK_BLUE_MOD2 = "11"
- Global $PICK_RED_HOTKEY = "58"
- Global $PICK_RED_MOD1 = "58"
- Global $PICK_RED_MOD2 = "11"
- Global $PICK_GOLD_HOTKEY = "43"
- Global $PICK_GOLD_MOD1 = "43"
- Global $PICK_GOLD_MOD2 = "11"
- Global $CALIBRATE_HOTKEY = "DD"
- Global $CALIBRATE_MOD1 = "DD"
- Global $CALIBRATE_MOD2 = "11"
- ;card hue identifiers
- Global $BLUE_HUE_MIN = 115
- Global $BLUE_HUE_MAX = 130
- Global $RED_HUE_MIN = 220
- Global $RED_HUE_MAX = 240
- Global $GOLD_HUE_MIN = 20
- Global $GOLD_HUE_MAX = 45
- ; Card state enum
- Global $UNDEF_CARD_STATE = -1
- Global $BLUE_CARD_STATE = 0
- Global $RED_CARD_STATE = 1
- Global $GOLD_CARD_STATE = 2
- ;Client title
- Global $CLIENT_TITLE = "League of Legends (TM) Client"
- ; globals
- ; isPressed library
- Global $mLib = DllOpen("user32.dll")
- ; League of Legends window handle
- Global $lolWin
- ; May later use hues to determine the colors
- ; then use colors to detect.
- ; As it stands, most of these aren't needed.
- Global $defaultCard
- Global $blueCard
- Global $redCard
- Global $goldCard
- Global $cardPosition
- Global $cardState = $UNDEF_CARD_STATE
- ; logic start
- ; keep script alive. read input.
- While 1
- If (_IsPressed($CALIBRATE_MOD1, $mLib) And _IsPressed($CALIBRATE_MOD2, $mLib) And _IsPressed($CALIBRATE_HOTKEY, $mLib)) Then
- calibrate()
- ElseIf (_IsPressed($PICK_BLUE_MOD1, $mLib) And _IsPressed($PICK_BLUE_MOD2, $mLib) And _IsPressed($PICK_BLUE_HOTKEY, $mLib)) Then
- $cardState = $BLUE_CARD_STATE
- ElseIf (_isPressed($PICK_RED_MOD1, $mLib) And _IsPressed($PICK_RED_MOD2, $mLib) And _IsPressed($PICK_RED_HOTKEY, $mLib)) Then
- $cardState = $RED_CARD_STATE
- elseIf (_isPressed($PICK_GOLD_MOD1, $mLib) And _IsPressed($PICK_GOLD_MOD2, $mLib) And _IsPressed($PICK_GOLD_HOTKEY, $mLib)) Then
- $cardState = $GOLD_CARD_STATE
- EndIf
- switch($cardState)
- Case $BLUE_CARD_STATE
- tryBlue()
- Case $RED_CARD_STATE
- tryRed()
- Case $GOLD_CARD_STATE
- tryGold()
- EndSwitch
- WEnd
- ; logic end
- ; script driver functions
- Func calibrate()
- $cardState = $GOLD_CARD_STATE
- $lolWin = WinGetHandle($CLIENT_TITLE)
- $cardPosition = MouseGetPos()
- EndFunc
- Func tryBlue()
- tryInRange($BLUE_HUE_MIN, $BLUE_HUE_MAX)
- EndFunc
- Func tryRed()
- tryInRange($RED_HUE_MIN, $RED_HUE_MAX)
- EndFunc
- Func tryGold()
- tryInRange($GOLD_HUE_MIN, $GOLD_HUE_MAX)
- EndFunc
- Func tryInRange($min, $max)
- If (inRange(colorGetHue(PixelGetColor($cardPosition[0], $cardPosition[1], $lolWin)), $min, $max)) Then
- Send($PAC_SPELL_HOTKEY)
- Sleep(50)
- EndIf
- EndFunc
- ; Color functions
- Func toRGB($color)
- Local $rgb[3]
- $rgb[0] = getRed($color)
- $rgb[1] = getGreen($color)
- $rgb[2] = getBlue($color)
- return $rgb
- EndFunc
- Func getRed($color)
- return Floor($color/65536)
- EndFunc
- Func getGreen($color)
- return Floor(($color - getRed($color)*65536)/256)
- EndFunc
- Func getBlue($color)
- Return $color - Floor($color/256)*256
- EndFunc
- Func colorGetHue($color)
- Return getHue(toRGB($color))
- EndFunc
- Func getHue($rgb)
- $r = $rgb[0]/256
- $g = $rgb[1]/256
- $b = $rgb[2]/256
- $cmax = max($r, max($g, $b))
- $cdel = $cmax - min($r, min($g, $b))
- $hue = 0
- If ($r = $cmax) Then
- $hue = Floor(40*(($g-$b)/$cdel))
- If($hue<0) Then
- $hue = 240 + $hue
- EndIf
- ElseIf ($g = $cmax) Then
- $hue = Floor(40*(($b-$r)/$cdel + 2))
- Else
- $hue = Floor(40*(($r-$g)/$cdel + 4))
- EndIf
- Return $hue
- EndFunc
- ; Math functions
- Func max($a, $b)
- Return ($a>=$b)?$a:$b
- EndFunc
- Func min($a, $b)
- Return ($a<=$b)?$a:$b
- EndFunc
- Func inRange($val, $min, $max)
- Return ($val>=$min) And ($val<=$max)
- EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement