Functions - keyboardPress(), keyboardType()

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.
Post Reply
Message
Author
zer0
Posts: 213
Joined: Sat Feb 16, 2008 11:55 pm

Functions - keyboardPress(), keyboardType()

#1 Post by zer0 » Fri Feb 22, 2008 9:54 pm

With shaiya, any calls I make to keyboardPress() or keyboardType(), the key is registered as being press twice. I've tried with keyboardSetDelay() and rest(), but no luck, any suggestions? As to what I can do, or am doing wrong?

note - I added key.VK_BACK (backspace) to virtual key map.

Code: Select all

function return_user()
  -- open chat text
  keyboardPress(key.VK_ENTER);
  yrest(100);

  -- remove channel char
  keyboardPress(key.VK_BACK);
  yrest(100);
  keyboardPress(key.VK_BACK);
  yrest(100);

  -- enter "/return", outputs "//rreettuurrnn".
  keyboardSetDelay(100);
  keyboardType("/return");

  -- wait 10 sec for user to respawn.
  yrest(10000);
end

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

Re: Functions - keyboardPress(), keyboardType()

#2 Post by Administrator » Fri Feb 22, 2008 10:09 pm

So you've lowered the delay with keyboardSetDelay()?

You can try using

Code: Select all

keyboardHold(key.VK_ENTER);
rest(10);
keyboardRelease(key.VK_ENTER);
rest(10);
Also try increasing your keyboard repeat time in your keyboard options under control panel.

zer0
Posts: 213
Joined: Sat Feb 16, 2008 11:55 pm

Re: Functions - keyboardPress(), keyboardType()

#3 Post by zer0 » Fri Feb 22, 2008 11:44 pm

Yep, tried lowering the delay, I'll try increasing the OS keyboard delay, it's probably the cause.

edit:
Win Vista -> Control Panel -> Keyboard Properties
Repeat delay: Long
Repeat rate: Slow

Image

keyboardSetDelay() - following values were tested
1000 - Same
100 - Same
10 - Same
1 - Key presses were still twice but no longer in order (considering it's 1ms I'm not surprised :D).

Code: Select all

    keyboardHold(key.VK_ENTER);
    rest(10);
    keyboardRelease(key.VK_ENTER);
    rest(10);
tried that with rest of 10 and 100, still no change.

edit: A bit more testing, every call to keyboardHold() is exactly two key presses, not one. I glanced over the CPP code, I'm using fullscreen mode, if that helps.

Here is my test script (test.lua):

Code: Select all

function return_user() 
  keyboardPress(key.VK_ENTER);
  rest(100);

  --keyboardPress(key.VK_BACK);
  --rest(100);
  --keyboardPress(key.VK_BACK);
  --rest(100);

  -- displays "ffoooo"
  keyboardHold(key.VK_F);
  rest(1000);
  keyboardRelease(key.VK_F);
  rest(1000);
  keyboardHold(key.VK_O);
  rest(1000);
  keyboardRelease(key.VK_O);
  rest(1000);
  keyboardHold(key.VK_O);
  rest(1000);
  keyboardRelease(key.VK_O);
  rest(1000);

  --keyboardSetDelay(100);
  --keyboardType("foobar");
  --yrest(10000);
end

function close()
  closeProcess(proc);
  detach();
end

function init()
  proc = openProcess( findProcessByExe("Game.exe") );

  win = findWindow("Shaiya");
  hdc = openDC(win);
  attach(win);
end

-------------------------------------------------
-- FUNCTION MAIN
-------------------------------------------------
function main()
  init();

  return_user();

  close();
end

startMacro(main);
Have you tested keyboardPress()/keyboardType() for shaiya, on your machine?
Could it be an issue with shaiya's message pump? or the Micromacro code?

edit: I tried to run it on Notepad, and the text was correct, it must be an issue with Shaiya's message pump, has anyone got any idea how to get around this?
Last edited by zer0 on Sat Feb 23, 2008 1:35 am, edited 3 times in total.

zer0
Posts: 213
Joined: Sat Feb 16, 2008 11:55 pm

Re: Functions - keyboardPress(), keyboardType()

#4 Post by zer0 » Sat Feb 23, 2008 1:19 am

bump - post updated.

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

Re: Functions - keyboardPress(), keyboardType()

#5 Post by Administrator » Sat Feb 23, 2008 5:01 am

Well, I wouldn't say a "problem" with Shaiya, but just... "different." I'll maybe screw around with it and see if I can locate the problem. It's strange that it happens with attached and non-attached input, though. If anything, I would assume emulating the key press and posting the message in one call would be the problem, but it appears not to be.

zer0
Posts: 213
Joined: Sat Feb 16, 2008 11:55 pm

Re: Functions - keyboardPress(), keyboardType()

#6 Post by zer0 » Mon Jun 02, 2008 12:41 am

sry for the necro, but I just wanted to let you know that the keyboard typing is fine. It was probably due to the fact that I used attach or that I wasn't running in win xp sp2 compatibility.

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

Re: Functions - keyboardPress(), keyboardType()

#7 Post by Administrator » Mon Jun 02, 2008 2:02 am

It could be because of attach, I suppose. When attaching the input to any window, it will actually send keypresses twice using two different methods to improve compatibility. Because of this, I'm guessing that if Shaiya didn't freeze when it's form loses focus, you could bot it without having the window focused. Well, thanks for the info.

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests