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.

User:Makazi/Macro/Pixel Click

From ATITD5
< User:Makazi‎ | Macro
Revision as of 22:03, 25 January 2011 by Makazi (talk | contribs) (Created page with "<pre> -- Pixel Click by Makazi, based on multi_click.lua by Jimbly -- A macro for repeatedly hitting the same button/image with a mouseclick. -- loadfile("luaScripts/screen_read...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search
-- Pixel Click by Makazi, based on multi_click.lua by Jimbly
-- A macro for repeatedly hitting the same button/image with a mouseclick.
--

loadfile("luaScripts/screen_reader_common.inc")();
loadfile("luaScripts/ui_utils.inc")();

per_click_delay = 150;

function doit()
	askForWindow("You will be asked to select what to click, be sure to hit something that is unique.");

	while 1 do
		mx, my = srMousePos();
		srReadScreen();
		srMakeImage("Pixel", mx, my, 16, 8);
		srShowImageDebug("Pixel", 5, 200);
		statusScreen("Place mouse over relevent text (16x8 pixels used to the LOWER RIGHT of mouse) and press Shift.");
		if (lsShiftHeld()) then
			break;
		end
		image_name = "Pixel"
		lsSleep(10);
	end

				
	-- Find buttons and click them!
	while 1 do
		srReadScreen();
		xyWindowSize = srGetWindowSize();
		local buttons = findAllImages(image_name);
		
		if #buttons == 0 then
			statusScreen("Searching for selected pixel...");
			lsSleep(per_click_delay);
		else
			statusScreen("Clicking " .. #buttons .. "button(s)...");

			for i=1, #buttons do
				srClickMouseNoMove(buttons[i][0]+5, buttons[i][1]+3, right_click);
				lsSleep(per_click_delay);
			end
			
			statusScreen("Done clicking (" .. #buttons .. " clicks).");
			lsSleep(per_click_delay);
		end	
	end
end