我每週在網上查看我的成績,以便上學。然後,我使用打印屏幕和ms繪畫來保存我的成績與網站的圖像。 (我知道這是真的費時又低效的,但我的電腦有連接問題,我的打印機,它不承認任何PDF製造商)
可能的解決方案:
寫一些程序或一些自動:
- 打開瀏覽器
- 轉到網站
- 日誌中
- 打開每個個體對象
- 創建映像(IDC它採用這樣做哪些進程)
感謝E'rybody
我每週在網上查看我的成績,以便上學。然後,我使用打印屏幕和ms繪畫來保存我的成績與網站的圖像。 (我知道這是真的費時又低效的,但我的電腦有連接問題,我的打印機,它不承認任何PDF製造商)
可能的解決方案:
寫一些程序或一些自動:
感謝E'rybody
不要使用瀏覽器。在Perl中發送Http請求或類似的東西。
您可以簡單地解析HTML而不是抓取屏幕截圖。
或者要求學校通過電子郵件或bloddy紙張提供您的成績?
個人而言,我會跟去捲曲在命令行,然後解析HTML你回來:
curl http://website.com/grades
但是,如果你需要通過Web瀏覽器來做到這一點(他們可能有一些時髦的javascript )那麼有一個叫selenium的框架可能是可用的:http://seleniumhq.org/
它通常用於測試,但可以用於您的方案。它也有很多不同語言的客戶。
您可以在java.awt中使用Robot類編寫一個簡單的java程序。這很簡單。由於電腦前有人,因此可以自動執行所有操作。可能需要一點點努力。但相信我,你可以完美地解決你的問題。
如果您對此有任何疑問,請隨時與我聯繫。我會幫忙的。
試試這個。這有點長。但它會告訴你機器人課程的能力。你可以通過在'go()'方法中調用它們來嘗試所有的方法。如果你有更多的耐心嘗試一下,你就可以像操作人員一樣自動完成鼠標和鍵盤操作。
這個類是爲更高級的功能而編寫的(當然,只是爲了好玩)。所以,你不需要這些先進的方法。你可以通過他們的名字來理解。
請注意,我發佈的是我寫的原始課程(sumudu lansakara或Codenamed_SC)。我沒有根據你的要求修改它,或者使它看起來很簡單。你可以自己做那部分。 (但是我認爲完整的代碼將是有用的,現在或以後)。
import java.awt.Color;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.HashMap;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
public class MyRobot {
Robot MYROBOT;
Color SCREEN[][];
int SCREEN_X;
int SCREEN_Y;
int WINDOW_X;
int WINDOW_Y;
int TYPE_DELAY = 0;
int MOUSE_DELAY = 0;
int SKILL = 0;
int X, Y;
int lastX, lastY;
int savedX, savedY;
int RED, GREEN, BLUE;
Color PIX_CLOSE_ACTIVE_OFF_MOUSE;
Color PIX_CLOSE_ACTIVE_ON_MOUSE;
HashMap<Character, Integer> KEYMAP;
ArrayList<Integer> randKeys;
GraphicsEnvironment grEnv;
GraphicsDevice grDevice;
JPanel drawPanel;
BufferedImage bufImg;
Rectangle rect;
public static void main(String[] args) {
new MyRobot().go();
}
void go() {
initialize();
gotoxy(100, 100);
}
void initialize() {
grEnv = GraphicsEnvironment.getLocalGraphicsEnvironment();
grDevice = grEnv.getDefaultScreenDevice();
updateScreenInfo();
setKeyMap();
try {
MYROBOT = new Robot();
} catch (Exception e) {
JOptionPane.showOptionDialog(null, "Can't build the robot!", "Error", -1, 1, null, null, this);
System.exit(1);
}
X = SCREEN_X/2;
Y = SCREEN_Y/2;
//MYROBOT.mouseMove(X, Y);
PIX_CLOSE_ACTIVE_OFF_MOUSE = new Color(184, 67, 44);
PIX_CLOSE_ACTIVE_ON_MOUSE = new Color(210, 35, 2);
}
void updateScreenInfo() {
SCREEN_X = grDevice.getDisplayMode().getWidth();
SCREEN_Y = grDevice.getDisplayMode().getHeight();
WINDOW_X = grEnv.getMaximumWindowBounds().width;
WINDOW_Y = grEnv.getMaximumWindowBounds().height;
}
void setKeyMap() {
KEYMAP = new HashMap<Character, Integer>();
KEYMAP.put('q', 81);
KEYMAP.put('w', 87);
KEYMAP.put('e', 69);
KEYMAP.put('r', 82);
KEYMAP.put('t', 84);
KEYMAP.put('y', 89);
KEYMAP.put('u', 85);
KEYMAP.put('i', 73);
KEYMAP.put('o', 79);
KEYMAP.put('p', 80);
KEYMAP.put('a', 65);
KEYMAP.put('s', 83);
KEYMAP.put('d', 68);
KEYMAP.put('f', 70);
KEYMAP.put('g', 71);
KEYMAP.put('h', 72);
KEYMAP.put('j', 74);
KEYMAP.put('k', 75);
KEYMAP.put('l', 76);
KEYMAP.put('z', 90);
KEYMAP.put('x', 88);
KEYMAP.put('c', 67);
KEYMAP.put('v', 86);
KEYMAP.put('b', 66);
KEYMAP.put('n', 78);
KEYMAP.put('m', 77);
KEYMAP.put('1', 49);
KEYMAP.put('2', 50);
KEYMAP.put('3', 51);
KEYMAP.put('4', 52);
KEYMAP.put('5', 53);
KEYMAP.put('6', 54);
KEYMAP.put('7', 55);
KEYMAP.put('8', 56);
KEYMAP.put('9', 57);
KEYMAP.put('0', 48);
KEYMAP.put(' ', 32);
randKeys = new ArrayList<Integer>();
for (int j = 44; j < 94; j++) {
randKeys.add(j);
}
randKeys.remove(randKeys.indexOf(58));
randKeys.remove(randKeys.indexOf(60));
randKeys.remove(randKeys.indexOf(62));
randKeys.remove(randKeys.indexOf(63));
randKeys.remove(randKeys.indexOf(64));
}
void typeHuman(String letters) {
MYROBOT.setAutoDelay(TYPE_DELAY);
char[] letter = letters.toCharArray();
for (int i = 0; i < letter.length; i++) {
System.out.print(letter[i]);
try {
if ((int) (Math.random() * SKILL) == (int) (Math.random() * SKILL)/2) {
int limit = (int) ((Math.random() * 3) + 1);
for (int j = 0; j < limit; j++) {
int k = (int) (Math.random() * (randKeys.size() - 1));
manuPress(randKeys.get(k));
}
sleep(200);
for (int j = 0; j < limit; j++) {
backspace();
}
}
if ((Character.isLowerCase(letter[i])) || (Character.isDigit(letter[i]))) {
MYROBOT.keyPress(KEYMAP.get(letter[i]));
MYROBOT.keyRelease(KEYMAP.get(letter[i]));
} else {
letter[i] = Character.toLowerCase(letter[i]);
MYROBOT.keyPress(16);
MYROBOT.keyPress(KEYMAP.get(letter[i]));
MYROBOT.keyRelease(KEYMAP.get(letter[i]));
MYROBOT.keyRelease(16);
}
} catch (Exception e) {
switch (letter[i]) {
case '!': {
manuPressSHIFTED(49);
break;
}
case '@': {
manuPressSHIFTED(50);
break;
}
case '#': {
manuPressSHIFTED(51);
break;
}
case '$': {
manuPressSHIFTED(52);
break;
}
case '%': {
manuPressSHIFTED(53);
break;
}
case '^': {
manuPressSHIFTED(54);
break;
}
case '&': {
manuPressSHIFTED(55);
break;
}
case '*': {
manuPressSHIFTED(56);
break;
}
case '(': {
manuPressSHIFTED(57);
break;
}
case ')': {
manuPressSHIFTED(48);
break;
}
case '?': {
manuPressSHIFTED(47);
break;
}
case '/': {
manuPress(47);
break;
}
case ':': {
manuPressSHIFTED(59);
break;
}
case ';': {
manuPress(59);
break;
}
case '.': {
manuPress(46);
break;
}
case ',': {
manuPress(44);
break;
}
case '"': {
manuPressSHIFTED(222);
break;
}
case '\'': {
manuPress(222);
break;
}
case '[': {
manuPress(91);
break;
}
case ']': {
manuPress(93);
break;
}
case '{': {
manuPressSHIFTED(91);
break;
}
case '}': {
manuPressSHIFTED(93);
break;
}
case '\\': {
manuPress(92);
break;
}
case '|': {
manuPressSHIFTED(92);
break;
}
case '=': {
manuPressSHIFTED(61);
break;
}
case '+': {
manuPressSHIFTED(61);
break;
}
case '-': {
manuPress(45);
break;
}
case '_': {
manuPressSHIFTED(45);
break;
}
case '`': {
manuPress(192);
break;
}
case '~': {
manuPressSHIFTED(192);
break;
}
case '<': {
manuPressSHIFTED(44);
break;
}
case '>': {
manuPressSHIFTED(46);
break;
}
}
}
}
System.out.println("");
}
void type(String letters) {
MYROBOT.setAutoDelay(TYPE_DELAY);
char[] letter = letters.toCharArray();
for (int i = 0; i < letter.length; i++) {
System.out.print(letter[i]);
try {
if ((Character.isLowerCase(letter[i])) || (Character.isDigit(letter[i]))) {
MYROBOT.keyPress(KEYMAP.get(letter[i]));
MYROBOT.keyRelease(KEYMAP.get(letter[i]));
} else {
letter[i] = Character.toLowerCase(letter[i]);
MYROBOT.keyPress(16);
MYROBOT.keyPress(KEYMAP.get(letter[i]));
MYROBOT.keyRelease(KEYMAP.get(letter[i]));
MYROBOT.keyRelease(16);
}
} catch (Exception e) {
switch (letter[i]) {
case '!': {
manuPressSHIFTED(49);
break;
}
case '@': {
manuPressSHIFTED(50);
break;
}
case '#': {
manuPressSHIFTED(51);
break;
}
case '$': {
manuPressSHIFTED(52);
break;
}
case '%': {
manuPressSHIFTED(53);
break;
}
case '^': {
manuPressSHIFTED(54);
break;
}
case '&': {
manuPressSHIFTED(55);
break;
}
case '*': {
manuPressSHIFTED(56);
break;
}
case '(': {
manuPressSHIFTED(57);
break;
}
case ')': {
manuPressSHIFTED(48);
break;
}
case '?': {
manuPressSHIFTED(47);
break;
}
case '/': {
manuPress(47);
break;
}
case ':': {
manuPressSHIFTED(59);
break;
}
case ';': {
manuPress(59);
break;
}
case '.': {
manuPress(46);
break;
}
case ',': {
manuPress(44);
break;
}
case '"': {
manuPressSHIFTED(222);
break;
}
case '\'': {
manuPress(222);
break;
}
case '[': {
manuPress(91);
break;
}
case ']': {
manuPress(93);
break;
}
case '{': {
manuPressSHIFTED(91);
break;
}
case '}': {
manuPressSHIFTED(93);
break;
}
case '\\': {
manuPress(92);
break;
}
case '|': {
manuPressSHIFTED(92);
break;
}
case '=': {
manuPressSHIFTED(61);
break;
}
case '+': {
manuPressSHIFTED(61);
break;
}
case '-': {
manuPress(45);
break;
}
case '_': {
manuPressSHIFTED(45);
break;
}
case '`': {
manuPress(192);
break;
}
case '~': {
manuPressSHIFTED(192);
break;
}
case '<': {
manuPressSHIFTED(44);
break;
}
case '>': {
manuPressSHIFTED(46);
break;
}
}
}
}
System.out.println("");
}
void typeln(String letters) {
type(letters);
enter();
}
void typelnHuman(String letters) {
typeHuman(letters);
enter();
}
void getRun() {
MYROBOT.keyPress(524);
MYROBOT.keyPress(82);
MYROBOT.keyRelease(82);
MYROBOT.keyRelease(524);
sleep(500);
}
void combinePress(int keyOne, int keyTwo) {
MYROBOT.keyPress(keyOne);
MYROBOT.keyPress(keyTwo);
MYROBOT.keyRelease(keyTwo);
MYROBOT.keyRelease(keyOne);
}
void combinePress(int keyOne, int keyTwo, int keyThree) {
MYROBOT.keyPress(keyOne);
MYROBOT.keyPress(keyTwo);
MYROBOT.keyPress(keyThree);
MYROBOT.keyRelease(keyThree);
MYROBOT.keyRelease(keyTwo);
MYROBOT.keyRelease(keyOne);
}
void altTab() {
MYROBOT.keyPress(18);
MYROBOT.keyPress(9);
MYROBOT.keyRelease(9);
MYROBOT.keyRelease(18);
}
void winD() {
MYROBOT.keyPress(524);
MYROBOT.keyPress(68);
MYROBOT.keyRelease(68);
MYROBOT.keyRelease(524);
}
void altF4() {
MYROBOT.keyPress(18);
MYROBOT.keyPress(115);
MYROBOT.keyRelease(115);
MYROBOT.keyRelease(18);
}
void enter() {
MYROBOT.keyPress(10);
MYROBOT.keyRelease(10);
}
void backspace() {
MYROBOT.keyPress(8);
MYROBOT.keyRelease(8);
}
void sleep(long duration) {
try {
Thread.sleep(duration);
} catch (Exception e) {
}
}
void click() {
MYROBOT.mousePress(16);
MYROBOT.mouseRelease(16);
}
void doubleClick() {
click();
click();
}
void clickNhold(boolean tof) {
if (tof) {
MYROBOT.mousePress(16);
} else {
MYROBOT.mouseRelease(16);
}
}
void rightClick() {
MYROBOT.mousePress(4);
MYROBOT.mouseRelease(4);
}
void rightclickHold(boolean tof) {
if (tof) {
MYROBOT.mousePress(4);
} else {
MYROBOT.mouseRelease(4);
}
}
void middleClick() {
MYROBOT.mousePress(8);
MYROBOT.mouseRelease(8);
}
void manuPress(int code) {
MYROBOT.keyRelease(16);
MYROBOT.keyPress(code);
MYROBOT.keyRelease(code);
}
void manuPressSHIFTED(int code) {
MYROBOT.keyPress(16);
MYROBOT.keyPress(code);
MYROBOT.keyRelease(code);
MYROBOT.keyRelease(16);
}
void gotoxy(int goX, int goY) {
lastX = X;
lastY = Y;
MYROBOT.setAutoDelay(MOUSE_DELAY);
int initX = X;
int initY = Y;
if (goX == X) {
if (goY > Y) {
for (int i = Y; i <= goY; i++) {
Y = i;
MYROBOT.mouseMove(X, Y);
}
} else {
for (int i = Y; i >= goY; i--) {
Y = i;
MYROBOT.mouseMove(X, Y);
}
}
} else if (goX > X) {
for (int i = 0; i <= (goX - initX); i++) {
X = initX + i;
Y = initY + ((i * (goY - initY))/(goX - initX));
MYROBOT.mouseMove(X, Y);
}
} else {
for (int i = 0; i >= (goX - initX); i--) {
X = initX + i;
Y = initY + ((i * (goY - initY))/(goX - initX));
MYROBOT.mouseMove(X, Y);
}
}
}
void getRGB(Color pixel) {
RED = pixel.getRed();
GREEN = pixel.getGreen();
BLUE = pixel.getBlue();
System.out.println(RED + "," + GREEN + "," + BLUE);
}
void savePoint() {
savedX = X;
savedY = Y;
}
void captureScreen() {
System.out.println("Capturing...");
SCREEN = new Color[SCREEN_X][SCREEN_Y];
for (int i = 0; i < SCREEN_X; i++) {
for (int j = 0; j < SCREEN_Y/2; j++) {
SCREEN[i][j] = MYROBOT.getPixelColor(i, j);
}
}
System.out.println("Capturing done");
}
void gotoPixel(Color pixel) {
if (MYROBOT.getPixelColor(X, Y).getRGB() != pixel.getRGB()) {
for (int i = SCREEN_X - 4; i >= 0; i--) {
for (int j = 3; j < SCREEN_Y/2; j++) {
if ((MYROBOT.getPixelColor(i, j).getRGB() == pixel.getRGB())) {
gotoxy(i, j);
i = -1;
break;
}
}
}
}
if (MYROBOT.getPixelColor(X, Y).getRGB() == pixel.getRGB()) {
while (MYROBOT.getPixelColor(X, Y).getRGB() == pixel.getRGB()) {
gotoxy((X - 1), Y);
}
}
}
void emergeFromPixel(Color pixel) {
if (MYROBOT.getPixelColor(X, Y).getRGB() != pixel.getRGB()) {
for (int i = SCREEN_X - 4; i >= 0; i--) {
for (int j = 3; j < SCREEN_Y/2; j++) {
if ((MYROBOT.getPixelColor(i, j).getRGB() == pixel.getRGB())) {
MYROBOT.mouseMove(i, j);
X = i;
Y = j;
i = -1;
break;
}
}
}
}
}
void shift(char dir) {
int initX = X;
Color initPixel;
dir = Character.toUpperCase(dir);
switch (dir) {
case 'L': {
gotoxy((X - 8), Y);
initPixel = MYROBOT.getPixelColor(X, Y);
while (MYROBOT.getPixelColor(X, Y).getRGB() == initPixel.getRGB()) {
gotoxy((X - 1), Y);
}
initX = X;
for (int i = initX; i > initX - 20; i--) {
if (MYROBOT.getPixelColor(i, Y).getRGB() == initPixel.getRGB()) {
gotoxy(i, Y);
while (MYROBOT.getPixelColor(X, Y).getRGB() == initPixel.getRGB()) {
gotoxy((X - 1), Y);
}
break;
}
}
break;
}
case 'R': {
initPixel = MYROBOT.getPixelColor(X, Y);
while (MYROBOT.getPixelColor(X, Y).getRGB() == initPixel.getRGB()) {
gotoxy((X + 1), Y);
}
initX = X;
for (int i = initX; i < initX + 20; i++) {
if (MYROBOT.getPixelColor(i, Y).getRGB() == initPixel.getRGB()) {
gotoxy(i, Y);
while (MYROBOT.getPixelColor(X, Y).getRGB() == initPixel.getRGB()) {
gotoxy((X + 1), Y);
}
break;
}
}
gotoxy((X + 8), Y);
break;
}
}
}
void emergeFromButton(String butName) {
int tempDelay = TYPE_DELAY;
TYPE_DELAY = 0;
MYROBOT.setAutoDelay(TYPE_DELAY);
butName = butName.toUpperCase();
if (butName.equals("CLOSE")) {
emergeFromPixel(PIX_CLOSE_ACTIVE_OFF_MOUSE);
} else if (butName.equals("MAXIMIZE")) {
emergeFromPixel(PIX_CLOSE_ACTIVE_OFF_MOUSE);
shift('L');
} else if (butName.equals("MINIMIZE")) {
emergeFromPixel(PIX_CLOSE_ACTIVE_OFF_MOUSE);
shift('L');
shift('L');
} else if (butName.equals("START")) {
MYROBOT.mouseMove(20, SCREEN_Y - 10);
}
TYPE_DELAY = tempDelay;
MYROBOT.setAutoDelay(TYPE_DELAY);
}
void gotoButton(String butName) {
butName = butName.toUpperCase();
if (butName.equals("CLOSE")) {
if (MYROBOT.getPixelColor(X, Y).getRGB() != PIX_CLOSE_ACTIVE_ON_MOUSE.getRGB()) {
gotoPixel(PIX_CLOSE_ACTIVE_OFF_MOUSE);
}
} else if (butName.equals("MAXIMIZE")) {
gotoPixel(PIX_CLOSE_ACTIVE_OFF_MOUSE);
shift('L');
} else if (butName.equals("MINIMIZE")) {
gotoPixel(PIX_CLOSE_ACTIVE_OFF_MOUSE);
shift('L');
shift('L');
} else if (butName.equals("START")) {
gotoxy(20, SCREEN_Y - 10);
}
}
void catchTitleBar() {
gotoButton("CLOSE");
gotoxy(X - 150, Y);
}
void pressKey(String keyName) {
keyName = keyName.toUpperCase();
if (keyName.equals("ESC")) {
manuPress(27);
}
}
void closeAllWindows() {
while ((MYROBOT.getPixelColor(65, SCREEN_Y - 35).getRed() > 213) && (MYROBOT.getPixelColor(65, SCREEN_Y - 35).getGreen() > 220) && (MYROBOT.getPixelColor(65, SCREEN_Y - 35).getBlue() > 228)) {
altTab();
gotoButton("CLOSE");
sleep(100);
click();
sleep(50);
}
}
void quickCloseAllWindows() {
while ((MYROBOT.getPixelColor(65, SCREEN_Y - 35).getRed() > 213) && (MYROBOT.getPixelColor(65, SCREEN_Y - 35).getGreen() > 220) && (MYROBOT.getPixelColor(65, SCREEN_Y - 35).getBlue() > 228)) {
winD();
sleep(100);
altTab();
altF4();
type("n");
}
}
void getNotepad() {
int saveDelay = TYPE_DELAY;
TYPE_DELAY = 0;
MYROBOT.setAutoDelay(0);
MYROBOT.keyPress(524);
MYROBOT.keyPress(82);
MYROBOT.keyRelease(82);
MYROBOT.keyRelease(524);
sleep(200);
typeln("notepad");
sleep(500);
TYPE_DELAY = saveDelay;
MYROBOT.setAutoDelay(TYPE_DELAY);
}
void closeActiveWindow() {
gotoButton("CLOSE");
click();
type("n");
}
void openMyComputer() {
gotoxy(50, 50);
doubleClick();
}
void lockMouse() {
Thread lockMouse = new Thread(new Runnable() {
@Override
public void run() {
while (true) {
MYROBOT.mouseMove(X, Y);
sleep(100);
}
}
});
lockMouse.start();
}
讓我知道你的進步。希望這有助於...