Looking for help

Discuss, ask for help, share ideas, give suggestions, read tutorials, and tell us about bugs you have found with MicroMacro in here.

Do not post RoM-Bot stuff here. There is a subforum for that.
Forum rules
This is a sub-forum for things specific to MicroMacro.

This is not the place to ask questions about the RoM bot, which uses MicroMacro. There is a difference.
Message
Author
kurapicas
Posts: 19
Joined: Sat Apr 11, 2015 1:51 pm

Looking for help

#1 Post by kurapicas » Sat Apr 11, 2015 2:10 pm

Is this possible?

process name: dark.exe

Hotkey F1 - Ammo
Hotkey F2 - Hp Potion
Hotkey F3 - Mp potion

Address of ammo (pointer): "dark.exe"+00621668 offset:50
Address of Hp: 0x00A880C4
address of mp: 0x00A880C8

ammo keep changing address. if i just use normal search address. have to find the pointer so it wont change everytime i login.

what i want is that is it possible to heal once the value of my health or mana reach below 50%?
and possible to reload my ammo if the ammount of ammo is lower than value of 10?

Thanks. I play window mode. So if my health goes down while im browsing youtube or internet it wont interupt the hotkey F1 (Help) in windows? only send the Hotkey F1 through dark.exe

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

Re: Looking for help

#2 Post by Administrator » Sat Apr 11, 2015 4:47 pm

Yes, it can be done. Very easily, even. First, see this tutorial on finding pointers: https://solarstrike.net/phpBB3/viewtopic.php?f=5&t=65

Once you've got your pointers, all you need to do is run a loop, read the contents of those addresses, and then send a hotkey if needed.

If you're doing this with MicroMacro2 (1.9 on the download page while it is still in beta), your script should look something like this:

Code: Select all

local win;
local procId;
local proc;
local exeName = "dark.exe";
function macro.init()
    win = window.find("the title of the window");
    procId = process.findByExec(exeName);
    proc = process.open(procId);
    darkExeAddress = process.getModuleAddress(procId, exeName);

    assert(win);
    assert(proc);
    assert(darkExeAddress);
end

local timeSinceLastAction = 0;
function macro.main(dt)
  timeSinceLastAction = timeSinceLastAction + dt;

  if( timeSinceLastAction > 1 ) then
      local HP = process.read(proc, "int", 0x00A880C4);
      local MP = process.read(proc, "int", 0x00A880C8);
      local ammo = process.readPtr(proc, "int", darkExeAddress + 0x621668, 50);

      if( HP < 80 ) then
        keyboard.virtualPress(win, key.VK_F2);
        timeSinceLastAction = 0;
      end

      if( MP < 50 ) then
         keyboard.virtualPress(win, key.VK_F3);
         timeSinceLastAction = 0;
      end

      if( ammo < 10 ) then
         keyboard.virtualPress(win, key.VK_F1);
         timeSinceLastAction = 0;
      end

  end

  return true;
end
That's just a rough idea. Of course you'll have to adjust the numbers a bit.

kurapicas
Posts: 19
Joined: Sat Apr 11, 2015 1:51 pm

Re: Looking for help

#3 Post by kurapicas » Sat Apr 11, 2015 5:48 pm

Could not get it to work..
- My UAC is off
- Run both files in Admin.
- Using Windows 8

dark.exe is running

but when i save the code into test.lua inside the Script folder and try to run it. I get this error

Code: Select all

2015-04-11 18:27:04 : Failed to run init function, err code: 7 (Runtime error)
test.lua:7: attempt to call a nil value (field 'findByExec')
stack traceback:
	test.lua:7: in function <test.lua:5>
Yes those are the Address of HP and MP they are single pointer address (does not change, stay permanent).

Only the Ammo change, when I go in different map or exit the game. But I manage to find out the pointer through Cheat Engine by following your guide. and that was this. This address stay

0x00621668 + 50 will always point to <some changing address>
<some changing address> + 50 points to my Ammo

Could not post image. So I dont know how this look like.

The Red Address is the Ammo that keep changing. but the Pointer address always point to my ammo.
<?xml version="1.0" encoding="utf-8"?>
<CheatTable>
<CheatEntries>
<CheatEntry>
<ID>5</ID>
<Description>"pointerscan result"</Description>
<LastState Value="231" Activated="0" RealAddress="0C834E30"/>
<Color>80000008</Color>
<VariableType>4 Bytes</VariableType>
<Address>"dark.exe"+00621668</Address>
<Offsets>
<Offset>50</Offset>
</Offsets>
</CheatEntry>
</CheatEntries>
</CheatTable>
i also change "the title of the window" to " dknb " there 2 space at the beginning of the title, i used autoit and ahk window spy. show same result.

0x00621668 + 50 is a static address
Attachments
1.png
3.png

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

Re: Looking for help

#4 Post by Administrator » Sat Apr 11, 2015 6:39 pm

Sorry, the function is findByExe, not findByExec.

The code I provided should lookup the module address for dark.exe, so it should actually work the way I have it, but that code was entirely off the top of my head and untested.

kurapicas
Posts: 19
Joined: Sat Apr 11, 2015 1:51 pm

Re: Looking for help

#5 Post by kurapicas » Sat Apr 11, 2015 7:09 pm

Edited.. Works on HP and MP.

Cant get it to work on Ammo.

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

Re: Looking for help

#6 Post by Administrator » Sat Apr 11, 2015 8:03 pm

What happens when you try this:

Code: Select all

print("exe + offset1, ptr:", darkExeAddress + 0x621668);
print("exe + offset1, addr:", process.read(proc, "int", darkExeAddress + 0x621668));

kurapicas
Posts: 19
Joined: Sat Apr 11, 2015 1:51 pm

Re: Looking for help

#7 Post by kurapicas » Sat Apr 11, 2015 8:12 pm

Administrator wrote:What happens when you try this:

Code: Select all

print("exe + offset1, ptr:", darkExeAddress + 0x621668);
print("exe + offset1, addr:", process.read(proc, "int", darkExeAddress + 0x621668));

I get a huge dump of this..it just keep going non stop.

should it suppose to show the Ammo ADDRESS "that keep changing" from Static Pointer?. it doesnt seem to match tho.
When i added the Pointer Address on CE manually. it show different address of the ammo..
Attachments
ptr.png

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

Re: Looking for help

#8 Post by Administrator » Sat Apr 11, 2015 9:27 pm

That is outputting in decimal. You'd want to output in hex. Try this:

Code: Select all

local ptr = process.read(proc, "int", darkExeAddress + 0x621668);
printf("ptr: 0x%X\n", ptr);
local value = process.read(proc, "int", ptr);
printf("Value: %d (0x%X)\n", value, value);
Please just copy and paste the output instead of posting screenshots of text data.

kurapicas
Posts: 19
Joined: Sat Apr 11, 2015 1:51 pm

Re: Looking for help

#9 Post by kurapicas » Sat Apr 11, 2015 10:07 pm

I added those line below

Code: Select all

 local ammo = process.readPtr(proc, "int", darkExeAddress + 0x621668, 50);
after adding that. I get this error

Code: Select all

Please enter the script name to run.
Type in 'exit' (without quotes) to exit.
Script> 1test
Running '1test'

ptr: 0xC267A88
Value: 9058332 (0x8A381C)
Error in main loop. Error code 7 (Runtime error)
1test.lua:39: attempt to compare nil with number
stack traceback:
        1test.lua:39: in function <1test.lua:18>

Please enter the script name to run.
Type in 'exit' (without quotes) to exit.
Script>

kurapicas
Posts: 19
Joined: Sat Apr 11, 2015 1:51 pm

Re: Looking for help

#10 Post by kurapicas » Sat Apr 11, 2015 10:46 pm

Thank you for your help.

After i follow your CE Guide to get the Pointer.

I tried another Memory Software like Art Money. and follow your Guide again. It works like a charmed.
local ammo = process.readPtr(proc, "int", darkExeAddress + 0x621668, 80);
How do i add by pressing Capslock then it would hold down Right Click mouse button?
And release capslock state function off *Capslock off*.

Code: Select all

local win;
local procId;
local proc;
local exeName = "dark.exe";
function macro.init()
    win = window.find("  dknb  ");
    procId = process.findByExe(exeName);
    proc = process.open(procId);
    darkExeAddress = process.getModuleAddress(procId, exeName);

    assert(win);
    assert(proc);
    assert(darkExeAddress);
end


local timeSinceLastAction = 0;
function macro.main(dt)
  timeSinceLastAction = timeSinceLastAction + dt;

  if( timeSinceLastAction > 1 ) then
      local HP = process.read(proc, "int", 0x00A880C4);
      local MP = process.read(proc, "int", 0x00A880C8);
	  local ammo = process.readPtr(proc, "int", darkExeAddress + 0x621668, 80);

      if( HP < 1000 ) then
        keyboard.press(key.VK_F2);
        timeSinceLastAction = 0;
      end

      if( MP < 100 ) then
         keyboard.press(key.VK_F3);
         timeSinceLastAction = 0;
      end

      if( ammo < 250 ) then
         keyboard.press(key.VK_F1);
         timeSinceLastAction = 0;
      end

  end

  return true;
end


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

Re: Looking for help

#11 Post by Administrator » Sun Apr 12, 2015 11:05 am

Here's the keyboard module documentation: https://solarstrike.net/wiki/index.php? ... ard_Module

To check if Capslock is on, you'll use keyboard.getToggleState():

Code: Select all

capsOn = keyboard.getToggleState(key.VK_CAPSLOCK);
I suppose setting the toggle state directly isn't supported yet (so I'll have to add that), but you can just press it to toggle:

Code: Select all

if( capsOn ) then
  keyboard.press(key.VK_CAPSLOCK);
end

kurapicas
Posts: 19
Joined: Sat Apr 11, 2015 1:51 pm

Re: Looking for help

#12 Post by kurapicas » Sun Apr 12, 2015 12:59 pm

EDIT: Got it fix. turn out to be

Code: Select all

mouse.hold(2)
i was thinking it would be similar format.

Code: Select all

keyboard.press(key.VK_CAPSLOCK)
mouse.hold(number.VK_2)
Is there a way to add pressing caps again after 190 seconds?

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

Re: Looking for help

#13 Post by Administrator » Sun Apr 12, 2015 1:26 pm

It is. Those names just stand for numbers. 2 just happens to be the right mouse button. You should probably use key.VK_RMOUSE though.
The full list of virtual keys (vks) is here: http://www.solarstrike.net/wiki/index.p ... Key_Module
Some keys contain multiple aliases. ie. VK_CAPITAL and VK_CAPSLOCK are the same thing.

To have it automatically toggle the capslock key again after some time, you can use a timer in one of two ways.

Method 1, the long method:

Code: Select all

local timeLeft = 0;
local triggered = false;
function macro.main(dt)
  if( timeLeft > 0 ) then
    timeLeft -= dt;
  else
    if( not triggered ) then
      -- Just triggered it now, so do something about it.
      triggered = true;
      keyboard.press(key.VK_CAPSLOCK);
    end
  end
end
Now, wherever you want to start the countdown:

Code: Select all

  timeLeft = 190;    -- Time in seconds until activated
  triggered = false;  -- Reset the triggered state

Method 2, the clean method:
At the top of your script, add this:

Code: Select all

require('timestamp');
To start the timer:

Code: Select all

actionTimestamp = Timestamp:now():addSeconds(190); -- 190 = time in seconds from now
In your main loop, check if it is triggered:

Code: Select all

if( actionTimestamp and not actionTimestamp:isFuture() ) then
  -- Triggered!
  keyboard.press(key.VK_CAPSLOCK);
  actionTimestamp = nil;
end
Realistically, these both work the same way. The difference is that we use the Timestamp class to handle most of the work for us and to just make the code cleaner and easier to use. Additionally, instead of a second variable to tell whether it was already triggered and reset or not, we just set the timestamp to nil to signal that we aren't running the timer right now.

kurapicas
Posts: 19
Joined: Sat Apr 11, 2015 1:51 pm

Re: Looking for help

#14 Post by kurapicas » Sun Apr 12, 2015 1:33 pm

Thanks.. I also been looking at those Module. Went to see Timing Module. but only showed Time/Date format.

But cant find an example how to send/press a key button every X seconds.

tried this

Code: Select all

function macro.init()
	timeLeft = 200;

Code: Select all

function macro.main(dt)
  timeSinceLastAction = timeSinceLastAction + dt;
  timeLeft = timeLeft - dt;

if( timeLeft < 0 ) then
    print("200 seconds have elapsed.");
    timeLeft = 200; -- Now reset it
	keyboard.press(key.VK_CAPSLOCK);
  end
it seems this code timeleft affect everything..I wanted it only start the timeleft when i press capslock
Last edited by kurapicas on Sun Apr 12, 2015 1:52 pm, edited 1 time in total.

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

Re: Looking for help

#15 Post by Administrator » Sun Apr 12, 2015 1:47 pm

I should also add that if you just want to continually trigger that every 190 seconds instead of only 190 seconds after some event (user input?) you can do this:

Code: Select all

actionTimestamp = Timestamp:now():addSeconds(190);
function macro.main(dt)
  if( not actionTimestamp:isFuture() ) then
    keyboard.press(key.VK_CAPSLOCK);
    actionTimestamp = Timestamp:now():addSeconds(190); -- Reset it
  end
end

kurapicas
Posts: 19
Joined: Sat Apr 11, 2015 1:51 pm

Re: Looking for help

#16 Post by kurapicas » Sun Apr 12, 2015 2:02 pm

cant seem to get that actionTimestamp to work. i added it below function macro.init()

Code: Select all

Failed to run init function, err code: 7 (Runtime error)
dnbk.lua:10: attempt to index a nil value (global 'Timestamp')

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

Re: Looking for help

#17 Post by Administrator » Sun Apr 12, 2015 2:11 pm

Ah, right. That's my fault. I forgot to include the lib folder with the releases.
In the main micromacro folder (the one with micromacro.exe), create a new folder named lib. Save the attached file (timestamp.lua) into that folder. Now it should work.
Attachments
timestamp.lua
(5.64 KiB) Downloaded 179 times

kurapicas
Posts: 19
Joined: Sat Apr 11, 2015 1:51 pm

Re: Looking for help

#18 Post by kurapicas » Sun Apr 12, 2015 4:31 pm

Sorry for late reply, couldn't test it right away..

put the timestamp.lua inside this folder i created lib

Code: Select all

C:\Users\teemo\Downloads\micromacro.1.91.41_x64\micromacro\lib
run the script and still get error.

Code: Select all

2015-04-12 17:28:54 : Failed to run init function, err code: 7 (Runtime error)
test.lua:10: attempt to index a nil value (global 'Timestamp')
stack traceback:
	test.lua:10: in function <test.lua:5>
Last edited by kurapicas on Sun Apr 12, 2015 4:34 pm, edited 2 times in total.

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

Re: Looking for help

#19 Post by Administrator » Sun Apr 12, 2015 4:33 pm

Did you put require('timestamp') at the top of your script?

kurapicas
Posts: 19
Joined: Sat Apr 11, 2015 1:51 pm

Re: Looking for help

#20 Post by kurapicas » Sun Apr 12, 2015 4:38 pm

didnt know that require function would be needed. now its fixed. script running great...

Post Reply

Who is online

Users browsing this forum: No registered users and 9 guests