#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#SingleInstance [Forced]
CoordMode, Pixel, Screen
Delay = 30000
UpArrow = 0
DownArrow = 0
DoubleCheck = 0
PrevUpArrow = 0
PrevDownArrow = 0
Buy = 0
Sell = 0
OpenBuyOrder = 0
OpenSellOrder = 0
SixtyFour = 0
ThirtyTwo = 0
Sixteen = 0
Eight = 0
Four = 0
Two = 0
One = 0
Contracts = 0
#P:: Pause
#Z::
Goto, ContractCalc
Main:
ImageSearch, FoundX, FoundY, 700, 0, 800, 200, *w14 *h17 *TransBlack C:\Users\Home\Desktop\AutoHotKey Images\UpTrendLabel.tiff
If (ErrorLevel = 0)
{
OpenBuyOrder = 1
}
Else If (ErrorLevel = 1)
{
OpenBuyOrder = 0
}
ImageSearch, FoundX, FoundY, 700, 0, 800, 200, *w14 *h17 *TransBlack C:\Users\Home\Desktop\AutoHotKey Images\DownTrendLabel.tiff
If (ErrorLevel = 0)
{
OpenSellOrder = 1
}
Else If (ErrorLevel = 1)
{
OpenSellOrder = 0
}
Check:
Loop{
ImageSearch, FoundX, FoundY, 0, 0, 1900, 1050, *w23 *h23 C:\Users\Home\Desktop\AutoHotKey Images\TVOK.tiff
If (ErrorLevel = 0)
{
;MouseMove, (FoundX-22), (FoundY+11)
MouseClick, Left, (FoundX-22), (FoundY+11), 1, 0
MouseClick, Left, (FoundX-22), (FoundY+11), 1, 0
Sleep,5000
MouseClick, Left, 875, 30, 1, 0
}
Else If (ErrorLevel = 1)
{
}
ImageSearch, FoundX, FoundY, 0, 0, 1900, 1050, *w38 *h22 C:\Users\Home\Desktop\AutoHotKey Images\OK2.tiff
If (ErrorLevel = 0)
{
;MouseMove, 300, -190
;MouseClick, Left, (FoundX-22), (FoundY+11), 1, 0
;MouseClick, Left, (FoundX-22), (FoundY+11), 1, 0
;Sleep,5000
MouseClick, Left, 300, -190, 1, 0
}
Else If (ErrorLevel = 1)
{
}
ImageSearch, FoundX, FoundY, 700, 0, 800, 200, *w14 *h17 *TransBlack C:\Users\Home\Desktop\AutoHotKey Images\UpTrendLabel.tiff
If (ErrorLevel = 0 and OpenBuyOrder = 0)
{
UpArrow = 1
If PrevUpArrow != %UpArrow%
{
DoubleCheck = 1
PrevUpArrow := UpArrow
}
}
Else If (ErrorLevel = 1)
{
OpenBuyOrder = 0
UpArrow = 0
If PrevUpArrow != %UpArrow%
{
DoubleCheck = 1
PrevUpArrow := UpArrow
}
}
ImageSearch, FoundX, FoundY, 700, 0, 800, 200, *w14 *h17 *TransBlack C:\Users\Home\Desktop\AutoHotKey Images\DownTrendLabel.tiff
If (ErrorLevel = 0 and OpenSellOrder = 0)
{
DownArrow = 1
If PrevDownArrow != %DownArrow%
{
DoubleCheck = 1
PrevDownArrow := DownArrow
}
}
Else If (ErrorLevel = 1)
{
OpenSellOrder = 0
DownArrow = 0
If PrevDownArrow != %DownArrow%
{
DoubleCheck = 1
PrevDownArrow := DownArrow
}
}
If DoubleCheck = 1
{
;Sleep, Delay
DoubleCheck = 0
Goto, Check
}
If (UpArrow = 0 and DownArrow = 1)
{
If (Buy = 0 and Sell = 0)
{
;Click Sell Button
;Send +S
MouseClick, Left, 1580, 125, 1, 0
MouseClick, Left, 875, 30, 1, 0
Buy = 0
Sell = 1
;Sleep, Delay
}
Else If (Buy = 1 and Sell = 0)
{
;Click Flatten Button
MouseClick, Left, 1818, 125, 1, 0
MouseClick, Left, 875, 30, 1, 0
;Click Sell Button
;MouseClick, Left, 1580, 125, 1, 0
;MouseClick, Left, 875, 30, 1, 0
Buy = 0
Sell = 0
Goto, Wait
}
}
Else If (UpArrow = 1 and DownArrow = 0)
{
if (Buy = 0 and Sell = 0)
{
;Click Buy Button
;Send +B
MouseClick, Left, 1495, 125, 1, 0
MouseClick, Left, 875, 30, 1, 0
Buy = 1
Sell = 0
;Sleep, Delay
}
Else If (Buy = 0 and Sell = 1)
{
;Click Flatten Button
MouseClick, Left, 1818, 125, 1, 0
MouseClick, Left, 875, 30, 1, 0
;Click Buy Button
;MouseClick, Left, 1495, 125, 1, 0
;MouseClick, Left, 875, 30, 1, 0
Buy = 0
Sell = 0
Goto, Wait
}
}
Else If (UpArrow = 0 and DownArrow = 0)
{
If (Buy = 1 and Sell = 0)
{
;Click Sell Button
;Buy = 0
;Sell = 0
;Send +S
;MouseClick, Left, 1570, 125, 1, 0
;MouseClick, Left, 875, 30, 1, 0
;Click Flatten Button
;MouseClick, Left, 1818, 125, 1, 0
;MouseClick, Left, 875, 30, 1, 0
;Sleep, Delay
;Goto, ContractCalc
}
Else If (Buy = 0 and Sell = 1)
{
;Click Buy Button
;Buy = 0
;Sell = 0
;Send +B
;MouseClick, Left, 1495, 125, 1, 0
;MouseClick, Left, 875, 30, 1, 0
;Click Flatten Button
;MouseClick, Left, 1818, 125, 1, 0
;MouseClick, Left, 875, 30, 1, 0
;Sleep, Delay
;Goto, ContractCalc
}
}
Else If (UpArrow = 1 and DownArrow = 1)
{
If (Buy = 1 and Sell = 0)
{
;Click Sell Button
;Buy = 0
;Sell = 0
;Send +S
;MouseClick, Left, 1570, 135, 1, 0
;MouseClick, Left, 875, 30, 1, 0
;Sleep, Delay
;Goto, Main
}
Else If (Buy = 0 and Sell = 1)
{
;Click Buy Button
;Buy = 0
;Sell = 0
;Send +B
;MouseClick, Left, 1495, 135, 1, 0
;MouseClick, Left, 875, 30, 1, 0
;Sleep, Delay
;Goto, Main
}
}
}
Return
;#########################################################################################
Wait:
ImageSearch, FoundX, FoundY, 700, 0, 800, 200, *w8 *h17 *TransBlack C:\Users\Home\Desktop\AutoHotKey Images\PositionOpen.tiff
If (ErrorLevel = 0)
{
Goto, Wait
}
Else If (ErrorLevel = 1)
{
Goto, ContractCalc
}
;#########################################################################################
#C::
ContractCalc:
ImageSearch, FoundX, FoundY, 0, 500, 125, 1000, *w8 *h17 C:\Users\Home\Desktop\AutoHotKey Images\64.tiff
If (ErrorLevel = 0)
{
SixtyFour = 64
}
Else
{
SixtyFour = 0
}
ImageSearch, FoundX, FoundY, 0, 500, 125, 1000, *w8 *h17 C:\Users\Home\Desktop\AutoHotKey Images\32.tiff
If (ErrorLevel = 0)
{
ThirtyTwo = 32
}
Else
{
ThirtyTwo = 0
}
ImageSearch, FoundX, FoundY, 0, 500, 125, 1000, *w8 *h17 C:\Users\Home\Desktop\AutoHotKey Images\16.tiff
If (ErrorLevel = 0)
{
Sixteen = 16
}
Else
{
Sixteen = 0
}
ImageSearch, FoundX, FoundY, 0, 500, 125, 1000, *w8 *h17 C:\Users\Home\Desktop\AutoHotKey Images\8.tiff
If (ErrorLevel = 0)
{
Eight = 8
}
Else
{
Eight = 0
}
ImageSearch, FoundX, FoundY, 0, 500, 125, 1000, *w8 *h17 C:\Users\Home\Desktop\AutoHotKey Images\4.tiff
If (ErrorLevel = 0)
{
Four = 4
}
Else
{
Four = 0
}
ImageSearch, FoundX, FoundY, 0, 500, 125, 1000, *w8 *h17 C:\Users\Home\Desktop\AutoHotKey Images\2.tiff
If (ErrorLevel = 0)
{
Two = 2
}
Else
{
Two = 0
}
ImageSearch, FoundX, FoundY, 0, 500, 125, 1000, *w8 *h17 C:\Users\Home\Desktop\AutoHotKey Images\1.tiff
If (ErrorLevel = 0)
{
One = 1
}
Else
{
One = 0
}
Contracts := SixtyFour + ThirtyTwo + Sixteen + Eight + Four + Two + One
;MsgBox, 0, , %Contracts%, 5
MouseClick, Left, 1510, 168, 1, 0
count = 0
Loop{
Send {Delete}
count := count + 1
sleep, 10
} Until count = 5
SendInput, %Contracts%
MouseClick, Left, 750, 250, 1, 0
MouseClick, Left, 875, 30, 1, 0
Goto, Check
;################################################################################################
#B::
Buy = 1
Sell = 0
Goto, ContractCalc
;#################################################################################################
#S::
Buy = 0
Sell = 1
Goto, ContractCalc