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);