RoM sendmail

You may request or share scripts for MicroMacro in this forum.
Post Reply
Message
Author
haura
Posts: 20
Joined: Fri Jan 23, 2009 6:54 am

RoM sendmail

#1 Post by haura » Wed Feb 18, 2009 4:13 am

This script need Elviron's function.lua module so save in same folder if you like. I don't provide any support, sorry!

I should have specified that MicroMacro 0.99 is required. (MM 1.0 had some unspecified problem with mouseSet and mouseGetPos coordinates and so I have not checked this script under MM 1.0)

Its function is send all items from backpack to a named character (a storage mule). You can modify it to accept the number of items to send or just use the F12 key to terminate the script after the current item is sent.

The RoM window must remain active and on top of desktop while this script runs.

Someone might improve on it. I experience bad lag so some of the included delays may not be necessary for your connection.

Code: Select all

include("functions.lua");

addressKey = key.VK_INSERT -- 
sortKey = key.VK_F1; -- 
itemKey = key.VK_F2; -- 
attachKey = key.VK_F3;
sendKey = key.VK_F4;
abortKey = key.VK_F12; -- press and hold this key to abort after the current message is sent

CAction = class(
	function (self)
		self.Learned = false;
		self.x = nil;
		self.y = nil;
	end
);

address = class(CAction);
sort = class(CAction);
item = class(CAction);
attach = class(CAction);
send = class(CAction);

local x,y = nil,nil

function main()
	mouseSetDelay(250);
	cprintf(cli.green, "RoM send mail wizard\n");
	printf("Items in backpack are sorted and sent one at a time to just one addressee.\n")
	printf("Open Backpack and mailbox Compose tab. Ensure address field is blank.\n")
	printf("Do not move the window locations after starting this macro.\n")
	cprintf(cli.yellow,"Press and hold (%s) at any time to abort send after the current item.\n",getKeyName(abortKey))
	keyboardBufferClear();
	io.stdin:flush();
	cprintf(cli.green, "Enter the name of adressee > ");
	addressee = io.stdin:read();


	cprintf(cli.yellow,"Position mouse at address input box and press (%s)\n",getKeyName(addressKey));
	repeat
		if( keyPressed(addressKey) ) then
			address.x,address.y = mouseGetPos(); 
			mouseSet(address.x,address.y);
			mouseLClick();
            keyboardPress( key.VK_HOME );
            keyboardHold( key.VK_SHIFT ); keyboardPress( key.VK_END ); keyboardRelease( key.VK_SHIFT );
            yrest(100);
            keyboardType(addressee);
			printf("Good, was the correct address input?\n"); -- no verification code yet
			address.Learned = true;
		else
            yrest(100);
			-- printf("Wrong key pressed.\n");
		end
	until address.Learned
    
	cprintf(cli.green,"CLICK ");
	cprintf(cli.yellow,"the backpack sort icon until the inventory is sorted \n");
    cprintf(cli.yellow,"and leave the mouse hovering there.\nThen press (%s)\n",getKeyName(sortKey));
	repeat
	    if( keyPressed(sortKey) ) then
			sort.x,sort.y = mouseGetPos(); 
			mouseSet(sort.x,sort.y);
			--mouseLClick();
            mouseLHold(); yrest(200); mouseLRelease();
			printf("Good, check the address - was it corrupted by your keypress?\n"); -- no verification code yet
			sort.Learned = true;
		else
            yrest(100);
			-- printf("Wrong key pressed.\n");
		end
	until sort.Learned
    
	cprintf(cli.yellow,"Hover mouse over the top-left item in the bag. Do not click! Then press (%s)\n",getKeyName(itemKey));
	repeat
		if( keyPressed(itemKey) ) then
			item.x,item.y = mouseGetPos(); 
			mouseSet(item.x,item.y);
			--mouseLClick();
            mouseLHold(); yrest(200); mouseLRelease();
			printf("Good, was the selected just now?\n"); -- no verification code yet
			item.Learned = true;
		else
            yrest(100);
			-- printf("Wrong key pressed.\n");
		end
	until item.Learned
	
    printf("Almost finished! ... Just two more steps to learn.\n");
	cprintf(cli.yellow,"Hover mouse over the Attachment box on the Compose tab of the mailbox. Do not click! Then press (%s)\n",getKeyName(attachKey));
	repeat
		if( keyPressed(attachKey) ) then
			attach.x,attach.y = mouseGetPos(); 
			mouseSet(attach.x,attach.y);
			--mouseLClick();
            mouseLHold(); yrest(200); mouseLRelease();
			printf("Good, was the selected item attached to the Compose tab just now?\n"); -- no verification code yet
			attach.Learned = true;
		else
            yrest(100);
			-- printf("Wrong key pressed.\n");
		end
	until attach.Learned

	cprintf(cli.yellow,"Finally, hover mouse over the Send button on the Compose tab. Do not click! Then press (%s)\n",getKeyName(sendKey));
	repeat
		if( keyPressed(sendKey) ) then
			send.x,send.y = mouseGetPos(); 
			mouseSet(send.x,send.y);
			--mouseLClick();
            mouseLHold(); yrest(200); mouseLRelease();
            yrest(500)
			printf("Good, was the message with attachment sent just now?\n"); -- no verification code yet
			send.Learned = true;
		else
            yrest(100);
			-- printf("Wrong key pressed.\n");
		end
	until send.Learned

	-- now iterate through the remaining 29 items to send each item from the backpack inventory tab to the one addressee
	yrest(100)
    cprintf(cli.lightblue,"Starting loop. Press (F6) at any time to pause.\n");
	-- for i = 1,29 do
    local abort = false;
    repeat
		mouseSet(address.x,address.y);
		mouseLClick();
        keyboardPress( key.VK_HOME );
        keyboardHold( key.VK_SHIFT ); keyboardPress( key.VK_END ); keyboardRelease( key.VK_SHIFT );
        keyboardType(addressee);
		--yrest(200);
		mouseSet(sort.x,sort.y);
		--mouseLClick();
        mouseLHold(); yrest(200); mouseLRelease();
		yrest(100);
		mouseSet(item.x,item.y);
		--mouseLClick();
		mouseLHold(); yrest(200); mouseLRelease();
		--yrest(500)
		mouseSet(attach.x,attach.y);
		--mouseLClick();
        mouseLHold(); yrest(200); mouseLRelease();
		yrest(200);
		mouseSet(send.x,send.y);
		--mouseLClick();
        mouseLHold(); yrest(200); mouseLRelease();
		yrest(300)
        if( keyPressed(abortKey) ) then abort = true; end;
	--end; -- for i = 1,29 do
    until abort
	
