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 "Code"

From ATITD5
Jump to navigationJump to search
(Replaced content with "<pre> Loop 5 { FirstStone := A_Index NumToRun1 := 6-A_Index ;Select Stone A_Index (code) (shortcut A) Loop, %NumToRun% { SecondStone := FirstStone+A_Index NuumToRun2...")
Line 18: Line 18:
 
}
 
}
 
}
 
}
 +
</pre>
 +
 +
<pre>
 +
;Ctrl+R to reload
 +
;Ctrl+P to pause
 +
 +
IfWinExist eGenesis Client
 +
{
 +
WinGet, GameWinHandle, ID, eGenesis Client
 +
} else {
 +
Msgbox, eGenesis client not running, exiting...
 +
Exit
 +
}
 +
;~ 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,,Make sure you have: `n"Right-Click Pins/Unpins a Menu" and `n"Right-Click opens a Menu as Pinned"´`nchecked under options\interface.
 +
Gui, Add, Button, x10 y70 gStart, Next »
 +
Gui, Add, Button, x200 y5 gClose, Close
 +
Gui, Show, X%StartXGUI% Y%StartYGUI% w240 h100, New GUI Window
 +
Return
 +
 +
Start:
 +
Gui, Destroy
 +
;~ Ask for config
 +
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,,Type in how many rows and columns `nof kettles you will be working with:
 +
Gui, Add, Text, x10 y40, Rows:
 +
Gui, Add, Edit,xp+35 yp-4 vnumRows, 1
 +
Gui, Add, Text,xp+20 y40, Columns:
 +
Gui, Add, Edit,xp+45 yp-4 vnumColumns, 4
 +
Gui, Add, Button, x10 y70 gNext, Next »
 +
Gui, Add, Button, x200 y5 gClose, Close
 +
Gui, Show, X%StartXGUI% Y%StartYGUI% w240 h100, New GUI Window
 +
Return
 +
 +
Next:
 +
Gui, submit
 +
Gui, Destroy
 +
;Get Top Left
 +
Gui, +AlwaysOnTop +ToolWindow -Border +Background
 +
Gui, Add, Text,,Using F8F8 camera view make `nsure you can see all kettles.
 +
Gui, Add, Text,,Position your mouse over `nthe topleft kettle and press the F2 key.
 +
Gui, Add, Button, x200 y5 gClose, Close
 +
Gui, Show, X%StartXGUI% Y%StartYGUI% w240 h100, New GUI Window
 +
loop
 +
{
 +
WinActivate eGenesis Client
 +
KeyWait, F2, D
 +
KeyWait, F2
 +
MouseGetPos, FirstX, FirstY, WinHandle
 +
if (WinHandle = GameWinHandle)
 +
{
 +
Gosub, GotTopLeft
 +
}
 +
}
 +
return
 +
 +
GotTopLeft:
 +
Gui, Destroy
 +
;Get Bottom Right
 +
Gui, +AlwaysOnTop +ToolWindow -Border +Background
 +
Gui, Add, Text,,Position your mouse over `nthe bottom right kettle `nand press the F2 key.
 +
Gui, Add, Button, x200 y5 gClose, Close
 +
Gui, Show, X%StartXGUI% Y%StartYGUI% w240 h100, New GUI Window
 +
 +
loop
 +
{
 +
WinActivate eGenesis Client
 +
KeyWait, F2, D
 +
KeyWait, F2
 +
MouseGetPos, LastX, LastY, WinHandle
 +
if (WinHandle = GameWinHandle)
 +
{
 +
Gosub, GotBottomRight
 +
}
 +
}
 +
return
 +
 +
GotBottomRight:
 +
Gui, Destroy
 +
;~ Open Windows
 +
;~ Hands off
 +
Gui, +AlwaysOnTop +ToolWindow -Border +Background
 +
Gui, Add, Text,vTimeLeft,Leave your mouse alone, `nopening windows 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, `nopening windows in %SmallPause% seconds.
 +
SmallPause --
 +
Sleep 1000
 +
}
 +
GuiControl, Text, TimeLeft, Opening Windows Now.
 +
WinActivate eGenesis Client
 +
 +
;~ loop through windows to open and arrange
 +
topNotFound := true
 +
Loop, %numColumns%
 +
{
 +
curColumn := A_Index
 +
openPosX := FirstX+(A_Index-1)*floor((LastX-FirstX)/(numColumns-1))
 +
Loop, %numRows%
 +
{
 +
openPosY := FirstY+(A_Index-1)*floor((LastY-FirstY)/(numRows-1))
 +
MouseClick,Right,openPosX,openPosY
 +
sleep, 200
 +
startSeaX := openPosX+5
 +
finishSeaY := openPosY-200
 +
;~ If the window size is not known find it
 +
If topNotFound
 +
{
 +
GuiControl, Text, TimeLeft, Verifying Window Height. (0 / 200)
 +
Loop, 20
 +
{
 +
curStartB := openPosY-(10*A_Index)
 +
proBar := 10*A_Index
 +
GuiControl, Text, TimeLeft, Verifying Window Height. (%proBar% / 200)
 +
curStartT := openPosY-(10*A_Index)-10
 +
PixelSearch,OutX,OutY,%startSeaX%,%curStartT%,%startSeaX%,%curStartB%,0x000000,Fast
 +
if ErrorLevel < 1
 +
{
 +
break
 +
}
 +
}
 +
GuiControl, Text, TimeLeft, Final Height Check.
 +
PixelSearch,OutX,OutY,%startSeaX%,%curStartB%,%startSeaX%,%curStartT%,0x000000
 +
curStartB := openPosY-OutY+3
 +
curStartT := openPosY-OutY-3
 +
topNotFound := false
 +
}
 +
;~ Search for black line on top of window
 +
GuiControl, Text, TimeLeft, Arranging Row:%A_Index% Column:%curColumn%
 +
startSeaYB := openPosY-curStartB
 +
startSeaYT := openPosY-curStartT
 +
PixelSearch,OutX,OutY,%startSeaX%,%startSeaYT%,%startSeaX%,%startSeaYB%,0x000000,50
 +
arrX := 18+20*(numRows)*(curColumn-1)+20*(A_Index-1)
 +
;~ Drag the window to position
 +
MouseClick,Left,%OutX%,%OutY%,,,D
 +
sleep 100
 +
MouseMove,%arrX%,50
 +
sleep 300
 +
MouseClick,Left,,,,,U
 +
sleep, 100
 +
}
 +
}
 +
 +
;~ focus
 +
gosub, Focus
 +
GuiControl, Text, TimeLeft, Checking Window Width.
 +
;~ Check windWidth
 +
PixelSearch,winWX,winWY,18,52,500,52,0x000000,50
 +
baseXofWidth := winWX-18
 +
 +
;~ Run the kettles
 +
GuiControl, Text, TimeLeft, Running The Kettles
 +
totalWindows := numColumns*numRows
 +
Winactivate
 +
allFinished := false
 +
 +
;~ Clear Vector
 +
GuiControl, Text, TimeLeft, Clearing Records.
 +
Loop, %totalWindows%
 +
{
 +
ketDone%A_Index% := False
 +
}
 +
NotReady := True
 +
 +
Loop
 +
{
 +
loop, %totalWindows%
 +
{
 +
GuiControl, Text, TimeLeft, Checking Kettle: %A_Index% of %totalWindows%
 +
focusPos := floor(18+20*(A_Index-1))
 +
focusPosEnd := floor(18+20*(A_Index-1)+baseXofWidth)
 +
;~ Focus Next
 +
;~ Start Kettle
 +
ImageSearch, OutX,OutY,focusPos,52,focusPosEnd,316,Potash.png
 +
If ErrorLevel<1
 +
{
 +
MouseClick, Left, OutX,OutY
 +
Sleep, 200
 +
}
 +
;~ Find and click Begin
 +
ImageSearch, OutX,OutY,focusPos,52,focusPosEnd,316,Begin.png
 +
If ErrorLevel<1
 +
{
 +
MouseClick, Left, OutX,OutY
 +
Sleep, 200
 +
}
 +
;~ Find and Click Ignite
 +
ImageSearch, OutX,OutY,focusPos,52,focusPosEnd,316,Ignite.png
 +
If ErrorLevel<1
 +
{
 +
MouseClick, Left, OutX,OutY
 +
Sleep, 300
 +
}
 +
;~ Find and Click Max
 +
centerOfWindowX := floor(Xmax/2)
 +
centerOfWindowY := floor(Ymax/2)
 +
baseMaxXB := centerOfWindowX-100
 +
baseMaxXE := centerOfWindowX+100
 +
baseMaxYB := centerOfWindowY
 +
baseMaxYE := centerOfWindowY+100
 +
ImageSearch, OutX,OutY,0,0,Xmax,Ymax,How.png
 +
baseYofMax := OutY+74
 +
baseXofMax := OutX+81
 +
If ErrorLevel<1
 +
{
 +
Mousemove,baseXofMax,baseYofMax
 +
MouseClick, Left,baseXofMax,baseYofMax
 +
sleep, 200
 +
}
 +
;~ Check if completed
 +
ImageSearch, OutX,OutY,focusPos,52,focusPosEnd,316,Take.png
 +
if ErrorLevel<1
 +
{
 +
ketDone%A_Index% := True
 +
}
 +
;~ Skip if completed
 +
CurrentState := ketDone%A_Index%
 +
If CurrentState=False
 +
{
 +
ImageSearch, OutX,OutY,focusPos,52,focusPosEnd,180,StokeMax.png
 +
stokeX := OutX
 +
stokeY := OutY
 +
ImageSearch, OutX,OutY,focusPos,52,focusPosEnd,280,Water6Wood5.png
 +
If ErrorLevel<1
 +
{
 +
ketDone%A_Index% := True
 +
} else {
 +
ImageSearch, OutX,OutY,focusPos,52,focusPosEnd,280,Wood0.png
 +
if ErrorLevel<1
 +
 +
MouseClick, Left, stokeX,stokeY
 +
sleep, 100
 +
} else {
 +
ImageSearch, OutX,OutY,focusPos,52,focusPosEnd,280,Water6.png
 +
if ErrorLevel<1
 +
{
 +
MouseClick, Left, stokeX,stokeY
 +
sleep, 100
 +
}
 +
}
 +
}
 +
}
 +
;~ Focus Next
 +
nextFocus := focusPosEnd+20
 +
if (A_Index<totalWindows)
 +
{
 +
MouseClick, Left,nextFocus,52
 +
sleep, 100
 +
}
 +
}
 +
gosub, Focus
 +
NotReady := False
 +
