The Wiki for Tale 4 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 "User:Cegaiel/Macros/SkillsTimer/Code"

From A Tale in the Desert
Jump to navigationJump to search
 
(20 intermediate revisions by the same user not shown)
Line 3: Line 3:
 
;Ctrl+P to pause script and Ctrl+P again to resume
 
;Ctrl+P to pause script and Ctrl+P again to resume
 
;The AHK icon in system tray will turn red while paused.
 
;The AHK icon in system tray will turn red while paused.
 +
;Hold F2 for 1 second, while script is running, to pause script and reset click counter to zero.
 
;Ctrl+R to reload script
 
;Ctrl+R to reload script
 +
;Date: June 20, 2010
 +
;Author: Cegaiel
 +
  
 
^r::reload
 
^r::reload
Line 9: Line 13:
 
^!w::
 
^!w::
  
SetDefaultMouseSpeed, 0
+
;X/Y mouse coordinates of a popup box's OK button (yellowish part of the OK button, not the black text)
 +
;530,479 is the position of OK button in 1024x768 resolution
 +
;You can find out your position, at your resolution, with a free tool called Magnify at:
 +
;http://www.atitd.org/wiki/tale4/User:Cegaiel/Macros#Tool:_Magnify_.28Windows_Executable.29
 +
;The purpose of this, is when popup boxes occurs (ie error message when you dont have enough materials to repair a mine)
 +
;The script will make a Windows Error sound and then pause script.
 +
;Once you figure out the problem, Ctrl+P, to resume/unpause where you left of at.
 +
 
 +
PopX = 530
 +
PopY = 479
 +
 
 +
counter = 0
 +
 
 +
Gui, +AlwaysOnTop +ToolWindow
 +
Gui, Add, Text,, # of Clicks to Stop?`n(Blank=Unlimited, don't stop):
 +
Gui, Add, Edit, vClicks wp number
 +
Gui, Add, Text,, Eating Grilled Food?`n(Automatically eat every 10 Teppy Min)
 +
Gui, Add, DropDownList, vEat Choose1, No|Yes
 +
Gui, Add, Button, gStart, Next
 +
Gui, Show
 +
return
 +
 
 +
 
  
 +
Start:
 +
Gui, Submit
 +
Gui, Destroy
  
 
Msgbox, Hover mouse over a black letter, in skills tab (ie Endurance for digging)`n`nThe letter/skill you want to hover is the one that turns red when you get tired`n`nWhen you are hovering a black letter it will tell you in the tooltip.`n`nPress F2, when it tells you in tooltip, to set position.`n`nClick OK to proceed...
 
Msgbox, Hover mouse over a black letter, in skills tab (ie Endurance for digging)`n`nThe letter/skill you want to hover is the one that turns red when you get tired`n`nWhen you are hovering a black letter it will tell you in the tooltip.`n`nPress F2, when it tells you in tooltip, to set position.`n`nClick OK to proceed...
  
 +
WinActivate, eGenesis Client
 +
SetDefaultMouseSpeed, 0
 +
SetMouseDelay, -1
  
 
loop
 
loop
Line 31: Line 63:
 
if state = D
 
if state = D
 
{
 
{
MsgBox Skills text location recorded!`n`nHover where you want to click and press F2.`n`nFor a dig (or other skills related tasks), pin up the Dig Hole menu and set the click to the word Dig.`n`nFor limestone/dirt set the click position on the icon.`n`nClick OK to proceed...
+
color = 0x000000
 +
MsgBox Skills text location recorded, now its time to record the click location.`n`nHover where you want to click and press F2.`n`nFor a dig (or other skills related tasks), pin up the Dig Hole menu and set the click to the word Dig.`n`nFor limestone/dirt set the click position on the icon.`n`nClick OK to proceed...
 
Tooltip
 
Tooltip
 +
WinActivate, eGenesis Client
 
break
 
break
 
}
 
}
Line 42: Line 76:
 
{
 
{
 
MouseGetPos, ClickX, ClickY
 
MouseGetPos, ClickX, ClickY
Msgbox, Click location recorded!`n`nNote you can hit Ctrl+P to pause script anytime and Ctrl+P again to resume`n`nClick OK to start...
+
Msgbox, Click location recorded!`n`nNote: you can hit Ctrl+P to PAUSE script anytime and Ctrl+P again to RESUME`n`nHold F2, while the script is running, to pause and reset click numbers.`nThen just Ctrl+P to unpause script and continue at 0 clicks.`n`nClick OK to continue...
 
}
 
}
  
  
 +
if (Eat == "Yes")
 +
{
 +
 +
Msgbox, One more step! You have selected that you will be eating grilled foods!`n`nPinup the Esc, Skills, Consume menu and set the click position of the "Eat Grilled food" menu by hovering and hitting F2.`n`nNote: When this macro begins, it will first eat (so don't manually eat first).`n`nThen every 10 Teppy Mins (11:00 real time), it will automatically click/eat the grilled food.`n`nClick OK, then hit F2 over the grilled food consume menu to set...
 +
 +
WinActivate, eGenesis Client
 +
 +
KeyWait, F2, D
 +
if ErrorLevel = 0
 +
{
 +
MouseGetPos, EatX, EatY
 +
Msgbox, Eat location recorded!`n`nClick OK to eat food and start the macro...
 +
 +
EatTimer = 1
 +
#Persistent
 +
SetTimer, Eat, 1000
 +
 +
}
 +
}
  
  
loop
+
Gui, +AlwaysOnTop +ToolWindow
 +
Gui, Add, Text, vClickText, Preparing to start... Standby!`n`n`n`n
 +
Gui, Show
 +
GuiControl, Text, ClickText, Preparing to start... Standby!`n`n`n`n
 +
 
 +
 
 +
 
 +
Delay = 5
 +
;You got 5 seconds to drag the status window out of the way
 +
Loop, %Delay%
 +
{
 +
GuiControl, Text, ClickText, %Delay%s to begin... Standby!
 +
Delay --
 +
Sleep 1000
 +
}
 +
 
 +
 
 +
 
 +
 
 +
;This just appends the "of #" or the "of Unlimited" text on GUI bar.
 +
if (Clicks > 0)
 
{
 
{
 +
Max := Clicks
 +
} else {
 +
Max := "Unlimited"
 +
}
 +
 +
 +
GuiControl, Text, ClickText, Focusing eGenesis client...
 +
 +
 +
 +
loop
 +
{
  
 
WinActivate, eGenesis Client
 
WinActivate, eGenesis Client
 +
 +
 +
 +
 +
;This searches for a popup box, which would suggest something likely went wrong
 +
 +
PixelSearch, Px, Py, %PopX%, %PopY%, %PopX%, %PopY%, 0xECDFBD, 15, Fast|RGB
 +
 +
if ErrorLevel = 0
 +
{
 +
SoundPlay *16,1
 +
SoundPlay *16,1
 +
SoundPlay *16,1
 +
SoundPlay *16,1
 +
SoundPlay *16,1
 +
Msgbox, Pop Up box detected! Pausing macro...`n`nNo problem, just find the problem, correct and hit Ctrl+P.`n`nYou will resume from where you left off at...
 +
PAUSE
 +
}
 +
 +
;End searching for popupbox
 +
 +
 +
 +
 +
 +
 +
GetKeyState, state, F2
 +
if state = D
 +
{
 +
Msgbox, Reseting click number to 0`n`nCurrent click number: %counter%`n`nClick OK to continue...
 +
counter = 0
 +
}
 +
 +
 
PixelGetColor, color, skillX, skillY, RGB
 
PixelGetColor, color, skillX, skillY, RGB
 +
  
 
if color = 0x000000
 
if color = 0x000000
 
{
 
{
 +
counter++
 
MouseGetPos, OldX, OldY
 
MouseGetPos, OldX, OldY
 
Click %ClickX%, %ClickY%  
 
Click %ClickX%, %ClickY%  
 
MouseMove, %OldX%, %OldY%
 
MouseMove, %OldX%, %OldY%
 +
 +
 +
if (Eat == "Yes")
 +
{
 +
GuiControl, Text, ClickText, Clicks: %counter% of %Max%`n`nEat Grilled: %EatTimer%s of 660s
 +
} else {
 +
GuiControl, Text, ClickText, Clicks: %counter% of %Max%`n`nCtrl+R: Reload, +P: Pause`n`nHold F2: Reset click # to 0
 +
Sleep 250 ;This sleep helps prevent double clicks. Grilled food automatically has a 1 second delay from the seconds countdown
 +
}
 +
 +
 +
 +
if (counter = Clicks)
 +
{
 +
GuiControl, Text, ClickText, Clicks: %counter% of %Max% - Done!`n`nCtrl+R to Reload/Reset
 +
SoundPlay *16,1
 +
PAUSE
 +
;The purpose of the pause is because the #Persistent Eat sub still runs even when done, this is just a lazy way to "exit the script"
 +
;Exit will not stop a persistent and my other choice is ExitApp which will completely terminate the script and the counter GUI.
 +
;The Eat sub runs whether you choose grilled foods or not. Even though its in an If statement, it still runs, so thats my workaround =/
 
}
 
}
  
Sleep 1000
+
 
}
+
}
 +
}
 +
 
 +
 
 +
 
 +
Eat:
 +
 
 +
EatTimer --
 +
GuiControl, Text, ClickText, Clicks: %counter% of %Max%`n`nEat Grilled: %EatTimer%s of 660s
 +
 +
if EatTimer = 0
 +
{
 +
SoundPlay *64,1
 +
GuiControl, Text, ClickText, Eating grilled food...
 +
MouseGetPos, OldMX, OldMY
 +
;Click the Eat Grilled food menu
 +
Click, %EatX%, %EatY%
 +
Sleep, 500
 +
MouseMove, %OldMX%, %OldMY%, 0
 +
EatTimer = 660
 +
Sleep 1000
 +
}
 +
return
 
</pre>
 
</pre>

Latest revision as of 23:36, 20 June 2010

;Ctrl+Alt+W to start script
;Ctrl+P to pause script and Ctrl+P again to resume
;The AHK icon in system tray will turn red while paused.
;Hold F2 for 1 second, while script is running, to pause script and reset click counter to zero.
;Ctrl+R to reload script
;Date: June 20, 2010
;Author: Cegaiel


^r::reload
^p::Pause
^!w::

;X/Y mouse coordinates of a popup box's OK button (yellowish part of the OK button, not the black text)
;530,479 is the position of OK button in 1024x768 resolution
;You can find out your position, at your resolution, with a free tool called Magnify at:
;http://www.atitd.org/wiki/tale4/User:Cegaiel/Macros#Tool:_Magnify_.28Windows_Executable.29
;The purpose of this, is when popup boxes occurs (ie error message when you dont have enough materials to repair a mine)
;The script will make a Windows Error sound and then pause script.
;Once you figure out the problem, Ctrl+P, to resume/unpause where you left of at.

PopX = 530
PopY = 479

counter = 0

	Gui, +AlwaysOnTop +ToolWindow
	Gui, Add, Text,, # of Clicks to Stop?`n(Blank=Unlimited, don't stop):
	Gui, Add, Edit, vClicks wp number
	Gui, Add, Text,, Eating Grilled Food?`n(Automatically eat every 10 Teppy Min)
	Gui, Add, DropDownList, vEat Choose1, No|Yes
	Gui, Add, Button, gStart, Next
	Gui, Show
	return



Start:
Gui, Submit
Gui, Destroy

Msgbox, Hover mouse over a black letter, in skills tab (ie Endurance for digging)`n`nThe letter/skill you want to hover is the one that turns red when you get tired`n`nWhen you are hovering a black letter it will tell you in the tooltip.`n`nPress F2, when it tells you in tooltip, to set position.`n`nClick OK to proceed...

WinActivate, eGenesis Client
SetDefaultMouseSpeed, 0
SetMouseDelay, -1

loop
{
MouseGetPos, skillX, skillY
PixelGetColor, color, skillX, skillY, RGB

if color = 0x000000
{
ToolTip, Coordinates: %skillX%`, %skillY%`nColor: %color%`n`n* HOVERING BLACK *`n* Press F2 to set location *
} else {
ToolTip, Coordinates: %skillX%`, %skillY%`nColor: %color%
}


GetKeyState, state, F2
if state = D
{
color = 0x000000
MsgBox Skills text location recorded, now its time to record the click location.`n`nHover where you want to click and press F2.`n`nFor a dig (or other skills related tasks), pin up the Dig Hole menu and set the click to the word Dig.`n`nFor limestone/dirt set the click position on the icon.`n`nClick OK to proceed...
Tooltip
WinActivate, eGenesis Client
break
}
}


KeyWait, F2, D
if ErrorLevel = 0
{
MouseGetPos, ClickX, ClickY
Msgbox, Click location recorded!`n`nNote: you can hit Ctrl+P to PAUSE script anytime and Ctrl+P again to RESUME`n`nHold F2, while the script is running, to pause and reset click numbers.`nThen just Ctrl+P to unpause script and continue at 0 clicks.`n`nClick OK to continue...
}


		if (Eat == "Yes")
		{

Msgbox, One more step! You have selected that you will be eating grilled foods!`n`nPinup the Esc, Skills, Consume menu and set the click position of the "Eat Grilled food" menu by hovering and hitting F2.`n`nNote: When this macro begins, it will first eat (so don't manually eat first).`n`nThen every 10 Teppy Mins (11:00 real time), it will automatically click/eat the grilled food.`n`nClick OK, then hit F2 over the grilled food consume menu to set...

	WinActivate, eGenesis Client

	KeyWait, F2, D
	if ErrorLevel = 0
	{
	MouseGetPos, EatX, EatY
	Msgbox, Eat location recorded!`n`nClick OK to eat food and start the macro...

	EatTimer = 1
	#Persistent 
	SetTimer, Eat, 1000

	}
		}


	Gui, +AlwaysOnTop +ToolWindow
	Gui, Add, Text, vClickText, Preparing to start... Standby!`n`n`n`n
	Gui, Show
	GuiControl, Text, ClickText, Preparing to start... Standby!`n`n`n`n



	Delay = 5
	;You got 5 seconds to drag the status window out of the way
	Loop, %Delay%
	{
	GuiControl, Text, ClickText, %Delay%s to begin... Standby!
	Delay --
	Sleep 1000
	}




;This just appends the "of #" or the "of Unlimited" text on GUI bar.
if (Clicks > 0)
{
Max := Clicks
} else {
Max := "Unlimited"
}


	GuiControl, Text, ClickText, Focusing eGenesis client...



	loop
	{

WinActivate, eGenesis Client




;This searches for a popup box, which would suggest something likely went wrong

			PixelSearch, Px, Py, %PopX%, %PopY%, %PopX%, %PopY%, 0xECDFBD, 15, Fast|RGB

			if ErrorLevel = 0
			{
			SoundPlay *16,1
			SoundPlay *16,1
			SoundPlay *16,1
			SoundPlay *16,1
			SoundPlay *16,1
			Msgbox, Pop Up box detected! Pausing macro...`n`nNo problem, just find the problem, correct and hit Ctrl+P.`n`nYou will resume from where you left off at...
			PAUSE
			}

;End searching for popupbox






GetKeyState, state, F2
if state = D
{
Msgbox, Reseting click number to 0`n`nCurrent click number: %counter%`n`nClick OK to continue...
counter = 0
}


PixelGetColor, color, skillX, skillY, RGB


if color = 0x000000
{
counter++
MouseGetPos, OldX, OldY
Click %ClickX%, %ClickY% 
MouseMove, %OldX%, %OldY%


		if (Eat == "Yes")
		{
		GuiControl, Text, ClickText, Clicks: %counter% of %Max%`n`nEat Grilled: %EatTimer%s of 660s
		} else {
		GuiControl, Text, ClickText, Clicks: %counter% of %Max%`n`nCtrl+R: Reload, +P: Pause`n`nHold F2: Reset click # to 0
		Sleep 250 ;This sleep helps prevent double clicks. Grilled food automatically has a 1 second delay from the seconds countdown
		}



if (counter = Clicks)
{
GuiControl, Text, ClickText, Clicks: %counter% of %Max% - Done!`n`nCtrl+R to Reload/Reset
SoundPlay *16,1
PAUSE
;The purpose of the pause is because the #Persistent Eat sub still runs even when done, this is just a lazy way to "exit the script"
;Exit will not stop a persistent and my other choice is ExitApp which will completely terminate the script and the counter GUI.
;The Eat sub runs whether you choose grilled foods or not. Even though its in an If statement, it still runs, so thats my workaround =/
}


		}
	}



	Eat: 

	EatTimer --
	GuiControl, Text, ClickText, Clicks: %counter% of %Max%`n`nEat Grilled: %EatTimer%s of 660s
	
	if EatTimer = 0
	{
	SoundPlay *64,1
	GuiControl, Text, ClickText, Eating grilled food...
	MouseGetPos, OldMX, OldMY
	;Click the Eat Grilled food menu
	Click, %EatX%, %EatY%			
	Sleep, 500
	MouseMove, %OldMX%, %OldMY%, 0			
	EatTimer = 660
	Sleep 1000
	}
	return