end
startMacro(main, true);
Last edited by haura on Fri Feb 20, 2009 3:50 am, edited 1 time in total.

User avatar
Administrator
Site Admin
Posts: 5307
Joined: Sat Jan 05, 2008 4:21 pm

Re: RoM sendmail

#2 Post by Administrator » Wed Feb 18, 2009 2:19 pm

Nice work. This will definitely come in handy for off-loading all those daily quest items. People are working on an addon that will do almost exactly what this does, but this is great until that addon is up and working fully.

I'd also suggest the inventory viewer addon (so you can keep track of other characters' inventories without switching), and RoMail addon(to quickly get all items/money out of mail) to accompany this.

haura
Posts: 20
Joined: Fri Jan 23, 2009 6:54 am

Re: RoM sendmail

#3 Post by haura » Wed Feb 18, 2009 3:04 pm

Administrator wrote:People are working on an addon that will do almost exactly what this does, but this is great until that addon is up and working fully.
I look forward to such an addon.
I'd like to be doing some addon development but I find the lack of API documentation and the need to relaunch the game for any changes to take effect two rather severe obstacles.
Last edited by haura on Fri Feb 27, 2009 3:46 am, edited 1 time in total.

Yahell14
Posts: 9
Joined: Fri Feb 20, 2009 6:43 am

Re: RoM sendmail

#4 Post by Yahell14 » Fri Feb 20, 2009 9:59 am

where do i need to copy this code to?
srry for beeing noob :X

Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests