|
|
Line 1: |
Line 1: |
− | IJWTS wow! Why can't I think of thigns like that?
| + | Please keep thrwonig these posts up they help tons. |
− | | |
− | == keyboardHold ==
| |
− | '''keyboardHold(key)'''
| |
− | | |
− | Holds the specified key until it is pressed or released (either physically, or virtually). See [[Virtual Keys]] for more information.
| |
− | | |
− | If you are running input in attached mode (through use of [[Process_Functions#attach|attach]]()) it will only send input to the target window, and will not interfere if you decide to switch windows.
| |
− | | |
− | If the target program does not appear to be picking up input through the use of this function, you might try calling [[Keyboard_Control#keyboardSetDelay|keyboardSetDelay]]() somewhere in your script to increase the delay.
| |
− | | |
− | | |
− | '''Example'''
| |
− | <source lang="lua">
| |
− | keyboardHold( key.VK_A ); -- The A key will be held down
| |
− | yrest(50);
| |
− | keyboardRelease( key.VK_A ); -- The A key is now released
| |
− | </source>
| |
− | | |
− | | |
− | This artclie keeps it real, no doubt.
| |
− | | |
− | == keyPressed ==
| |
− | '''int keyPressed(key)'''
| |
− | | |
− | Checks if a key is being held down or pressed. Returns a boolean: true if held/pressed, otherwise returns false. See [[Virtual Keys]] for more information.
| |
− | | |
− | The check for this is done globally, meaning that you do not need to have the calling MicroMacro window, or it's attached window, focused for a keypress to register. If you only want to gather input from MicroMacro or it's attached window, use [[Keyboard_Control#keyPressedLocal|keyPressedLocal]]() instead.
| |
− | | |
− | | |
− | '''Example'''
| |
− | <source lang="lua">
| |
− | if( keyPressed( key.VK_A ) ) then
| |
− | -- A is pressed. Do something!
| |
− | end
| |
− | </source>
| |
− | | |
− | == keyPressedLocal ==
| |
− | '''int keyPressedLocal(key)'''
| |
− | | |
− | Checks if a key is being held down or pressed. Returns a boolean: true if held/pressed, otherwise returns false. See [[Virtual Keys]] for more information.
| |
− | | |
− | The check for this is done locally, meaning that you must have the calling MicroMacro window, or it's attached window, focused for a keypress to register. If you want to gather input globally, use [[Keyboard_Control#keyPressed|keyPressed]]() instead.
| |
− | | |
− | | |
− | '''Example'''
| |
− | <source lang="lua">
| |
− | if( keyPressedLocal( key.VK_A ) ) then
| |
− | -- A is pressed. Do something!
| |
− | end
| |
− | </source>
| |
− | | |
− | No question this is the place to get this info, thnkas y'all.
| |
− | | |
− | == keyboardSetDelay ==
| |
− | '''keyboardSetDelay(time)'''
| |
− | | |
− | Sets the automatic delay between key presses and releases for functions like [[Keyboard_Control#keyboardType|keyboardType]]() or [[Keyboard_Control#keyboardPress|keyboardPress]](). 'time' is specified in miliseconds. If the target program does not appear to be picking up input well using the current delay, use this function to increase it and give the target program more time to detect the press/release. Note that it will then take longer to process the key press if you increase the delay.
| |
− | | |
− | The default keyboard delay is 50ms.
| |
− | | |
− | | |
− | '''Example'''
| |
− | <source lang="lua">
| |
− | keyboardSetDelay(100);
| |
− | keyboardType("This is an example! ;)");
| |
− | -- This will output the string with 100ms delay between each character
| |
− | </source>
| |
− | | |
− | == getKeyName ==
| |
− | '''string getKeyName(key)'''
| |
− | | |
− | Returns the symbolic name for the key specified. That is, passing key.VK_SPACE to getKeyName() will result in the function returning "SPACE". This function is affected by your computer's language settings.
| |
− | | |
− | | |
− | '''Example'''
| |
− | <source lang="lua">
| |
− | printf("Keyname: %s\n", getKeyName(key.VK_SPACE));
| |
− | </source>
| |
− | | |
− | == keyboardBufferClear ==
| |
− | '''keyboardBufferClear()'''
| |
− | | |
− | Flushes any remaining characters left in the keyboard buffer. You typically would do this only before reading information from the standard input stream.
| |
− | | |
− | | |
− | '''Example'''
| |
− | <source lang="lua">
| |
− | keyboardBufferClear(); -- clear keyboard buffer
| |
− | io.stdin:flush(); -- clear standard input buffer
| |
− | | |
− | -- everything is clean, now time to read input.
| |
− | printf("Please enter your name: ");
| |
− | local name = io.stdin:read();
| |
− | | |
− | printf("\n\nYour name is %s\n", name);
| |
− | </source>
| |