Page 1 of 1

Functions - keyboardPress(), keyboardType()

Posted: Fri Feb 22, 2008 9:54 pm
by zer0
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

Re: Functions - keyboardPress(), keyboardType()

Posted: Fri Feb 22, 2008 10:09 pm
by Administrator
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.

Re: Functions - keyboardPress(), keyboardType()

Posted: Fri Feb 22, 2008 11:44 pm
by zer0
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?

Re: Functions - keyboardPress(), keyboardType()

Posted: Sat Feb 23, 2008 1:19 am
by zer0
bump - post updated.

Re: Functions - keyboardPress(), keyboardType()

Posted: Sat Feb 23, 2008 5:01 am
by Administrator
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.

Re: Functions - keyboardPress(), keyboardType()

Posted: Mon Jun 02, 2008 12:41 am
by zer0
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.

Re: Functions - keyboardPress(), keyboardType()

Posted: Mon Jun 02, 2008 2:02 am
by Administrator
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.