package ResoluçõesGo;
import bomberclickv2.MainMenu;
import java.awt.AWTException;
import java.awt.Robot;
import java.awt.event.InputEvent;
import java.util.logging.Level;
import java.util.logging.Logger;
public class Executar1080 implements Runnable {
public static void main(String[] args) {
}
public void start() {
MainMenu menu = new MainMenu ();
//CONDIÇÕES DE FUNCIONAMENTO
try {
Robot robo = new Robot();
//tempo do click
String delayClick = menu.delayClick.getSelectedItem().toString();
int convertClick = Integer.parseInt(menu.delayClick.getSelectedItem().toString());
robo.setAutoDelay(convertClick);
int mimir = 78000 ;
//tempo do descanso
String tempoDescanso = menu.tempoDescanso.getSelectedItem().toString();
int convertDescanso = Integer.parseInt(menu.tempoDescanso.getSelectedItem().toString());
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
//INICIAR 1080p
if (menu.janela1080p.isSelected()){
for (;;) {
//TRABALHAR
robo.mouseMove(1800,950);
robo.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robo.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
robo.mouseMove(680, 280);
robo.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robo.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
robo.mouseMove(980, 180);
robo.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robo.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
robo.mouseMove(980, 380);
robo.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robo.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
Thread.sleep(10000);
//USUARIO SELECECIONA TEMPO
for(int x = 1; x <= convertDescanso ; ++x){
robo.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robo.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
//CLICK DESCONECT
for (int Y =0; Y <=1; ++Y ){
//FASE1
robo.mouseMove(900, 730);
robo.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robo.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
//FASE2
robo.mouseMove(900, 890);
robo.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robo.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
//FASE3
robo.mouseMove(1840, 540);
robo.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robo.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
//FASE4
robo.mouseMove(980, 380);
robo.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robo.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
}
//DESCANCO 1 MINUTOS
robo.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robo.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
Thread.sleep(mimir);
//ANTIDESCONECT
//SAI
robo.mouseMove(40, 60);
robo.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robo.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
//ENTRA
robo.mouseMove(980, 380);
robo.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robo.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
Thread.sleep(10000 );
//SAI
robo.mouseMove(40, 60);
robo.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robo.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
//ENTRA
robo.mouseMove(980, 380);
robo.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robo.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
//FASE1
robo.mouseMove(900, 730);
robo.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robo.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
//FASE2
robo.mouseMove(900, 890);
robo.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robo.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
//FASE3
robo.mouseMove(1840, 540);
robo.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robo.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
//FASE4
robo.mouseMove(980, 380);
robo.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robo.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
}
// voltar menu principal
robo.mouseMove(40, 60);
robo.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robo.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
}
}
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
} catch (InterruptedException ex) {
Logger.getLogger(Executar1080.class.getName()).log(Level.SEVERE, null, ex);
} catch (AWTException ex) {
Logger.getLogger(Executar1080.class.getName()).log(Level.SEVERE, null, ex);
}
}
@Override
public void run() {
throw new UnsupportedOperationException("Not supported yet.");
}
}
me ajuda pls kkk :l
O problema é que no seu método main
você está criando um MainMenu
e na classe Executar1080
está criando um novo MainMenu
ao invés de utilizar o mesmo que você criou no método main
.
Entendi, como eu faço para ao inves de criar um novo, utilizar o mesmo que eu já criei ?
e que eu preciso puxar os metodos dos botões para a classe Executar1080 para funcionar.
consegue me ajudar ?
realmente deve ser isso, pois se eu utilizar println com loop de contagem, ele funciona.
Mas eu tenho que chamar os metodos dos botões que está na classe principal (MainMenu) , para fazer funcionar e deixar em classses separadas
Pois na interface grafica tem as opções de escolher o tempo do delay do click e o tempo para reinciar o loop ( que é feito com a quantidade de repetições ) ex descanso dos bombers > 6 = 45 min. ele vai repetir o loop 6 vezes e vai reinciar o loop novamente.
por isso eu tenho que chamar a class MainMenu para a Executar1080p.
se não ele não vai pegar o valor dos botões.
Passa o objeto do MainMenu
como parâmetro na criação do objeto da classe Executar1080
, dessa forma:
import bomberclickv2.MainMenu;
import java.awt.AWTException;
import java.awt.Robot;
import java.awt.event.InputEvent;
import java.util.logging.Level;
import java.util.logging.Logger;
public class Executar1080 implements Runnable {
private final MainMenu menu;
public Executar1080(MainMenu menu) {
this.menu = menu;
}
public void start() {
//CONDIÇÕES DE FUNCIONAMENTO
try {
Robot robo = new Robot();
//tempo do click
String delayClick = menu.delayClick.getSelectedItem().toString();
int convertClick = Integer.parseInt(menu.delayClick.getSelectedItem().toString());
robo.setAutoDelay(convertClick);
int mimir = 78000 ;
//tempo do descanso
String tempoDescanso = menu.tempoDescanso.getSelectedItem().toString();
int convertDescanso = Integer.parseInt(menu.tempoDescanso.getSelectedItem().toString());
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
//INICIAR 1080p
if (menu.janela1080p.isSelected()){
for (;;) {
//TRABALHAR
robo.mouseMove(1800,950);
robo.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robo.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
robo.mouseMove(680, 280);
robo.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robo.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
robo.mouseMove(980, 180);
robo.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robo.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
robo.mouseMove(980, 380);
robo.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robo.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
Thread.sleep(10000);
//USUARIO SELECECIONA TEMPO
for(int x = 1; x <= convertDescanso ; ++x){
robo.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robo.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
//CLICK DESCONECT
for (int Y =0; Y <=1; ++Y ){
//FASE1
robo.mouseMove(900, 730);
robo.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robo.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
//FASE2
robo.mouseMove(900, 890);
robo.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robo.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
//FASE3
robo.mouseMove(1840, 540);
robo.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robo.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
//FASE4
robo.mouseMove(980, 380);
robo.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robo.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
}
//DESCANCO 1 MINUTOS
robo.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robo.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
Thread.sleep(mimir);
//ANTIDESCONECT
//SAI
robo.mouseMove(40, 60);
robo.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robo.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
//ENTRA
robo.mouseMove(980, 380);
robo.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robo.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
Thread.sleep(10000 );
//SAI
robo.mouseMove(40, 60);
robo.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robo.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
//ENTRA
robo.mouseMove(980, 380);
robo.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robo.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
//FASE1
robo.mouseMove(900, 730);
robo.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robo.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
//FASE2
robo.mouseMove(900, 890);
robo.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robo.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
//FASE3
robo.mouseMove(1840, 540);
robo.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robo.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
//FASE4
robo.mouseMove(980, 380);
robo.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robo.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
}
// voltar menu principal
robo.mouseMove(40, 60);
robo.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robo.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
}
}
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
} catch (InterruptedException ex) {
Logger.getLogger(Executar1080.class.getName()).log(Level.SEVERE, null, ex);
} catch (AWTException ex) {
Logger.getLogger(Executar1080.class.getName()).log(Level.SEVERE, null, ex);
}
}
@Override
public void run() {
throw new UnsupportedOperationException("Not supported yet.");
}
}
Aí é só criar a Thread assim:
private void iniciarActionPerformed(java.awt.event.ActionEvent evt) {
Runnable runnable = new new Executar1080(this);
Thread thread = new Thread(runnable);
thread.start();
}
agora deu uma exeption
Exception in thread "Thread-0" java.lang.UnsupportedOperationException: Not supported yet.
at ResoluçõesGo.Executar1080.run(Executar1080.java:156)
at java.base/java.lang.Thread.run(Thread.java:833)
Pôxa amiguinho, você implementou a classe Executar1080
pra lançar essa exceção e agora não sabe o que está acontecendo?
@Override
public void run() {
throw new UnsupportedOperationException("Not supported yet.");
}
🤷🏻