AzgarD Posted August 25, 2017 Share Posted August 25, 2017 (edited) Hello guys. So, i'm trying to automate a system that is running in HostExplorer emulator. Well, i did that, but i have a problem with a key spam. I have created some days ago a Topic with the intention to solve that problem, you can see here Sleep function problem. Anyway, the topic goes sideways, because in some point we are talking about other not related solutions. So, this new topic i'll bring the subject back. As you can see in my code, in some point of the script i need to fast spam the "F4", and that has to be extremelly fast. That have to keep going untill the screen changes. I'm using a simple double clicking and copy to compare with a pre defined String. Well that works, but the problem is that taking a lot of time because of the double clicking. If take off the Sleep function off the ApertaF4 function the script don't works properly as you can imagine, because he sends "F4" before the double clicking is ended. In other hand, adding the Sleep function delays much more the script. As i sayed in the ther topic, the compare strings condition has to break ASAP after it comes false. Anyway, i need help with something that can detect a change in the screen or something like that and say to AutoIt "continue the script". PS.: I like to thank water for the help in the other topic, and the others to. expandcollapse popup#include <MsgBoxConstants.au3> #include <GUIConstantsEx.au3> #include <AutoItConstants.au3> #include <StringConstants.au3> #include <ComboConstants.au3> Global $gui = GUICreate("MONSTRA v1.1", 300, 300) Global $sigla = GUICtrlCreateInput("Sigla ", 10, 10, 80, 20) Global $terminal = GUICtrlCreateInput("Terminal ", 10, 40, 120, 20) Global $button = GUICtrlCreateButton("OK", 100, 80, 100, 40) Global $Velox = GUICtrlCreateCombo("Velocidade", 160, 40, 120, 20, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) Global $iDesktopWidth = @DesktopWidth Global $iDesktopHeight = @DesktopHeight Global $mouseX = "" Global $mouseY = "" GUICtrlSetData(-1, "300K|600K|1MB|2MB|5MB|10MB|15MB|20MB|25MB|35MB") Global $dicas = GUICtrlCreateLabel ( "DICAS: ", 10, 150, 120, 20) Global $dica1 = GUICtrlCreateLabel ( " - Abra o comando CA no STC ", 10, 170, 300, 20) Global $dica2 = GUICtrlCreateLabel ( " - Ao clicar no botão OK não movimente mais ou mouse ", 10, 190, 300, 30) Global $dica3 = GUICtrlCreateLabel ( " - A qualquer momento pressione a tecla ESC para parar a Macro ", 10, 210, 300, 30) Global $dica4 = GUICtrlCreateLabel ( " - Para melhor funcionamento, deixe apenas um STC aberto ", 10, 240, 300, 30) HotKeySet("{ESC}", "ExitProg") Func ExitProg() Exit EndFunc ;==>ExitProg Resolucao() Terminal() Func Terminal() GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $button GUISetState(@SW_HIDE) RodarMacro() EndSelect WEnd EndFunc ;==>Terminal Func RodarMacro() WinActivate("1 - STC (10.31.9.100)") WinSetState("1 - STC (10.31.9.100)", "", @SW_MAXIMIZE) Send("{F4}") Send("x") Send("{ENTER}") Send("n") Send("{ENTER}") Sleep (1000) Send(GUICtrlRead($sigla)) Send("{ENTER}") Send(GUICtrlRead($terminal)) Sleep (1000) ApertaF4() EndFunc ;==>RodarMacro Func ApertaF4() Send("{F4}") MouseClick($MOUSE_CLICK_LEFT, $mouseX, $mouseY, 2, 1) ;usar $mouseX e $mouseY Send("^c") $copia = "Sigla" While StringRegExp ( $copia, "Sigla" ) = True Sleep (500) Send("{F4}") MouseClick($MOUSE_CLICK_LEFT, $mouseX, $mouseY, 2, 1) ;usar $mouseX e $mouseY Send("^c") $copia = ClipGet() WEnd VelocidadesVelox() EndFunc ;==>ApertaF4 Func VelocidadesVelox() Send("{T}") Send("{TAB}") Send("T") Send("{TAB}") Send("{TAB}") Send("T") Send("{F4}") Send("X") Send("{F4}") ;While 1 ;$nMsg = GUIGetMsg() ; Switch $nMsg ; Case $GUI_EVENT_CLOSE ; Exit ; Case $Velox If GUICtrlRead($Velox) = "300K" Then Send("{TAB}") Send("X") Send("{F4}") Send("{TAB}") Send("X") Send("{F4}") EndIf If GUICtrlRead($Velox) = "600K" Then Send("{TAB}") Send("X") Send("{F4}") Send("{TAB}") Send("{TAB}") Send("X") Send("{F4}") EndIf If GUICtrlRead($Velox) = "1MB" Then Send("{TAB}") Send("X") Send("{F4}") Send("X") Send("{F4}") EndIf If GUICtrlRead($Velox) = "2MB" Then Send("X") Send("{F4}") Send("{F8}") Send("{TAB}") Send("X") Send("{F4}") EndIf If GUICtrlRead($Velox) = "5MB" Then Send("X") Send("{F4}") Send("{F8}") Send("{F8}") Send("X") Send("{F4}") EndIf If GUICtrlRead($Velox) = "10MB" Then Send("X") Send("{F4}") Send("X") Send("{F4}") EndIf If GUICtrlRead($Velox) = "15MB" Then Send("X") Send("{F4}") Send("{TAB}") Send("X") Send("{F4}") EndIf If GUICtrlRead($Velox) = "20MB" Then Send("X") Send("{F4}") Send("{TAB}") Send("{TAB}") Send("X") Send("{F4}") EndIf If GUICtrlRead($Velox) = "25MB" Then Send("X") Send("{F4}") Send("{F8}") Send("X") Send("{F4}") EndIf If GUICtrlRead($Velox) = "35MB" Then Send("X") Send("{F4}") Send("{F8}") Send("{TAB}") Send("{TAB}") Send("X") Send("{F4}") EndIf ;EndSwitch ; WEnd Send("{F4}") Send("{F4}") Send("N") Send("P") Send("{TAB}") Send("P") Send("{F4}") Send("{F4}") Send("{ENTER}") Send("X") Send("{ENTER}") Send("{ENTER}") Send("{ENTER}") Send("{ENTER}") Send("S") Send("{ENTER}") Send("N") Send("{ENTER}") Send("N") Send("{ENTER}") Send("T") Send("{TAB}") Send("T") Send("{TAB}") Send("T") Send("{TAB}") Send("G44291") ;LOGIN Send("?") Send("{ENTER}") Send("X") Send("{ENTER}") Send("{TAB}") Send("T") Send("{TAB}") Send("T") Send("{ENTER}") Send("{F4}") Send("{ENTER}") ExitProg() EndFunc ;==>VelocidadesVelox Func Resolucao() Select Case $iDesktopWidth = 640 And $iDesktopHeight = 480 Case $iDesktopWidth = 800 And $iDesktopHeight = 480 Case $iDesktopWidth = 854 And $iDesktopHeight = 480 Case $iDesktopWidth = 800 And $iDesktopHeight = 600 Case $iDesktopWidth = 960 And $iDesktopHeight = 540 Case $iDesktopWidth = 1024 And $iDesktopHeight = 576 Case $iDesktopWidth = 1024 And $iDesktopHeight = 600 Case $iDesktopWidth = 1024 And $iDesktopHeight = 768 $mouseX = 363 $mouseY = 358 Case $iDesktopWidth = 1152 And $iDesktopHeight = 864 Case $iDesktopWidth = 1280 And $iDesktopHeight = 720 Case $iDesktopWidth = 1280 And $iDesktopHeight = 768 Case $iDesktopWidth = 1280 And $iDesktopHeight = 800 Case $iDesktopWidth = 1280 And $iDesktopHeight = 960 Case $iDesktopWidth = 1280 And $iDesktopHeight = 1024 Case $iDesktopWidth = 1360 And $iDesktopHeight = 768 Case $iDesktopWidth = 1366 And $iDesktopHeight = 768 $mouseX = 522 $mouseY = 384 Case $iDesktopWidth = 1440 And $iDesktopHeight = 900 Case $iDesktopWidth = 1400 And $iDesktopHeight = 1050 Case $iDesktopWidth = 1600 And $iDesktopHeight = 900 $mouseX = 611 $mouseY = 444 Case $iDesktopWidth = 1600 And $iDesktopHeight = 1200 Case $iDesktopWidth = 1680 And $iDesktopHeight = 1050 Case $iDesktopWidth = 1920 And $iDesktopHeight = 1080 Case $iDesktopWidth = 1920 And $iDesktopHeight = 1200 Case $iDesktopWidth = 1920 And $iDesktopHeight = 1400 Case $iDesktopWidth = 2048 And $iDesktopHeight = 1080 Case $iDesktopWidth = 2048 And $iDesktopHeight = 1152 Case $iDesktopWidth = 2048 And $iDesktopHeight = 1536 Case $iDesktopWidth = 2538 And $iDesktopHeight = 1080 Case $iDesktopWidth = 2560 And $iDesktopHeight = 1080 Case $iDesktopWidth = 2560 And $iDesktopHeight = 1440 Case $iDesktopWidth = 2560 And $iDesktopHeight = 1600 Case $iDesktopWidth = 2560 And $iDesktopHeight = 2048 Case $iDesktopWidth = 2880 And $iDesktopHeight = 900 Case $iDesktopWidth = 3200 And $iDesktopHeight = 2048 Case $iDesktopWidth = 3200 And $iDesktopHeight = 2400 Case $iDesktopWidth = 3840 And $iDesktopHeight = 2160 Case $iDesktopWidth = 3840 And $iDesktopHeight = 2400 Case $iDesktopWidth = 4096 And $iDesktopHeight = 1716 Case $iDesktopWidth = 4096 And $iDesktopHeight = 3072 Case $iDesktopWidth = 5120 And $iDesktopHeight = 3200 Case $iDesktopWidth = 5120 And $iDesktopHeight = 4096 Case $iDesktopWidth = 6400 And $iDesktopHeight = 4096 Case $iDesktopWidth = 6400 And $iDesktopHeight = 4800 Case $iDesktopWidth = 7680 And $iDesktopHeight = 4320 Case $iDesktopWidth = 7680 And $iDesktopHeight = 4800 Case Else Return SetError(1, 0, "") EndSelect EndFunc ;==> Resolução Edited August 25, 2017 by AzgarD Link to comment Share on other sites More sharing options...
AzgarD Posted August 25, 2017 Author Share Posted August 25, 2017 Never mind, i used a simple PixelGetColor function. Ty Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now