Created
April 27, 2021 10:35
-
-
Save smvd/6d3341fd323e4f11b861bfe5ccbf9121 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define WINVER 0x0500 // It needs to be windows 2000 or up | |
#include <windows.h> // Import windows standard header | |
#include <string.h> // Import header to work with words | |
#include <stdio.h> // Import input/output header | |
int main // Main function | |
( | |
int argc, // Variable to hold the ammount of arguments | |
char **argv // Variable to hold the arguments | |
) | |
{ | |
if (argc != 5) // If we dont have the correrct ammount of arguments | |
{ | |
fprintf(stderr, // Write to standard error | |
"\e[0;31m" // Color RED | |
"ERROR >> ARGUMENTS >> Expected 4 arguments, received %d\n" | |
"\e[0m", // Clear Color | |
argc - 1 // Replace %d with the ammount of arguments | |
); | |
exit(1); // End program | |
} | |
int ammount = atoi(argv[2]); // Variable to hold the ammount of messages to send | |
int sleep = atoi(argv[3]); // Variable to hold the delay between messages | |
char word[1000];; // Maka a variable to hold the word | |
strcpy(word, argv[1]); // Save the word in the variable | |
printf("\e[s"); // Save cursor posision | |
printf("Waiting..."); | |
Sleep(atoi(argv[4])); // Wait for the given milliseconds | |
printf("\e[u0/%d ",ammount); // Reset cursor and display 0/ammount | |
for ( // For loop | |
int a = 0; // Make a varaible a = 0 | |
a < ammount; // While a < ammount of messages | |
a++ // Add 1 to a | |
) | |
{ | |
int len = strlen(word); // Variable for word length | |
KEYBDINPUT ki; // Variable to store keyboard input | |
INPUT input; // Variable to store general input | |
for (int i = 0; i < len; i++) // Loop for each character in the word | |
{ | |
ki.wVk = 0; // Set the virtual key code to 0 | |
ki.wScan = word[i]; // Set the actual key code to the character | |
ki.dwFlags = KEYEVENTF_UNICODE; // Set the key type to unicode | |
ki.time = 0; // Set the time to 0 | |
ki.dwExtraInfo = 0; // Set the extra info to 0 | |
input.type = INPUT_KEYBOARD; // Set the input type to keyboard | |
input.ki = ki; // Set the keyboard input to ki | |
SendInput(1, &input, sizeof(INPUT));// Send the input | |
} | |
ki.wVk = 13; // Set the virtual key code to 13 (ENTER) | |
ki.dwFlags = KEYEVENTF_UNICODE; // Set the key type to unicode | |
ki.time = 0; // Set the time to 0 | |
ki.dwExtraInfo = 0; // Set the extra info to 0 | |
input.type = INPUT_KEYBOARD; // Set the input type to keyboard | |
input.ki = ki; // Set the keyboard input to ki | |
SendInput(1, &input, sizeof(INPUT)); // Send the input | |
printf("\e[u%d/%d",a,ammount); // Reset cursor and display current count | |
Sleep(sleep); // Wait for the given delay | |
} | |
printf("\e[u%d/%d",ammount,ammount); // Display the complete ammount | |
printf("\e[uDone... \n"); // Display that its done | |
return 0; // Exit normaly | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment