Windowは指定されたQQクライアントウィンドウにメッセージを送信する
3896 ワード
キーボード上の0~9のASCII
キーボード上A~ZのASCII
メッセージ送信ロジックの実装
public static final int VK_0 = 0x30;
public static final int VK_1 = 0x31;
public static final int VK_2 = 0x32;
public static final int VK_3 = 0x33;
public static final int VK_4 = 0x34;
public static final int VK_5 = 0x35;
public static final int VK_6 = 0x36;
public static final int VK_7 = 0x37;
public static final int VK_8 = 0x38;
public static final int VK_9 = 0x39;
キーボード上A~ZのASCII
public static final int VK_A = 0x41;
public static final int VK_B = 0x42;
public static final int VK_C = 0x43;
public static final int VK_D = 0x44;
public static final int VK_E = 0x45;
public static final int VK_F = 0x46;
public static final int VK_G = 0x47;
public static final int VK_H = 0x48;
public static final int VK_I = 0x49;
public static final int VK_J = 0x4A;
public static final int VK_K = 0x4B;
public static final int VK_L = 0x4C;
public static final int VK_M = 0x4D;
public static final int VK_N = 0x4E;
public static final int VK_O = 0x4F;
public static final int VK_P = 0x50;
public static final int VK_Q = 0x51;
public static final int VK_R = 0x52;
public static final int VK_S = 0x53;
public static final int VK_T = 0x54;
public static final int VK_U = 0x55;
public static final int VK_V = 0x56;
public static final int VK_W = 0x57;
public static final int VK_X = 0x58;
public static final int VK_Y = 0x59;
public static final int VK_Z = 0x5A;
メッセージ送信ロジックの実装
public class SendQQMessage {
public void sendQQMessage(Robot robot, Clipboard clipboard,String QQ, String message) throws Exception {
// :tencent://Message/?Uin=919433667&websiteName=www.oicqzone.com&Menu=yes
// :tencent://AddContact/fromId=45&fromSubId=1&subcmd=all&uin=574201314&fuin=919433667&website=www.oicqzone.com
// String url = "http://wpa.qq.com/msgrd?v=3&uin=\""+QQ+"\"&site=qq&menu=yes";
String url = "tencent://message/?uin=" + QQ + "&Site=null&Menu=yes";// QQ
String cmd = "explorer \"" + url + "\"";
Process process = null;
try {
process = Runtime.getRuntime().exec(cmd);
//
int i = process.waitFor();
// 2
// 1.5 , ,
// 50
robot.delay(1500);
//
clipboard.setContents(new StringSelection(message), null);
// ctrl+v,
robot.keyPress(KeyEvent.VK_CONTROL);
robot.keyPress(KeyEvent.VK_V);
// ctrl , ctrl, , , , 。crtl ,
// , ctrl 。
robot.keyRelease(KeyEvent.VK_CONTROL);
// 0.5 , ,
robot.delay(500);
robot.keyPress(KeyEvent.VK_ENTER);//
} catch (IOException e) {
System.out.println(" ");
} finally {
assert process != null;
process.getErrorStream().close();
process.getInputStream().close();
process.getOutputStream().close();
}
}
}