Loop, %totalWindows%
 +
{
 +
CurrentState := ketDone%A_Index%
 +
If CurrentState=False
 +
{
 +
GuiControl, Text, TimeLeft, LOOP %A_Index% - NotReady:%NotReady% - `nBAD!!
 +
Sleep 5000
 +
NotReady := True
 +
}
 +
 +
}
 +
If (NotReady=False)
 +
{
 +
Break
 +
}
 +
}
 +
 +
;~ Take
 +
Loop, %totalWindows%
 +
{
 +
GuiControl, Text, TimeLeft, Taking from Kettle: %A_Index% of %totalWindows%
 +
focusPos := floor(18+20*(A_Index-1))
 +
focusPosEnd := floor(18+20*(A_Index-1)+baseXofWidth)
 +
ImageSearch, OutX,OutY,focusPos,52,focusPosEnd,316,Take.png
 +
if ErrorLevel<1
 +
{
 +
MouseClick, Left,OutX,OutY
 +
sleep, 100
 +
}
 +
nextFocus := focusPosEnd+20
 +
if (A_Index<totalWindows)
 +
{
 +
MouseClick, Left,nextFocus,52
 +
sleep, 100
 +
}
 +
}
 +
gosub, Focus
 +
ExitApp
 +
 +
 +
Focus:
 +
GuiControl, Text, TimeLeft, Reversing Order.
 +
totalWindows := numColumns*numRows
 +
loop, %totalWindows%
 +
{
 +
focusPos := 18+20*(totalWindows-A_Index)
 +
MouseClick, Left,focusPos,50
 +
sleep 100
 +
}
 +
return
 +
 +
Close:
 +
ExitApp
 +
 +
^r::reload
 +
^p::Pause
 
</pre>
 
</pre>

Revision as of 05:08, 24 October 2010

Loop 5
{
	FirstStone := A_Index
	NumToRun1 := 6-A_Index
	;Select Stone A_Index (code) (shortcut A)
	Loop, %NumToRun%
	{
		SecondStone := FirstStone+A_Index
		NuumToRun2 := 5-A_Index 
		;Select Stone B_Index (code) (shortcut A)
		Loop, %NumToRun2%
		[
			ThirdStone := SecondStone+A_Index
			;Select Stone B_Index (code) (shortcut S)
			;Check if popup opened and close it
		}
	}
}
;Ctrl+R to reload
;Ctrl+P to pause

IfWinExist eGenesis Client
{
	WinGet, GameWinHandle, ID, eGenesis Client
} else {
	Msgbox, eGenesis client not running, exiting...
Exit
}
;~ 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,,Make sure you have: `n"Right-Click Pins/Unpins a Menu" and `n"Right-Click opens a Menu as Pinned"´`nchecked under options\interface.
Gui, Add, Button, x10 y70 gStart, Next »
Gui, Add, Button, x200 y5 gClose, Close 
Gui, Show, X%StartXGUI% Y%StartYGUI% w240 h100, New GUI Window
Return

Start:
Gui, Destroy
;~ Ask for config
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,,Type in how many rows and columns `nof kettles you will be working with:
Gui, Add, Text, x10 y40, Rows:
Gui, Add, Edit,xp+35 yp-4 vnumRows, 1
Gui, Add, Text,xp+20 y40, Columns:
Gui, Add, Edit,xp+45 yp-4 vnumColumns, 4
Gui, Add, Button, x10 y70 gNext, Next »
Gui, Add, Button, x200 y5 gClose, Close 
Gui, Show, X%StartXGUI% Y%StartYGUI% w240 h100, New GUI Window
Return

Next:
Gui, submit
Gui, Destroy
;Get Top Left
Gui, +AlwaysOnTop +ToolWindow -Border +Background 
Gui, Add, Text,,Using F8F8 camera view make `nsure you can see all kettles.
Gui, Add, Text,,Position your mouse over `nthe topleft kettle and press the F2 key.
Gui, Add, Button, x200 y5 gClose, Close 
Gui, Show, X%StartXGUI% Y%StartYGUI% w240 h100, New GUI Window
loop
{
	WinActivate eGenesis Client
	KeyWait, F2, D
	KeyWait, F2
	MouseGetPos, FirstX, FirstY, WinHandle
	if (WinHandle = GameWinHandle)
	{
		Gosub, GotTopLeft
	}
}
return

GotTopLeft:
Gui, Destroy
;Get Bottom Right
Gui, +AlwaysOnTop +ToolWindow -Border +Background 
Gui, Add, Text,,Position your mouse over `nthe bottom right kettle `nand press the F2 key.
Gui, Add, Button, x200 y5 gClose, Close 
Gui, Show, X%StartXGUI% Y%StartYGUI% w240 h100, New GUI Window

loop
{
	WinActivate eGenesis Client
	KeyWait, F2, D
	KeyWait, F2
	MouseGetPos, LastX, LastY, WinHandle
	if (WinHandle = GameWinHandle)
	{
		Gosub, GotBottomRight
	}
}
return

GotBottomRight:
Gui, Destroy
;~ Open Windows
;~ Hands off
Gui, +AlwaysOnTop +ToolWindow -Border +Background
Gui, Add, Text,vTimeLeft,Leave your mouse alone, `nopening windows 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, `nopening windows in %SmallPause% seconds.
	SmallPause --
	Sleep 1000
	}
GuiControl, Text, TimeLeft, Opening Windows Now.
WinActivate eGenesis Client

;~ loop through windows to open and arrange
topNotFound := true
Loop, %numColumns%
{
	curColumn := A_Index 
	openPosX := FirstX+(A_Index-1)*floor((LastX-FirstX)/(numColumns-1))
	Loop, %numRows% 
	{
		openPosY := FirstY+(A_Index-1)*floor((LastY-FirstY)/(numRows-1))
		MouseClick,Right,openPosX,openPosY
		sleep, 200
		startSeaX := openPosX+5
		finishSeaY := openPosY-200
;~ 		If the window size is not known find it
		If topNotFound 
		{
			GuiControl, Text, TimeLeft, Verifying Window Height. (0 / 200)
			Loop, 20 
			{
				curStartB := openPosY-(10*A_Index)
				proBar := 10*A_Index
				GuiControl, Text, TimeLeft, Verifying Window Height. (%proBar% / 200)
				curStartT := openPosY-(10*A_Index)-10
				PixelSearch,OutX,OutY,%startSeaX%,%curStartT%,%startSeaX%,%curStartB%,0x000000,Fast 
				if ErrorLevel < 1
				{
					break	
				}
			}
			GuiControl, Text, TimeLeft, Final Height Check.
			PixelSearch,OutX,OutY,%startSeaX%,%curStartB%,%startSeaX%,%curStartT%,0x000000
			curStartB := openPosY-OutY+3
			curStartT := openPosY-OutY-3
			topNotFound := false 
		}
;~ 		Search for black line on top of window
		GuiControl, Text, TimeLeft, Arranging Row:%A_Index% Column:%curColumn%
		startSeaYB := openPosY-curStartB
		startSeaYT := openPosY-curStartT
		PixelSearch,OutX,OutY,%startSeaX%,%startSeaYT%,%startSeaX%,%startSeaYB%,0x000000,50
		arrX := 18+20*(numRows)*(curColumn-1)+20*(A_Index-1)
;~ 		Drag the window to position
		MouseClick,Left,%OutX%,%OutY%,,,D
		sleep 100
		MouseMove,%arrX%,50
		sleep 300
		MouseClick,Left,,,,,U
		sleep, 100
	}
}

;~ focus
gosub, Focus
GuiControl, Text, TimeLeft, Checking Window Width.
;~ Check windWidth
PixelSearch,winWX,winWY,18,52,500,52,0x000000,50
baseXofWidth := winWX-18

;~ Run the kettles
GuiControl, Text, TimeLeft, Running The Kettles
totalWindows := numColumns*numRows
Winactivate
allFinished := false 

;~ Clear Vector
GuiControl, Text, TimeLeft, Clearing Records.
Loop, %totalWindows%
{
	ketDone%A_Index% := False 
}
NotReady := True

Loop
{
	loop, %totalWindows%
	{
		GuiControl, Text, TimeLeft, Checking Kettle: %A_Index% of %totalWindows%
		focusPos := floor(18+20*(A_Index-1))
		focusPosEnd := floor(18+20*(A_Index-1)+baseXofWidth)
		;~ Focus Next
		;~ Start Kettle
		ImageSearch, OutX,OutY,focusPos,52,focusPosEnd,316,Potash.png
		If ErrorLevel<1
		{
			MouseClick, Left, OutX,OutY		
			Sleep, 200
		}
		;~ Find and click Begin
		ImageSearch, OutX,OutY,focusPos,52,focusPosEnd,316,Begin.png
		If ErrorLevel<1
		{
			MouseClick, Left, OutX,OutY		
			Sleep, 200
		}
	;~ Find and Click Ignite
		ImageSearch, OutX,OutY,focusPos,52,focusPosEnd,316,Ignite.png
		If ErrorLevel<1
		{
			MouseClick, Left, OutX,OutY		
			Sleep, 300
		}
	;~ Find and Click Max
		centerOfWindowX := floor(Xmax/2)
		centerOfWindowY := floor(Ymax/2)
		baseMaxXB := centerOfWindowX-100
		baseMaxXE := centerOfWindowX+100
		baseMaxYB := centerOfWindowY
		baseMaxYE := centerOfWindowY+100
		ImageSearch, OutX,OutY,0,0,Xmax,Ymax,How.png
		baseYofMax := OutY+74
		baseXofMax := OutX+81
		If ErrorLevel<1
		{
			Mousemove,baseXofMax,baseYofMax
			MouseClick, Left,baseXofMax,baseYofMax
			sleep, 200
		}
	;~ Check if completed
		ImageSearch, OutX,OutY,focusPos,52,focusPosEnd,316,Take.png
		if ErrorLevel<1
		{
			ketDone%A_Index% := True 
		}
		;~ 	Skip if completed
		CurrentState := ketDone%A_Index%
		If CurrentState=False 
		{
			ImageSearch, OutX,OutY,focusPos,52,focusPosEnd,180,StokeMax.png
			stokeX := OutX
			stokeY := OutY
			ImageSearch, OutX,OutY,focusPos,52,focusPosEnd,280,Water6Wood5.png		
			If ErrorLevel<1 
			{
				ketDone%A_Index% := True 
			} else {
				ImageSearch, OutX,OutY,focusPos,52,focusPosEnd,280,Wood0.png
				if ErrorLevel<1
				{  
					MouseClick, Left, stokeX,stokeY
					sleep, 100
				} else {
					ImageSearch, OutX,OutY,focusPos,52,focusPosEnd,280,Water6.png
					if ErrorLevel<1
					{
						MouseClick, Left, stokeX,stokeY
						sleep, 100
					}
				}
			}
		}
	;~ Focus Next
		nextFocus := focusPosEnd+20
		if (A_Index<totalWindows)
		{
			MouseClick, Left,nextFocus,52
			sleep, 100
		}
	}
	gosub, Focus
	NotReady := False 	
	Loop, %totalWindows%
	{
		CurrentState := ketDone%A_Index%
		If CurrentState=False
		{
		GuiControl, Text, TimeLeft, LOOP %A_Index% - NotReady:%NotReady% - `nBAD!!
		Sleep 5000
		NotReady := True 
		}

	}
	If (NotReady=False)
	{
		Break
	}
}

;~ Take
Loop, %totalWindows%
{
	GuiControl, Text, TimeLeft, Taking from Kettle: %A_Index% of %totalWindows%
	focusPos := floor(18+20*(A_Index-1))
	focusPosEnd := floor(18+20*(A_Index-1)+baseXofWidth)
	ImageSearch, OutX,OutY,focusPos,52,focusPosEnd,316,Take.png
	if ErrorLevel<1
	{
		MouseClick, Left,OutX,OutY
		sleep, 100
	}
	nextFocus := focusPosEnd+20
	if (A_Index<totalWindows)
	{
		MouseClick, Left,nextFocus,52
		sleep, 100
	}
}
gosub, Focus
ExitApp


Focus:
GuiControl, Text, TimeLeft, Reversing Order.
totalWindows := numColumns*numRows
loop, %totalWindows%
{
	focusPos := 18+20*(totalWindows-A_Index)
	MouseClick, Left,focusPos,50
	sleep 100
}
return

Close:
ExitApp

^r::reload
^p::Pause