-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathWhatsappAutoMessenger.java
50 lines (38 loc) · 1.23 KB
/
WhatsappAutoMessenger.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/**
* @author Varun Kumar <varunon9@gmail.com>
*/
/**
* Execute this script from terminal. After 5 seconds, message will start getting typed and sent.
* You can see message being typed and sent on terminal. To send it to your friend on whatsapp web, just
* click on inputDiv (div for typing message on whatsapp web).
*/
import java.util.*;
public class WhatsappAutoMessenger {
public static void main(String args[]) {
// define your messages here
String wishes[] = {
"Happy bday",
"happy again!!",
"Happy bday last time :p"
};
MouseKeyboardControl mouseKeyboardControl = new MouseKeyboardControl();
Timer timer = new Timer();
final int length = wishes.length;
timer.scheduleAtFixedRate(new TimerTask() {
int index = 0;
public void run() {
String wish = wishes[index++];
// type ecah character of wish message
for (int i = 0; i < wish.length(); i++) {
mouseKeyboardControl.typeCharacter(wish.charAt(i));
}
// simulate enter key to send message
mouseKeyboardControl.typeCharacter('\n');
// we want to restart if all wishes have been sent
if (index == length) {
index = 0;
}
}
}, 5000, 5000); // 5000ms delay and 5000ms repeat period
}
}