Looking for help
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.
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.
- Administrator
- Site Admin
- Posts: 5312
- Joined: Sat Jan 05, 2008 4:21 pm
Re: Looking for help
Good. Glad you could get it all working and it seems you learned a few things.
The require function is used to include additional optional packages, including Lua plugins, libraries, or modules. Everything in that lib folder will be considered optional.
The require function is used to include additional optional packages, including Lua plugins, libraries, or modules. Everything in that lib folder will be considered optional.
Re: Looking for help
Yep I learned a lot today and yesterday.
Now Im learning this. Attach?
So it would be like this?
can it work also like attaching process?
While I was reading through Keyboard Module. I found this attach
Now the problem is that its reading the Ammo. but i switch to Notepad++ then F1 (Help) appeared.? that keypress should be only send through attach process
I cant find an example of AttachInput script.
Ex: typing "yes" in notepad.exe while not focus on another window?
Now Im learning this. Attach?
Code: Select all
attach( findWindow(" dnbk ") );
Code: Select all
function macro.init()
attach = window.find(" dknb ");
end
Code: Select all
attach = process.findByExe(exeName);
So im trying to use attach. its A cool feature, I can Browse without worrying that my Health is going down if im not focus into the game window..If you are running input in attached mode (through use of attach()) it will only send input to the target window, and will not interfere if you decide to switch windows.
Now the problem is that its reading the Ammo. but i switch to Notepad++ then F1 (Help) appeared.? that keypress should be only send through attach process
I cant find an example of AttachInput script.
Ex: typing "yes" in notepad.exe while not focus on another window?
- Administrator
- Site Admin
- Posts: 5312
- Joined: Sat Jan 05, 2008 4:21 pm
Re: Looking for help
You don't need to attach() with MicroMacro 2. Instead, you just use the keyboard.virtualPress(win, vk) function. It has the same effect of sending the input directly to the window.
You should probably store the window in a variable instead of calling window.find() constantly.
You should probably store the window in a variable instead of calling window.find() constantly.
Code: Select all
win = window.find(" dnbk ");
keyboard.virtualPress(win, key.VK_F1);
Re: Looking for help
Tried that
but it doesnt seem to send F1 key, even i went into the game.. VirtualPress doesnt seem to work.
but keyboard.press works fine. Im using Windows 8.1 maybe virtual keyboards doesnt work..
Code: Select all
keyboard.virtualPress(win, key.VK_F1);
but keyboard.press works fine. Im using Windows 8.1 maybe virtual keyboards doesnt work..
- Administrator
- Site Admin
- Posts: 5312
- Joined: Sat Jan 05, 2008 4:21 pm
Re: Looking for help
Maybe. Whether that type of input works or not depends entirely on how the input logic is programmed in the target application.
Another possibility is that the game is just creating multiple windows, and you're just sending it to the wrong one.. You can use a tool like WinSpy to investigate that further. What happens when you add this to macro.init():
Another possibility is that the game is just creating multiple windows, and you're just sending it to the wrong one.. You can use a tool like WinSpy to investigate that further. What happens when you add this to macro.init():
Code: Select all
local windows = process.getWindows( process.findByExe("dark.exe") );
for i,v in pairs(windows) do
printf("windows[%d]: hwnd: %d, class: %s, name: %s\n", i, v.hwnd, v.class, v.name);
end
Re: Looking for help
Get Error of
about the timestamp
it seems when i run the script, It also start the timer, the moment the script start running..
I just wanted the time counter for this part, pressing capslock should activate the timestamp event..
Code: Select all
2015-04-12 22:46:33 : Load file error code: 7 (Runtime error)
1test.lua:6: attempt to call a nil value (field 'getWindows')
Code: Select all
function macro.init()
actionTimestamp = Timestamp:now():addSeconds(200);
I just wanted the time counter for this part, pressing capslock should activate the timestamp event..
Code: Select all
if( not actionTimestamp:isFuture() ) then
actionTimestamp = Timestamp:now():addSeconds(200); -- Reset it
keyboard.press(key.VK_CAPSLOCK);
mouse.hold(key.VK_RMOUSE);
print("200 seconds have elapsed.");
else
if( capsOn ) then
keyboard.press(key.VK_CAPSLOCK);
end
end
- Administrator
- Site Admin
- Posts: 5312
- Joined: Sat Jan 05, 2008 4:21 pm
Re: Looking for help
Sorry about that again. I'm not testing this code at all and it's just off the top of my head. The function is process.getWindows(), not window.getWindows().
If you don't want to start the timer and instead want to trigger it immediately, you could just chop off the ":addSeconds(200)" part of the call that happens outside of the main function. Alternatively, you might consider changing it to 3 seconds or something to give you a chance to switch back to the window before it triggers for the first time.
If you don't want to start the timer and instead want to trigger it immediately, you could just chop off the ":addSeconds(200)" part of the call that happens outside of the main function. Alternatively, you might consider changing it to 3 seconds or something to give you a chance to switch back to the window before it triggers for the first time.
Re: Looking for help
Code: Select all
windows[1]: hwnd: 1573668, class: dknb , name: dknb
windows[2]: hwnd: 4982006, class: MSCTFIME UI, name: MSCTFIME UI
windows[3]: hwnd: 7734736, class: IME, name: Default IME
I even tried
Code: Select all
timeLeft = 200; function.
maybe there a way to put timeleft countdown inside macro.main? so it would only start counting down when capslock is pressed? It would start the script even press capslock on its own.
Code: Select all
function macro.main(dt)
if( capsOn ) then
keyboard.press(key.VK_CAPSLOCK);
mouse.hold(key.VK_RMOUSE)
timeleft = 200; -- start countdown
else
if( timeLeft < 0 ) then -- when countdown reach 0
keyboard.press(key.VK_CAPSLOCK); -- press capslock again then this goes back to function "( capsOn )"
end
end
- Administrator
- Site Admin
- Posts: 5312
- Joined: Sat Jan 05, 2008 4:21 pm
Re: Looking for help
You can try using virtualPress() but specify different windows to see if it works or not. Based on that input, you could do this:
When that doesn't work, change win to the next number and try again. Note that these numbers will certainly change every time you restart the game, but if you can find a window that works, then we can work around that. If all don't work, then that type of synthetic input just isn't picked up by the game's input code, so there's not much you can do about it except just use regular input (though that requires the game to be focused).
OK, so, you want the timer to only start when you manually press the capslock key. First, remove both calls that were setting actionTimestamp (both outside the main function and the one where it is triggered). On the trigger itself, you again want to change this line:
so it includes the "actionTimestamp and" part again, as well as the "actionTimestamp = nil" inside it. This is so we won't get nil errors, and disable it after it has been triggered.
Now, you're going to add some code to capture an event:
This will check if the user has pressed and released their capslock key, and if they have, it starts the actionTimestamp timer to be triggered in 200 seconds. It will also disable the capslock key instantly.
Code: Select all
win = 1573668;
keyboard.virtualPress(win, key.VK_F1);
OK, so, you want the timer to only start when you manually press the capslock key. First, remove both calls that were setting actionTimestamp (both outside the main function and the one where it is triggered). On the trigger itself, you again want to change this line:
Code: Select all
if( actionTimestamp and not actionTimestamp:isFuture() ) then
actionTimestamp = nil;
Now, you're going to add some code to capture an event:
Code: Select all
function macro.event(e, ...)
if( e == "keyreleased" ) then
vk,toggle = ...;
if( vk == key.VK_CAPSLOCK ) then
actionTimestamp = Timestamp:now():addSeconds(200);
if( toggle ) then
keyboard.press(key.VK_CAPSLOCK, false);
end
print("Timestamp set.");
end
end
end
Re: Looking for help
It seem it only trigger once.
The game have feature of auto attack by pressing CapsLock and Holding right click.
The Auto Attack last for 3 minutes only (180 seconds)..
So in order to auto attack again I must press capslock and Hold right click again...
maybe im doing something wrong. But here entire code.
http://codepad.org/6cAN0Bm1
The game have feature of auto attack by pressing CapsLock and Holding right click.
The Auto Attack last for 3 minutes only (180 seconds)..
So in order to auto attack again I must press capslock and Hold right click again...
maybe im doing something wrong. But here entire code.
http://codepad.org/6cAN0Bm1
- Administrator
- Site Admin
- Posts: 5312
- Joined: Sat Jan 05, 2008 4:21 pm
Re: Looking for help
You didn't do anything wrong, you just coded it to be enabled, but not ever disabled when pressing the capslock again.
Just need to add in that if/else statement to toggle it.
Oh, also remove the line setting actionTimestamp to nil on the trigger code, so it doesn't get disabled after one run. Re-add the code that restarts the timer.
Code: Select all
if( e == "keyreleased" ) then
vk,toggle = ...;
if( vk == key.VK_CAPSLOCK ) then
if( actionTimestamp ) then
actionTimestamp = nil;
print("Disabled");
else
actionTimestamp = Timestamp:now():addSeconds(185);
print("Enabled");
end
if( toggle ) then
keyboard.press(key.VK_CAPSLOCK, false);
end
end
end
Oh, also remove the line setting actionTimestamp to nil on the trigger code, so it doesn't get disabled after one run. Re-add the code that restarts the timer.
Re: Looking for help
Sorry for late reply... Was away for a while.
Thanks works completely now..
Is there a way to change the Value of HP and MP to Percent?. I had to keep changing the value everytime i play low level character or high level character. How to make it 50%?
if( HP < 50% ) doesnt seem to work
Thanks works completely now..
Is there a way to change the Value of HP and MP to Percent?. I had to keep changing the value everytime i play low level character or high level character. How to make it 50%?
if( HP < 50% ) doesnt seem to work
- Administrator
- Site Admin
- Posts: 5312
- Joined: Sat Jan 05, 2008 4:21 pm
Re: Looking for help
Well, a percentage is just a ratio of the current level out of its maximal amount, so you'll need to get the max HP and max MP values as well. Then you can just do this:
Code: Select all
local HP_percent = (HP / maxHP) * 100;
local MP_percent = (MP / maxMP) * 100;
if( HP_percent < 50 ) then
Re: Looking for help
can the max HP and Max MP value just be read from the HP/MP address?. cuz lowest character HP Value is like 400 while my other character have 5k+ hp.
- Administrator
- Site Admin
- Posts: 5312
- Joined: Sat Jan 05, 2008 4:21 pm
Re: Looking for help
The max HP/MP values are very often stored +4 bytes from the original. That is, your HP is stored at 0x00A880C4, so try checking 0x00A880C8. Do the same thing for MP.
Re: Looking for help
So the way I add it would be like this?
or
or
Which way is the right one? Im very noob at this
Code: Select all
local HP = process.read(proc, "int", 0x00A880C4);
local MP = process.read(proc, "int", 0x00A880C8);
local maxHP = process.read(proc, "int", 0x00A880CC);
local maxMP = process.read(proc, "int", 0x00A880D0);
local HP_percent = (HP / maxHP) * 100;
local MP_percent = (MP / maxMP) * 100;
Code: Select all
local HP_percent = (0x00A880C4 / 0x00A880CC) * 100;
local MP_percent = (0x00A880C8 / 0x00A880D0) * 100;
Code: Select all
local HP_percent = process.read(proc, "int", 0x00A880C4 / 0x00A880CC) * 100;
local MP_percent = process.read(proc, "int", 0x00A880C8 / 0x00A880D0) * 100;
- Administrator
- Site Admin
- Posts: 5312
- Joined: Sat Jan 05, 2008 4:21 pm
Re: Looking for help
The first one. But first, you should try adding those addresses in Cheat Engine to make sure that they are correct.
Who is online
Users browsing this forum: No registered users and 8 guests