The Wiki for Tale 5 is in read-only mode and is available for archival and reference purposes only. Please visit the current Tale 11 Wiki in the meantime.

If you have any issues with this Wiki, please post in #wiki-editing on Discord or contact Brad in-game.

Difference between revisions of "Takhetu/Code"

From ATITD5
Jump to navigationJump to search
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
<pre>
 
<pre>
IfWinExist eGenesis Client
+
;Ctrl+R to reload
{
+
;Ctrl+P to pause
WinGet, GameWinHandle, ID, eGenesis Client
+
 
} else {
 
Msgbox, eGenesis client not running, exiting...
 
Exit
 
}
 
 
;~ Info
 
;~ Info
;~ Ask for config
 
 
WinActivate, eGenesis Client
 
WinActivate, eGenesis Client
 
WinGetActiveStats, win_Title, Xmax, Ymax, win_Xpos, win_Ypos
 
WinGetActiveStats, win_Title, Xmax, Ymax, win_Xpos, win_Ypos
Line 14: Line 9:
 
StartYGUI := win_Ypos+35
 
StartYGUI := win_Ypos+35
 
Gui, +AlwaysOnTop +ToolWindow -Border +Background  
 
Gui, +AlwaysOnTop +ToolWindow -Border +Background  
Gui, Add, Text,,Type in how many rows and columns `nof pottery wheels you `nwill be working with:
+
Gui, Add, Text,x10 y10,Crematory Macro Running
Gui, Add, Text, x10 y55, Rows:
+
Gui, Add, Text,x10 y25,CTRL+R - Restart macro
Gui, Add, Edit,xp+35 yp-4 vnumRows, 5
+
Gui, Add, Text,x10 y40,CTRL+P - Pause macro
Gui, Add, Text,xp+20 y55, Columns:
+
Gui, Add, Text,x10 y55 vMyText,CTRL+A - Turn ON Auto mode
Gui, Add, Edit,xp+45 yp-4 vnumColumns, 5
+
Gui, Add, Text,x10 y75,Keep the crematory window away from popups.
Gui, Add, Button, x10 y70 gNext, Next »
 
 
Gui, Add, Button, x200 y5 gClose, Close  
 
Gui, Add, Button, x200 y5 gClose, Close  
 
Gui, Show, X%StartXGUI% Y%StartYGUI% w240 h100, New GUI Window
 
Gui, Show, X%StartXGUI% Y%StartYGUI% w240 h100, New GUI Window
Return
 
  
Next:
+
;~ Amigos
Gui, submit
+
;~    * B1=S1+S7
Gui, Destroy
+
;~    * B2=S5
;Get Top Left
+
;~    * B3=S2
Gui, +AlwaysOnTop +ToolWindow -Border +Background
+
;~    * B4=S4+S6
Gui, Add, Text,,Using F8F8 camera view make `nsure you can see all kettles.
+
;~    * B5=S3
Gui, Add, Text,,Make sure the wheels have no `njugs when you start.
+
 
Gui, Add, Text,,Position your mouse over `nthe topleft wheel and press the F2 key.
+
;;******* CONFIG *********
Gui, Add, Button, x200 y5 gClose, Close
+
;Singles
Gui, Show, X%StartXGUI% Y%StartYGUI% w240 h120, New GUI Window
+
B1 := 2  ;Button Number
loop
+
B1S := 5  ;Slider Number
 +
 
 +
B2 := 3  ;Button Number
 +
B2S := 2  ;Slider Number
 +
 
 +
B3 := 5  ;Button Number
 +
B3S := 3  ;Slider Number
 +
 
 +
;Pairs
 +
B4 := 1  ;Button Number
 +
B4S1 := 1 ;First Slider Number
 +
B4S2 := 7 ;Second Slider Number
 +
B4D := 0  ;0 for parallel, 1 for opposite direction
 +
 
 +
B5 := 4    ;Button Number
 +
B5S1 := 4  ;First Slider Number
 +
B5S2 := 6  ;Second Slider Number
 +
B5D := 1  ;0 for opposite, 1 for paralel direction
 +
 
 +
;;******* END OF CONFIG *********
 +
 
 +
gosub, Setup
 +
 
 +
WinActivate, eGenesis Client
 +
lastTimeSlidersMoved := A_Now
 +
autoMode := false
 +
Loop
 
{
 
{
WinActivate eGenesis Client
+
If (autoMode=true)
KeyWait, F2, D
 
KeyWait, F2
 
MouseGetPos, FirstX, FirstY, WinHandle
 
if (WinHandle = GameWinHandle)
 
 
{
 
{
Gosub, GotTopLeft
+
;~ check if completed
}
+
ImageSearch, BarX,BarY,ProgressSX,ProgressSY,ProgressEX,ProgressEY,*40 BitRed.png
}
+
if ErrorLevel=1
return
+
{
 +
;~ Knobs not moving - Finished
 +
gosub, unload
 +
gosub, load
 +
} else {
 +
currentTime := A_Now
 +
tempLast := LastTimeSlidersMoved
 +
EnvSub, tempLast,,Seconds
 +
If (tempLast<-300)
 +
{
 +
gosub, unload
 +
gosub, load
 +
}
 +
}
 +
}
 +
;~ Check to make sure the window wasn't moved
 +
WindowMoved := false
 +
ImageSearch, NewLimeX,NewLimeY,0,0,Xmax,Ymax,*40 Lime.png
 +
If ErrorLevel<1
 +
{
 +
If (NewLimeX<>LimeX)
 +
{
 +
WindowMoved := true
 +
} else {
 +
If (NewLimeY<>LimeY)
 +
{
 +
WindowMoved := True
 +
}
 +
}
 +
If WindowMoved=True
 +
{
 +
gosub, Setup
 +
}
 +
} else {
 +
gosub, Setup
 +
}
 +
 +
 +
ImageSearch, KnobX,KnobY1,SliderSearchSX1,SliderSearchSY,SliderSearchEX1,SliderSearchEY,*40 SliderKnob.png
 +
ImageSearch, KnobX,KnobY2,SliderSearchSX2,SliderSearchSY,SliderSearchEX2,SliderSearchEY,*40 SliderKnob.png
 +
ImageSearch, KnobX,KnobY3,SliderSearchSX3,SliderSearchSY,SliderSearchEX3,SliderSearchEY,*40 SliderKnob.png
 +
ImageSearch, KnobX,KnobY4,SliderSearchSX4,SliderSearchSY,SliderSearchEX4,SliderSearchEY,*40 SliderKnob.png
 +
ImageSearch, KnobX,KnobY5,SliderSearchSX5,SliderSearchSY,SliderSearchEX5,SliderSearchEY,*40 SliderKnob.png
 +
ImageSearch, KnobX,KnobY6,SliderSearchSX6,SliderSearchSY,SliderSearchEX6,SliderSearchEY,*40 SliderKnob.png
 +
ImageSearch, KnobX,KnobY7,SliderSearchSX7,SliderSearchSY,SliderSearchEX7,SliderSearchEY,*40 SliderKnob.png
 +
Knob1 := SliderM-KnobY1-1
 +
Knob2 := SliderM-KnobY2-1
 +
Knob3 := SliderM-KnobY3-1
 +
Knob4 := SliderM-KnobY4-1
 +
Knob5 := SliderM-KnobY5-1
 +
Knob6 := SliderM-KnobY6-1
 +
Knob7 := SliderM-KnobY7-1
  
GotTopLeft:
+
NoKnobsMoved := True
Gui, Destroy
 
;Get Bottom Right
 
Gui, +AlwaysOnTop +ToolWindow -Border +Background
 
Gui, Add, Text,,Position your mouse over `nthe bottom right wheel `nand press the F2 key.
 
Gui, Add, Button, x200 y5 gClose, Close
 
Gui, Show, X%StartXGUI% Y%StartYGUI% w240 h100, New GUI Window
 
  
loop
+
If B4D=0
 
{
 
{
WinActivate eGenesis Client
+
If (Knob%B4S1%<>oldKnob%B4S1%) ;knob moved
KeyWait, F2, D
 
KeyWait, F2
 
MouseGetPos, LastX, LastY, WinHandle
 
if (WinHandle = GameWinHandle)
 
 
{
 
{
Gosub, GotBottomRight
+
NoKnobsMoved := False
 +
If (Knob%B4S1%>oldKnob%B4S1%) ;knob rose
 +
{
 +
If (Knob%B4S1%>Knob%B4S2%) ;Knob%B4S1% is above Knob%B4S2%, knobs are spreading out
 +
{
 +
MouseClick,Left,ButtonX%B4%,ButtonY
 +
}
 +
} else {
 +
If (Knob%B4S1%<Knob%B4S2%) ;Knob%B4S1% is bellow Knob%B4S2%, knobs are spreading out
 +
{
 +
MouseClick,Left,ButtonX%B4%,ButtonY
 +
}
 +
}
 +
oldKnob%B4S1% := Knob%B4S1%
 +
oldKnob%B4S2% := Knob%B4S2%
 
}
 
}
}
+
} else {
return
+
If (Knob%B4S1%<>oldKnob%B4S1%) ;knob moved
 
 
GotBottomRight:
 
Gui, Destroy
 
;~ Open Windows
 
;~ Hands off
 
Gui, +AlwaysOnTop +ToolWindow -Border +Background
 
Gui, Add, Text,vTimeLeft,Leave your mouse alone, `nstarting jugs in 5 seconds.
 
Gui, Add, Button, x200 y5 gClose, Close
 
Gui, Show, X%StartXGUI% Y%StartYGUI% w240 h100, New GUI Window
 
SmallPause := 5
 
Loop, %SmallPause%
 
 
{
 
{
GuiControl, Text, TimeLeft, Leave your mouse alone, `nstarting jugs in %SmallPause% seconds.
+
NoKnobsMoved := False
SmallPause --
+
averagePos := floor((Knob%B4S1%+Knob%B4S2%)/2)
Sleep 1000
+
If (Knob%B4S1%>oldKnob%B4S1%) ;knobs are going up
 +
{
 +
If averagePos>0 ;averageposition is above center
 +
{
 +
MouseClick,Left,ButtonX%B4%,ButtonY
 +
}
 +
} else { ;knobs are going down
 +
If averagePos<0 ;averageposition is bellow center
 +
{
 +
MouseClick,Left,ButtonX%B4%,ButtonY
 +
}
 +
}
 +
oldKnob%B4S1% := Knob%B4S1%
 +
oldKnob%B4S2% := Knob%B4S2%
 
}
 
}
GuiControl, Text, TimeLeft, Making Jugs.
+
}
WinActivate eGenesis Client
 
  
;~ loop through wheels to make jugs
+
If B5D=0
topNotFound := true
 
Loop,
 
 
{
 
{
Loop, %numColumns%
+
If (Knob%B5S1%<>oldKnob%B5S1%) ;knob moved
 
{
 
{
curColumn := A_Index
+
NoKnobsMoved := False
openPosX := FirstX+(A_Index-1)*floor((LastX-FirstX)/(numColumns-1))
+
If (Knob%B5S1%>oldKnob%B5S1%) ;knob rose
Loop, %numRows%  
 
 
{
 
{
openPosY := FirstY+(A_Index-1)*floor((LastY-FirstY)/(numRows-1))
+
If (Knob%B5S1%>Knob%B5S2%) ;Knob%B5S1% is above Knob%B5S2%, knobs are spreading out
MouseClick,Left,openPosX,openPosY
+
{
sleep, 100
+
MouseClick,Left,ButtonX%B5%,ButtonY
MouseClick,Left,openPosX+10,openPosY-3
+
}
 +
} else {
 +
If (Knob%B5S1%<Knob%B5S2%) ;Knob%B5S1% is bellow Knob%B5S2%, knobs are spreading out
 +
{
 +
MouseClick,Left,ButtonX%B5%,ButtonY
 +
}
 
}
 
}
 +
oldKnob%B5S1% := Knob%B5S1%
 +
oldKnob%B5S2% := Knob%B5S2%
 
}
 
}
;Wait Until Wheel Stops
+
} else {
checksum := getPicChecksum(FirstX,FirstY)
+
If (Knob%B5S1%<>oldKnob%B5S1%) ;knob moved
Loop,
 
 
{
 
{
curCheck := getPicChecksum(FirstX,FirstX)
+
NoKnobsMoved := False
if (checksum<>curCheck)
+
averagePos := floor((Knob%B5S1%+Knob%B5S2%)/2)
 +
If (Knob%B5S1%>oldKnob%B5S1%) ;knobs are going up
 +
{
 +
If averagePos>0 ;averageposition is above center
 +
{
 +
MouseClick,Left,ButtonX%B5%,ButtonY
 +
}
 +
} else { ;knobs are going down
 +
If averagePos<0 ;averageposition is bellow center
 +
{
 +
MouseClick,Left,ButtonX%B5%,ButtonY
 +
}
 +
}
 +
oldKnob%B5S1% := Knob%B5S1%
 +
oldKnob%B5S2% := Knob%B5S2%
 +
}
 +
}
 +
 
 +
 
 +
NumAbove := 0
 +
NumBellow := 0
 +
If (Knob%B4S1%<0)
 +
{
 +
NumBellow++
 +
} Else {
 +
NumAbove++
 +
}
 +
If (Knob%B4S2%<0)
 +
{
 +
NumBellow++
 +
} Else {
 +
NumAbove++
 +
}
 +
If (Knob%B5S1%<0)
 +
{
 +
NumBellow++
 +
} Else {
 +
NumAbove++
 +
}
 +
If (Knob%B5S2%<0)
 +
{
 +
NumBellow++
 +
} Else {
 +
NumAbove++
 +
}
 +
 
 +
Axis1 := 0
 +
Axis2 := 0
 +
If NumAbove=1
 +
{
 +
Axis1 := 5
 +
} else {
 +
If NumAbove=0
 +
{
 +
Axis1 := 5
 +
Axis2 := 5
 +
} else {
 +
If NumBellow=1
 +
{
 +
Axis1 := -5
 +
} else {
 +
If NumBellow=0
 +
{
 +
Axis1 := -5
 +
Axis2 := -5
 +
}
 +
}
 +
}
 +
}
 +
 +
 
 +
 
 +
;~ First Single Slider
 +
If (Knob%B1S%>oldKnob%B1S%) ;knob Rose
 
{
 
{
checksum := curCheck
+
NoKnobsMoved := False
 +
oldKnob%B1S% := Knob%B1S%
 +
If (Knob%B1S%>Axis1) ;knob Over Line
 +
{
 +
MouseClick,Left,ButtonX%B1%,ButtonY
 +
}
 
} else {
 
} else {
Break
+
If (Knob%B1S%<oldKnob%B1S%) ;knob Fell
 +
{
 +
NoKnobsMoved := False
 +
oldKnob%B1S% := Knob%B1S%
 +
If (Knob%B1S%<Axis1) ;knob Bellow Line
 +
{
 +
MouseClick,Left,ButtonX%B1%,ButtonY
 +
}
 +
}
 
}
 
}
sleep, 100
+
 
 +
;~ Second Single Slider
 +
If (Knob%B2S%>oldKnob%B2S%) ;knob Rose
 +
{
 +
NoKnobsMoved := False
 +
oldKnob%B2S% := Knob%B2S%
 +
If (Knob%B2S%>Axis2) ;knob Over Line
 +
{
 +
MouseClick,Left,ButtonX%B2%,ButtonY
 +
}
 +
} else {
 +
If (Knob%B2S%<oldKnob%B2S%) ;knob Fell
 +
{
 +
NoKnobsMoved := False
 +
oldKnob%B2S% := Knob%B2S%
 +
If (Knob%B2S%<Axis2) ;knob Bellow Line
 +
{
 +
MouseClick,Left,ButtonX%B2%,ButtonY
 +
}
 +
}
 +
}
 +
 
 +
;~ Third Single Slider
 +
If (Knob%B3S%>oldKnob%B3S%) ;knob Rose
 +
{
 +
NoKnobsMoved := False
 +
oldKnob%B3S% := Knob%B3S%
 +
If Knob%B3S%>0 ;knob Over Line
 +
{
 +
MouseClick,Left,ButtonX%B3%,ButtonY
 +
}
 +
} else {
 +
If (Knob%B3S%<oldKnob%B3S%) ;knob Fell
 +
{
 +
NoKnobsMoved := False
 +
oldKnob%B3S% := Knob%B3S%
 +
If Knob%B3S%<0 ;knob Bellow Line
 +
{
 +
MouseClick,Left,ButtonX%B3%,ButtonY
 +
}
 +
}
 +
}
 +
 
 +
 
 +
 +
}
 +
 
 +
Setup:
 +
IfWinExist eGenesis Client
 +
{
 +
WinGet, GameWinHandle, ID, eGenesis Client
 +
} else {
 +
Msgbox, eGenesis client not running, exiting...
 +
Exit
 +
}
 +
 
 +
;~ Base
 +
OriX := 625
 +
OriY := 342
 +
 
 +
;~ Offsets
 +
offRedLineStartX := OriX-625
 +
offRedLineStartY := OriY-333
 +
offSliderT := OriY-364
 +
offSliderM := OriY-424
 +
offSliderB := OriY-483
 +
offSliderX1 := OriX-618
 +
offSliderX2 := OriX-654
 +
offSliderX3 := OriX-690
 +
offSliderX4 := OriX-726
 +
offSliderX5 := OriX-762
 +
offSliderX6 := OriX-798
 +
offSliderX7 := OriX-834
 +
offButtonY := OriY-503
 +
offButtonX1 := OriX-647
 +
offButtonX2 := OriX-688
 +
offButtonX3 := OriX-729
 +
offButtonX4 := OriX-769
 +
offButtonX5 := OriX-809
 +
 
 +
 
 +
;~ Locate Word Lime
 +
WinActivate eGenesis Client
 +
ImageSearch, LimeX,LimeY,0,0,Xmax,Ymax,*40 Lime.png
 +
If ErrorLevel=2
 +
{
 +
MsgBox,,,Couldn't Find Lime.png
 +
}
 +
If ErrorLevel<1
 +
{
 +
GuiControl, Text, Label, Found Crematory Window
 +
} else {
 +
If ErrorLevel<2
 +
{
 +
;Didn't find the Word Lime
 +
MsgBox,,Crematory Macro,Crematory Window not Found, closing macro
 +
ExitApp
 
}
 
}
sleep, 100
 
 
}
 
}
  
getPicChecksum(x,y)
+
RedLineStartX := LimeX-offRedLineStartX
{
+
RedLineStartY := LimeY-offRedLineStartY
Check := 0
+
SliderX1 := LimeX-offSliderX1
Loop, 5
+
SliderX2 := LimeX-offSliderX2
 +
SliderX3 := LimeX-offSliderX3
 +
SliderX4 := LimeX-offSliderX4
 +
SliderX5 := LimeX-offSliderX5
 +
SliderX6 := LimeX-offSliderX6
 +
SliderX7 := LimeX-offSliderX7
 +
SliderT := LimeY-offSliderT
 +
SliderM := LimeY-offSliderM
 +
SliderB := LimeY-offSliderB
 +
ButtonY := LimeY-offButtonY
 +
ButtonX1 := LimeX-offButtonX1
 +
ButtonX2 := LimeX-offButtonX2
 +
ButtonX3 := LimeX-offButtonX3
 +
ButtonX4 := LimeX-offButtonX4
 +
ButtonX5 := LimeX-offButtonX5
 +
ProgressSX := LimeX-2
 +
ProgressSY := LimeY-12
 +
ProgressEX := LimeX+3
 +
ProgressEY := LimeY+5
 +
SliderSearchSX1 := SliderX1-2
 +
SliderSearchSX2 := SliderX2-2
 +
SliderSearchSX3 := SliderX3-2
 +
SliderSearchSX4 := SliderX4-2
 +
SliderSearchSX5 := SliderX5-2
 +
SliderSearchSX6 := SliderX6-2
 +
SliderSearchSX7 := SliderX7-2
 +
SliderSearchEX1 := SliderX1+7
 +
SliderSearchEX2 := SliderX2+7
 +
SliderSearchEX3 := SliderX3+7
 +
SliderSearchEX4 := SliderX4+7
 +
SliderSearchEX5 := SliderX5+7
 +
SliderSearchEX6 := SliderX6+7
 +
SliderSearchEX7 := SliderX7+7
 +
SliderSearchSY := SliderT-10
 +
SliderSearchEY := SliderB+10
 +
oldKnob1 := 100
 +
oldKnob2 := 100
 +
oldKnob3 := 100
 +
oldKnob4 := 100
 +
oldKnob5 := 100
 +
oldKnob6 := 100
 +
oldKnob7 := 100
 +
return
 +
 
 +
Unload: ;Unload
 +
;~ Knobs not moving - Finished
 +
;~ Refresh
 +
MouseClick,Left,LimeX,LimeY
 +
sleep, 100
 +
;~ Find Take
 +
ImageSearch,LoadX,LoadY,LimeX-29,LimeY-136,LimeX+49,LimeY-40,*40 Take.png
 +
If ErrorLevel<1
 
{
 
{
xinc := A_Index
+
MouseClick,Left,LoadX,LoadY
Loop, 5
+
sleep,300
 +
ImageSearch,EveX,EveY,LoadX,LoadY-50,LoadX+133,LoadY+50,*90 Everything.png
 +
If ErrorLevel<1
 
{
 
{
PixelGetColor, p1,% x+(4*xinc)-10,% y+(4*A_Index)-10
+
MouseClick,Left,EveX,EveY
Check := Check+p1
+
sleep, 300
}
+
}
 +
}
 +
return
 +
 
 +
 
 +
Load:
 +
;~ Knobs not moving - Finished
 +
;~ Refresh
 +
MouseClick,Left,LimeX,LimeY
 +
sleep, 100
 +
;~ Find Load
 +
ImageSearch,LoadX,LoadY,LimeX-29,LimeY-136,LimeX+49,LimeY-40,*40 Load.png
 +
If ErrorLevel<1
 +
{
 +
;load Limestone
 +
sleep,100
 +
MouseClick,Left,LoadX,LoadY
 +
sleep,100
 +
MouseClick,Left,LoadX+14,LoadY-33
 +
sleep,200
 +
MouseClick,Left,floor(Xmax/2),floor(Ymax/2)+44
 +
sleep,200
 +
;load Leeks
 +
sleep,100
 +
MouseClick,Left,LoadX,LoadY
 +
sleep,100
 +
MouseClick,Left,LoadX+14,LoadY-17
 +
sleep,200
 +
MouseClick,Left,floor(Xmax/2),floor(Ymax/2)+44
 +
sleep,200
 +
;load Flax
 +
sleep,100
 +
MouseClick,Left,LoadX,LoadY
 +
sleep,100
 +
MouseClick,Left,LoadX+14,LoadY
 +
sleep,200
 +
MouseClick,Left,floor(Xmax/2),floor(Ymax/2)+44
 +
sleep,200
 +
;load Papyrus
 +
sleep,100
 +
MouseClick,Left,LoadX,LoadY
 +
sleep,100
 +
MouseClick,Left,LoadX+14,LoadY+17
 +
sleep,200
 +
MouseClick,Left,floor(Xmax/2),floor(Ymax/2)+44
 +
sleep,200
 +
;load Wood
 +
sleep,100
 +
MouseClick,Left,LoadX,LoadY
 +
sleep,100
 +
MouseClick,Left,LoadX+14,LoadY+33
 +
sleep,200
 +
MouseClick,Left,floor(Xmax/2),floor(Ymax/2)+44
 +
sleep,200
 +
;Fire
 +
MouseClick,Left,LoadX,LoadY-17
 +
sleep, 100
 
}
 
}
return, %Check%
+
return
}
 
  
 
Close:
 
Close:
 
ExitApp
 
ExitApp
  
 +
^a:: ;automode
 +
if (autoMode=True)
 +
{
 +
autoMode := False
 +
GuiControl,,myText,CTRL+A - Auto Mode is OFF
 +
} else {
 +
autoMode := True
 +
GuiControl,,myText,CTRL+A - Auto Mode is ON
 +
}
 +
return
 +
 +
^p::pause
 
^r::reload
 
^r::reload
^p::Pause
 
 
 
</pre>
 
</pre>

Latest revision as of 02:47, 5 November 2010

;Ctrl+R to reload
;Ctrl+P to pause

;~ Info
WinActivate, eGenesis Client
WinGetActiveStats, win_Title, Xmax, Ymax, win_Xpos, win_Ypos
StartXGUI := Xmax+win_Xpos-255
StartYGUI := win_Ypos+35
Gui, +AlwaysOnTop +ToolWindow -Border +Background 
Gui, Add, Text,x10 y10,Crematory Macro Running
Gui, Add, Text,x10 y25,CTRL+R - Restart macro
Gui, Add, Text,x10 y40,CTRL+P - Pause macro
Gui, Add, Text,x10 y55 vMyText,CTRL+A - Turn ON Auto mode
Gui, Add, Text,x10 y75,Keep the crematory window away from popups.
Gui, Add, Button, x200 y5 gClose, Close 
Gui, Show, X%StartXGUI% Y%StartYGUI% w240 h100, New GUI Window

;~ Amigos
;~     * B1=S1+S7
;~     * B2=S5
;~     * B3=S2
;~     * B4=S4+S6
;~     * B5=S3 

	;;******* CONFIG *********
		;Singles
		B1 := 2  ;Button Number
		B1S := 5  ;Slider Number

		B2 := 3  ;Button Number
		B2S := 2  ;Slider Number

		B3 := 5  ;Button Number
		B3S := 3  ;Slider Number

		;Pairs
		B4 := 1   ;Button Number
		B4S1 := 1 ;First Slider Number
		B4S2 := 7 ;Second Slider Number
		B4D := 0  ;0 for parallel, 1 for opposite direction

		B5 := 4    ;Button Number
		B5S1 := 4  ;First Slider Number
		B5S2 := 6  ;Second Slider Number
		B5D := 1   ;0 for opposite, 1 for paralel direction

	;;******* END OF CONFIG *********

gosub, Setup

WinActivate, eGenesis Client
lastTimeSlidersMoved := A_Now 
autoMode := false
Loop
{
	If (autoMode=true)
	{
;~ 		check if completed
		ImageSearch, BarX,BarY,ProgressSX,ProgressSY,ProgressEX,ProgressEY,*40 BitRed.png
		if ErrorLevel=1
		{
			;~ 	Knobs not moving - Finished
			gosub, unload
			gosub, load
		} else {
			currentTime := A_Now
			tempLast := LastTimeSlidersMoved
			EnvSub, tempLast,,Seconds 
			If (tempLast<-300)
			{
				gosub, unload
				gosub, load
			}
		}
	} 
	;~ 	Check to make sure the window wasn't moved
		WindowMoved := false 
		ImageSearch, NewLimeX,NewLimeY,0,0,Xmax,Ymax,*40 Lime.png
		If ErrorLevel<1
		{
			If (NewLimeX<>LimeX)
			{
				WindowMoved := true
			} else {
				If (NewLimeY<>LimeY)
				{
					WindowMoved := True
				}	
			}
			If WindowMoved=True
			{
				gosub, Setup
			}
		} else {
			gosub, Setup
		}	
		
			
		ImageSearch, KnobX,KnobY1,SliderSearchSX1,SliderSearchSY,SliderSearchEX1,SliderSearchEY,*40 SliderKnob.png	
		ImageSearch, KnobX,KnobY2,SliderSearchSX2,SliderSearchSY,SliderSearchEX2,SliderSearchEY,*40 SliderKnob.png
		ImageSearch, KnobX,KnobY3,SliderSearchSX3,SliderSearchSY,SliderSearchEX3,SliderSearchEY,*40 SliderKnob.png
		ImageSearch, KnobX,KnobY4,SliderSearchSX4,SliderSearchSY,SliderSearchEX4,SliderSearchEY,*40 SliderKnob.png
		ImageSearch, KnobX,KnobY5,SliderSearchSX5,SliderSearchSY,SliderSearchEX5,SliderSearchEY,*40 SliderKnob.png
		ImageSearch, KnobX,KnobY6,SliderSearchSX6,SliderSearchSY,SliderSearchEX6,SliderSearchEY,*40 SliderKnob.png
		ImageSearch, KnobX,KnobY7,SliderSearchSX7,SliderSearchSY,SliderSearchEX7,SliderSearchEY,*40 SliderKnob.png
		Knob1 := SliderM-KnobY1-1
		Knob2 := SliderM-KnobY2-1
		Knob3 := SliderM-KnobY3-1
		Knob4 := SliderM-KnobY4-1
		Knob5 := SliderM-KnobY5-1
		Knob6 := SliderM-KnobY6-1
		Knob7 := SliderM-KnobY7-1

		NoKnobsMoved := True

If B4D=0
{
	If (Knob%B4S1%<>oldKnob%B4S1%) ;knob moved
	{
		NoKnobsMoved := False 
		If (Knob%B4S1%>oldKnob%B4S1%) ;knob rose
		{
			If (Knob%B4S1%>Knob%B4S2%) ;Knob%B4S1% is above Knob%B4S2%, knobs are spreading out
			{
				MouseClick,Left,ButtonX%B4%,ButtonY
			}
		} else {
			If (Knob%B4S1%<Knob%B4S2%) ;Knob%B4S1% is bellow Knob%B4S2%, knobs are spreading out
			{
				MouseClick,Left,ButtonX%B4%,ButtonY
			}
		}
		oldKnob%B4S1% := Knob%B4S1%
		oldKnob%B4S2% := Knob%B4S2%
	}
} else {
	If (Knob%B4S1%<>oldKnob%B4S1%) ;knob moved
	{
		NoKnobsMoved := False 
		averagePos := floor((Knob%B4S1%+Knob%B4S2%)/2)
		If (Knob%B4S1%>oldKnob%B4S1%) ;knobs are going up
		{
			If averagePos>0 ;averageposition is above center
			{
				MouseClick,Left,ButtonX%B4%,ButtonY
			}
		} else { ;knobs are going down
			If averagePos<0 ;averageposition is bellow center
			{
				MouseClick,Left,ButtonX%B4%,ButtonY
			}
		}
		oldKnob%B4S1% := Knob%B4S1%
		oldKnob%B4S2% := Knob%B4S2%
	}
}

If B5D=0
{
	If (Knob%B5S1%<>oldKnob%B5S1%) ;knob moved
	{
		NoKnobsMoved := False 
		If (Knob%B5S1%>oldKnob%B5S1%) ;knob rose
		{
			If (Knob%B5S1%>Knob%B5S2%) ;Knob%B5S1% is above Knob%B5S2%, knobs are spreading out
			{
				MouseClick,Left,ButtonX%B5%,ButtonY
			}
		} else {
			If (Knob%B5S1%<Knob%B5S2%) ;Knob%B5S1% is bellow Knob%B5S2%, knobs are spreading out
			{
				MouseClick,Left,ButtonX%B5%,ButtonY
			}
		}
		oldKnob%B5S1% := Knob%B5S1%
		oldKnob%B5S2% := Knob%B5S2%
	}
} else {
	If (Knob%B5S1%<>oldKnob%B5S1%) ;knob moved
	{
		NoKnobsMoved := False 
		averagePos := floor((Knob%B5S1%+Knob%B5S2%)/2)
		If (Knob%B5S1%>oldKnob%B5S1%) ;knobs are going up
		{
			If averagePos>0 ;averageposition is above center
			{
				MouseClick,Left,ButtonX%B5%,ButtonY
			}
		} else { ;knobs are going down
			If averagePos<0 ;averageposition is bellow center
			{
				MouseClick,Left,ButtonX%B5%,ButtonY
			}
		}
		oldKnob%B5S1% := Knob%B5S1%
		oldKnob%B5S2% := Knob%B5S2%
	}
}


		NumAbove := 0
		NumBellow := 0
		If (Knob%B4S1%<0)
		{
			NumBellow++
		} Else {
			NumAbove++
		}
		If (Knob%B4S2%<0)
		{
			NumBellow++
		} Else {
			NumAbove++
		}
		If (Knob%B5S1%<0)
		{
			NumBellow++
		} Else {
			NumAbove++
		}
		If (Knob%B5S2%<0)
		{
			NumBellow++
		} Else {
			NumAbove++
		}

		Axis1 := 0
		Axis2 := 0
		If NumAbove=1
		{
			Axis1 := 5
		} else {
			If NumAbove=0
			{
				Axis1 := 5
				Axis2 := 5
			} else {
				If NumBellow=1
				{
					Axis1 := -5
				} else {
					If NumBellow=0
					{
						Axis1 := -5
						Axis2 := -5
					}
				}
			}
		}
		


	;~ 	First Single Slider
		If (Knob%B1S%>oldKnob%B1S%) ;knob Rose
		{
			NoKnobsMoved := False 
			oldKnob%B1S% := Knob%B1S%
			If (Knob%B1S%>Axis1) ;knob Over Line
			{
				MouseClick,Left,ButtonX%B1%,ButtonY
			}
		} else {
			If (Knob%B1S%<oldKnob%B1S%) ;knob Fell
			{
				NoKnobsMoved := False 
				oldKnob%B1S% := Knob%B1S%
				If (Knob%B1S%<Axis1) ;knob Bellow Line
				{
					MouseClick,Left,ButtonX%B1%,ButtonY
				}
			}
		}

	;~ 	Second Single Slider
		If (Knob%B2S%>oldKnob%B2S%) ;knob Rose
		{
			NoKnobsMoved := False 
			oldKnob%B2S% := Knob%B2S%
			If (Knob%B2S%>Axis2) ;knob Over Line
			{
				MouseClick,Left,ButtonX%B2%,ButtonY
			}
		} else {
			If (Knob%B2S%<oldKnob%B2S%) ;knob Fell
			{
				NoKnobsMoved := False 
				oldKnob%B2S% := Knob%B2S%
				If (Knob%B2S%<Axis2) ;knob Bellow Line
				{
					MouseClick,Left,ButtonX%B2%,ButtonY
				}
			}
		}

	;~ 	Third Single Slider
		If (Knob%B3S%>oldKnob%B3S%) ;knob Rose
		{
			NoKnobsMoved := False 
			oldKnob%B3S% := Knob%B3S%
			If Knob%B3S%>0 ;knob Over Line
			{
				MouseClick,Left,ButtonX%B3%,ButtonY
			}
		} else {
			If (Knob%B3S%<oldKnob%B3S%) ;knob Fell
			{
				NoKnobsMoved := False 
				oldKnob%B3S% := Knob%B3S%
				If Knob%B3S%<0 ;knob Bellow Line
				{
					MouseClick,Left,ButtonX%B3%,ButtonY
				}
			}
		}


	
}

Setup:
IfWinExist eGenesis Client
{
	WinGet, GameWinHandle, ID, eGenesis Client
} else {
	Msgbox, eGenesis client not running, exiting...
Exit
}

;~ Base
OriX := 625
OriY := 342

;~ Offsets
offRedLineStartX := OriX-625
offRedLineStartY := OriY-333
offSliderT := OriY-364
offSliderM := OriY-424
offSliderB := OriY-483
offSliderX1 := OriX-618
offSliderX2 := OriX-654
offSliderX3 := OriX-690
offSliderX4 := OriX-726
offSliderX5 := OriX-762
offSliderX6 := OriX-798
offSliderX7 := OriX-834
offButtonY := OriY-503
offButtonX1 := OriX-647
offButtonX2 := OriX-688
offButtonX3 := OriX-729
offButtonX4 := OriX-769
offButtonX5 := OriX-809


;~ Locate Word Lime
WinActivate eGenesis Client
ImageSearch, LimeX,LimeY,0,0,Xmax,Ymax,*40 Lime.png
If ErrorLevel=2
{
	MsgBox,,,Couldn't Find Lime.png
}
If ErrorLevel<1
{
	GuiControl, Text, Label, Found Crematory Window
} else {
	If ErrorLevel<2
	{
		;Didn't find the Word Lime
		MsgBox,,Crematory Macro,Crematory Window not Found, closing macro
		ExitApp
	}
}

RedLineStartX := LimeX-offRedLineStartX
RedLineStartY := LimeY-offRedLineStartY
SliderX1 := LimeX-offSliderX1
SliderX2 := LimeX-offSliderX2
SliderX3 := LimeX-offSliderX3
SliderX4 := LimeX-offSliderX4
SliderX5 := LimeX-offSliderX5
SliderX6 := LimeX-offSliderX6
SliderX7 := LimeX-offSliderX7
SliderT := LimeY-offSliderT
SliderM := LimeY-offSliderM
SliderB := LimeY-offSliderB
ButtonY := LimeY-offButtonY
ButtonX1 := LimeX-offButtonX1
ButtonX2 := LimeX-offButtonX2
ButtonX3 := LimeX-offButtonX3
ButtonX4 := LimeX-offButtonX4
ButtonX5 := LimeX-offButtonX5
ProgressSX := LimeX-2
ProgressSY := LimeY-12
ProgressEX := LimeX+3
ProgressEY := LimeY+5
SliderSearchSX1 := SliderX1-2
SliderSearchSX2 := SliderX2-2
SliderSearchSX3 := SliderX3-2
SliderSearchSX4 := SliderX4-2
SliderSearchSX5 := SliderX5-2
SliderSearchSX6 := SliderX6-2
SliderSearchSX7 := SliderX7-2
SliderSearchEX1 := SliderX1+7
SliderSearchEX2 := SliderX2+7
SliderSearchEX3 := SliderX3+7
SliderSearchEX4 := SliderX4+7
SliderSearchEX5 := SliderX5+7
SliderSearchEX6 := SliderX6+7
SliderSearchEX7 := SliderX7+7
SliderSearchSY := SliderT-10
SliderSearchEY := SliderB+10
oldKnob1 := 100
oldKnob2 := 100
oldKnob3 := 100
oldKnob4 := 100
oldKnob5 := 100
oldKnob6 := 100
oldKnob7 := 100
return

Unload: ;Unload
;~ 	Knobs not moving - Finished
;~ 	Refresh
	MouseClick,Left,LimeX,LimeY
	sleep, 100
;~ 	Find Take
	ImageSearch,LoadX,LoadY,LimeX-29,LimeY-136,LimeX+49,LimeY-40,*40 Take.png
	If ErrorLevel<1
	{
		MouseClick,Left,LoadX,LoadY
		sleep,300
		ImageSearch,EveX,EveY,LoadX,LoadY-50,LoadX+133,LoadY+50,*90 Everything.png
		If ErrorLevel<1
		{
			MouseClick,Left,EveX,EveY
			sleep, 300
		} 
	}
	return


Load:
;~ 	Knobs not moving - Finished
;~ 	Refresh
	MouseClick,Left,LimeX,LimeY
	sleep, 100
;~ 	Find Load
	ImageSearch,LoadX,LoadY,LimeX-29,LimeY-136,LimeX+49,LimeY-40,*40 Load.png
	If ErrorLevel<1
	{
		;load Limestone
		sleep,100
		MouseClick,Left,LoadX,LoadY
		sleep,100
		MouseClick,Left,LoadX+14,LoadY-33
		sleep,200
		MouseClick,Left,floor(Xmax/2),floor(Ymax/2)+44
		sleep,200
		;load Leeks
		sleep,100
		MouseClick,Left,LoadX,LoadY
		sleep,100
		MouseClick,Left,LoadX+14,LoadY-17
		sleep,200
		MouseClick,Left,floor(Xmax/2),floor(Ymax/2)+44
		sleep,200
		;load Flax
		sleep,100
		MouseClick,Left,LoadX,LoadY
		sleep,100
		MouseClick,Left,LoadX+14,LoadY
		sleep,200
		MouseClick,Left,floor(Xmax/2),floor(Ymax/2)+44
		sleep,200
		;load Papyrus
		sleep,100
		MouseClick,Left,LoadX,LoadY
		sleep,100
		MouseClick,Left,LoadX+14,LoadY+17
		sleep,200
		MouseClick,Left,floor(Xmax/2),floor(Ymax/2)+44
		sleep,200
		;load Wood
		sleep,100
		MouseClick,Left,LoadX,LoadY
		sleep,100
		MouseClick,Left,LoadX+14,LoadY+33
		sleep,200
		MouseClick,Left,floor(Xmax/2),floor(Ymax/2)+44
		sleep,200
		;Fire
		MouseClick,Left,LoadX,LoadY-17
		sleep, 100
	}
	return

Close:
ExitApp

^a:: ;automode
if (autoMode=True)
{
	autoMode := False
	GuiControl,,myText,CTRL+A - Auto Mode is OFF
} else {
	autoMode := True
	GuiControl,,myText,CTRL+A - Auto Mode is ON
}
return

^p::pause
^r::reload