package com.company.Iguana;
import java.awt.*;
import java.awt.AWTException;
import java.awt.Color;
import java.awt.Robot;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.io.IOException;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.Timer;
import java.awt.event.KeyEvent;
public class Main {
public static boolean Clicking = true;
public static Robot robot;
public static void main(String[] args) throws AWTException {
Robot robot = new Robot();
new KeyListener() {
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
if(e.getKeyChar() == 'x')
Clicking = true;
if(e.getKeyChar() == 'v')
Clicking = false;
if(Clicking == true)
while(true){
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robot.delay(1000);
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
}
}
@Override
public void keyReleased(KeyEvent e) {
}
};
}
}
我试着让它这样每当我按下x自动点击启动和停止它当我按下v,但一旦我运行代码,它只是说公共静态void主要(字符串[]args),但当我把静态它说23:9 java:非静态变量,这不能从一个静态上下文引用行23:9是this.addkeylistener(新keylistener(){
..................................................................................................................................................................................................................
暂无答案!
目前还没有任何答案,快来回答吧!