Results 1 to 8 of 8

Thread: type tKeyboard=record;

  1. #1
    Join Date
    Jun 2012
    Posts
    586
    Mentioned
    112 Post(s)
    Quoted
    296 Post(s)

    Default type tKeyboard=record;

    tKeyboard.send('{enter 2}')
    By @Obscurity;

    Last Updated: 2016-01-26


    Introduction



    It's not much, but it gets the job done. This type lets you send complex strings, buttons, and more with a relatively simple syntax similar to that of AHK. Buttons and combinations such as arrow keys, backspace, enter, and more can now be held, released, pressed with ease.



    Methods


    tKeyboard.code(vKey:string)


    Returns the specified button's keycode.

    This method is used to get the key code of a button. It functions like getKeyCode(), only it accepts strings such as backspace, enter, del, etc.

    Example:
    Simba Code:
    (*
      The following writes:
      37
    *)


    writeLN(
      keyboard.code('left')
    );



    tKeyboard.format(vString:string)


    Returns the specified string, formatted to be used with the send method.

    This method is used to format a string so that it can be easily parsed by the send method. It replaces keys with their respective keycodes, grouping them in brackets.

    Example:
    Simba Code:
    (*
      The following writes:
      {16 down}{72}{16 up}{69}{76}{76}{79}{32}{87}{79}{82}{76}{68}
    *)


    writeLN(
      keyboard.format('{shift down}h{shift up}ello world')
    );



    tKeyboard.press(vKey:variant;vOption:variant='')


    Holds, presses, or releases a specific key.

    This method can repeatedly press a key, hold a key, release a key, or press a key once. vKey can be an integer key code or a name, such as enter.

    Example:
    Simba Code:
    (*
      The following presses enter three times
    *)


    keyboard.press('enter',3);

    (* ...delete once *)

    keyboard.press(46);

    (* ...holds the left arrow *)

    keyboard.press('left','down');

    (* ...releases the CTRL button *)

    keyboard.press('ctrl','up');

    Sending - tKeyboard.send(vString:string)


    Holds, presses, or releases a string of keys.

    This method functions like the press method, only it allows for multiple different keys and combinations.

    Example:
    Simba Code:
    (*
      The following sends:
      Hello world!
    *)


    keyboard.send('{shift down}h{shift up}e{l 2}o world{shift down}1{shift up}');

    (* ...CTRL-s *)

    keyboard.send('{ctrl down}s{ctrl up}');

    (* ...doubling {legit/trusted} *)

    keyboard.send('doubling \{legit/trusted\}');

    (* ...HELLO world *)

    keyboard.send('{shift down}hello{shift up} world');

    (* ...f3 (five times) *)

    keyboard.send('{f3 5}');

    (* ...world *)

    keyboard.send('hello {backspace 6}world');

    (* ...right arrow (and holds it) *)

    keyboard.send('{right down}');



    tKeyboard.state(vKey:variant)


    Returns the state, pressed or not, of a key.

    This method returns whether or not a key is held. vKey can be an integer key code or a name, such as enter.

    Example:
    Simba Code:
    (*
      The following writes:
      True
    *)


    keyboard.press('ctrl','down');
    writeLN(
      keyboard.state('ctrl')
    );
    keyboard.press('ctrl','up');



    Properties


    tKeyboard.speed


    This property controls the speed of the inputs and the delays between keys. I'd recommend setting speed to roughly 100.



    Attached Files Attached Files
    Last edited by Obscurity; 01-27-2016 at 01:19 AM.




    Skype: obscuritySRL@outlook.com

  2. #2
    Join Date
    Jan 2012
    Location
    East Coast
    Posts
    733
    Mentioned
    81 Post(s)
    Quoted
    364 Post(s)

    Default

    Awesome, as usual. Can't wait to use this! It will be extremely useful.

  3. #3
    Join Date
    May 2012
    Location
    USA
    Posts
    169
    Mentioned
    2 Post(s)
    Quoted
    64 Post(s)

    Default

    Know how to fix this?

    http://puu.sh/nd64f/8b323655e9.jpg

  4. #4
    Join Date
    Jun 2012
    Posts
    586
    Mentioned
    112 Post(s)
    Quoted
    296 Post(s)

    Default

    Quote Originally Posted by Threshold View Post
    What exactly are you trying to send? If you'd like, since it looks like a username, you can PM me.




    Skype: obscuritySRL@outlook.com

  5. #5
    Join Date
    Dec 2010
    Posts
    483
    Mentioned
    30 Post(s)
    Quoted
    328 Post(s)

    Default

    Haha this is really cool! Neat release man, specifically the way you allow regex-esque parameters in the string you pass. Nifty - repped!

  6. #6
    Join Date
    Sep 2008
    Location
    Not here.
    Posts
    5,422
    Mentioned
    13 Post(s)
    Quoted
    242 Post(s)

    Default

    You should nix the string parsing for some constants. Much cleaner and easier to grok.

  7. #7
    Join Date
    Jun 2012
    Posts
    586
    Mentioned
    112 Post(s)
    Quoted
    296 Post(s)

    Default

    Quote Originally Posted by Threshold View Post
    https://github.com/Elfyyy/OSR-Reflection/pull/99

    Should be fixed shortly - as soon as Kyle updates.

    The issue was caused any time GetKeyCode was called after setEIOSTarget(). My solution was a bit... Hackish... But it works. Changed:
    Simba Code:
    Exit(GetKeyCode(Key[1]));
    To:
    Simba Code:
    SetKeyMouseTarget(0);
        Result := GetKeyCode(Key[1]);
        if Reflect.Smart.PID then
          SetEIOSTarget('libsmartremote', ToStr(Reflect.Smart.PID));
        Exit(Result);




    Skype: obscuritySRL@outlook.com

  8. #8
    Join Date
    May 2012
    Location
    USA
    Posts
    169
    Mentioned
    2 Post(s)
    Quoted
    64 Post(s)

    Default

    Quote Originally Posted by Obscurity View Post
    https://github.com/Elfyyy/OSR-Reflection/pull/99

    Should be fixed shortly - as soon as Kyle updates.

    The issue was caused any time GetKeyCode was called after setEIOSTarget(). My solution was a bit... Hackish... But it works. Changed:
    Simba Code:
    Exit(GetKeyCode(Key[1]));
    To:
    Simba Code:
    SetKeyMouseTarget(0);
        Result := GetKeyCode(Key[1]);
        if Reflect.Smart.PID then
          SetEIOSTarget('libsmartremote', ToStr(Reflect.Smart.PID));
        Exit(Result);
    +rep way to go

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •