AzgarD Posted August 19, 2017 Share Posted August 19, 2017 Hello guys. Is more a question then a problem. The question is, can i make this function faster? Because what i need to do has to be done extremally fast, and if i take off the Sleep function the script kind of crashes. I already tested speed below 500ms, and the script stops without an error. The script has to push F4 like crazy, real fast. Func ApertaF4() Send("{F4}") MouseClick($MOUSE_CLICK_LEFT, 518, 378, 2, 1) Send("^c") $copia = ClipGet() While StringRegExp ( $copia, "Sigla" ) = True Sleep (500) Send("{F4}") MouseClick($MOUSE_CLICK_LEFT, 518, 378, 2, 1) Send("^c") $copia = ClipGet() WEnd EndFunc Link to comment Share on other sites More sharing options...
water Posted August 19, 2017 Share Posted August 19, 2017 Using MouseClick and Send might be unreliable because it depends on screen size, resolution, window position etc. We usually suggest to use Win* and Control* functions. From your other thread I got the impression that you try to automate another program. Can you please provide some information which program we are talking about? Using the Autoit Window Info Tool you get the information needed to use the Control* functions. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Cotino Posted August 19, 2017 Share Posted August 19, 2017 Here is my version of key spam : #include <Misc.au3> While 1 If _IsPressed("73") Then ; F4 ControlSend("[ACTIVE]", "", 0, "{F4}") MouseClick("Left") EndIf WEnd Link to comment Share on other sites More sharing options...
AzgarD Posted August 21, 2017 Author Share Posted August 21, 2017 Yes, im trying to automate another program. The script is not yet finished, but the task should be simple. I just need to press "F4" until the screen changes, and then do some other more easy stuff using "Send" function. This is how my code looks like: expandcollapse popup#include <MsgBoxConstants.au3> #include <GUIConstantsEx.au3> #include <AutoItConstants.au3> #include <StringConstants.au3> #include <ComboConstants.au3> Global $gui = GUICreate("MONSTRA v1.0", 300, 250) 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|30MB|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) HotKeySet("{ESC}", "ExitProg") Func ExitProg() Exit EndFunc ;==>ExitProg 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, 518, 378, 2, 1) ;usar $mouseX e $mouseY Send("^c") $copia = ClipGet() While StringRegExp ( $copia, "Sigla" ) = True Sleep (500) Send("{F4}") MouseClick($MOUSE_CLICK_LEFT, 518, 378, 2, 1) ;usar $mouseX e $mouseY Send("^c") $copia = ClipGet() WEnd VelocidadesVelox() EndFunc ;==>ApertaF4 Func VelocidadesVelox() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Velox If GUICtrlRead($Velox) = "300K" Then EndIf If GUICtrlRead($Velox) = "600K" Then EndIf If GUICtrlRead($Velox) = "1MB" Then EndIf If GUICtrlRead($Velox) = "2MB" Then EndIf If GUICtrlRead($Velox) = "5MB" Then EndIf If GUICtrlRead($Velox) = "10MB" Then EndIf If GUICtrlRead($Velox) = "15MB" Then EndIf If GUICtrlRead($Velox) = "20MB" Then EndIf If GUICtrlRead($Velox) = "25MB" Then EndIf If GUICtrlRead($Velox) = "30MB" Then EndIf If GUICtrlRead($Velox) = "35MB" Then EndIf EndSwitch WEnd EndFunc ;==>VelocidadesVelox Link to comment Share on other sites More sharing options...
AzgarD Posted August 22, 2017 Author Share Posted August 22, 2017 On 19/08/2017 at 6:03 PM, Cotino said: Here is my version of key spam : #include <Misc.au3> While 1 If _IsPressed("73") Then ; F4 ControlSend("[ACTIVE]", "", 0, "{F4}") MouseClick("Left") EndIf WEnd So i tryed that and my script doesnt work. Any other ideas? Link to comment Share on other sites More sharing options...
AzgarD Posted August 22, 2017 Author Share Posted August 22, 2017 This is how my code looks like right now. Ignore the Resolution Function because isnt all complete, but is doing what i need to do so far. My nly and biggest problem is that delay on the "ApertaF4" function. 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 = ClipGet() 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}") 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 Link to comment Share on other sites More sharing options...
AzgarD Posted August 22, 2017 Author Share Posted August 22, 2017 On 19/08/2017 at 5:10 PM, water said: Using MouseClick and Send might be unreliable because it depends on screen size, resolution, window position etc. We usually suggest to use Win* and Control* functions. From your other thread I got the impression that you try to automate another program. Can you please provide some information which program we are talking about? Using the Autoit Window Info Tool you get the information needed to use the Control* functions. So, i'll put the info here, hope that helps you guys help me ^^. The mouse position is the location where i'm getting the String to compare, and yes, the double clicking take a lot of time. As you sayed, using that kind of script depends on scree, resolution and window, that why i use that function tho get those informations. >>>> Window <<<< Title: 1 - STC (10.31.9.100) Class: HostExplorer Position: -4, -4 Size: 1374, 748 Style: 0x17CF0000 ExStyle: 0x00000100 Handle: 0x00000000000A03F8 >>>> Control <<<< Class: Instance: ClassnameNN: Name: Advanced (Class): ID: Text: Position: Size: ControlClick Coords: Style: ExStyle: Handle: >>>> Mouse <<<< Position: 524, 341 Cursor ID: 0 Color: 0x4080FF >>>> StatusBar <<<< 1: 2: 3: 1 4: Sess-1 5: 10.31.9.100 6: 7: 8: GLJM0133 9: 10: >>>> ToolsBar <<<< This is the code: 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 = ClipGet() 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}") 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 Link to comment Share on other sites More sharing options...
water Posted August 22, 2017 Share Posted August 22, 2017 Another idea: Use AutoItSetOption("MouseCoordMode", 0) so the coordinates are no longer absolute screen coordinates but relative coordinates to the active window. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
AzgarD Posted August 22, 2017 Author Share Posted August 22, 2017 Note this, the program i'm trying to automate uses a coordinate system as you can see in the images. When the cursor of the program is on top o the "T" the coords are 7/38, and when i put the cursor on thop of the "i" right next to him the coords are 7/39. Our previous MACRO was coded in Visual Basic using the Excel, and he was able to comunicate and navigate by those coords. So, maybe that could be better, but i dont know how to do this. Link to comment Share on other sites More sharing options...
water Posted August 22, 2017 Share Posted August 22, 2017 (edited) I see. What you try to automate is a host (mainframe, AS400 ...?) emulation program. What you see in the lower right corner (7/39) is the character postition (row/column) of the Emulation window. To automate such an application I would use another approach. You could either create a macro fo the emulation program by using AutoIt and then let AutoIt call the macro Menu and execute it. Or use the API provided by the emulation program. Do you know the name of the emulator you run? Which Information does (ajuda - help) show? Edited August 22, 2017 by water My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
AzgarD Posted August 22, 2017 Author Share Posted August 22, 2017 Thats what "Help" says: Link to comment Share on other sites More sharing options...
water Posted August 22, 2017 Share Posted August 22, 2017 Hummingbird is now Opentext. But according to their website their product supports Macro playback and programs using COM.http://connectivity.opentext.com/products/hostexplorer-technical-spec.aspx Seems your version is quite old so I'm not sure what has changed since 1999. If your documentation includes a macro coding guide or a description of the object model we could go this route and create quite reliable programs. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
AzgarD Posted August 22, 2017 Author Share Posted August 22, 2017 (edited) Guys i've made a "discovery" that can help me a lot. I say in quotes because was there all the time and i was dumb enough not to see, and just realized when water seyed. So, the program has a Macro recorder, that you can map the use of the program and then execute the Macro later to do that task. Just for you know the Macro works that way in the Loop part. '---------------------------------------------------------------------- ' This macro was created by the macro recorder. ' Macro File: C:\Users\innova\Desktop\SAMPLE.EBS ' Date: Tue Aug 22 14:33:45 2017 '---------------------------------------------------------------------- Sub Main Dim HostExplorer as Object Dim CurrentHost as Object Dim iIdleTime Set HostExplorer = CreateObject("HostExplorer") ' Initialize HostExplorer Object Set CurrentHost = HostExplorer.CurrentHost ' Set object for current session iIdleTime = 1 ' Idle time set to 2000 milliseconds Call Copy_Interval(10, 18, 10, 25) If SelText = "Informe:" Then CurrentHost.RunCmd( "Pf4" ) CurrentHost.WaitIdle( iIdleTime ) End If Edited August 22, 2017 by AzgarD Link to comment Share on other sites More sharing options...
water Posted August 22, 2017 Share Posted August 22, 2017 That's the way to go! My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
water Posted August 22, 2017 Share Posted August 22, 2017 (edited) As described in the Programmer's Guide you could even use COM to access the HostExplorer like Word or Excel.https://de.scribd.com/doc/226692979/Host-Explorer-Programming Or grab the macro created by the HostExplorer macro recorder and easily convert it to AutoIt. So you get the flexibility of both worlds! Edited August 22, 2017 by water My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
AzgarD Posted August 22, 2017 Author Share Posted August 22, 2017 5 minutes ago, water said: As described in the Programmer's Guide you could even use COM to access the HostExplorer like Word or Excel.https://de.scribd.com/doc/226692979/Host-Explorer-Programming Thats nice man. Thanks for all the help. Looks like i was working for nothing, because i'll have to go all the way again. Link to comment Share on other sites More sharing options...
water Posted August 22, 2017 Share Posted August 22, 2017 1 hour ago, AzgarD said: because i'll have to go all the way again. But this time you will be much faster and your code will be more reliable My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
AzgarD Posted August 23, 2017 Author Share Posted August 23, 2017 On 22/08/2017 at 4:08 PM, water said: But this time you will be much faster and your code will be more reliable So, i need to revive the topic (lol). So i make the code using Hummingbird and as expected the "F4" spam goes realy well. But now we have other problem, the other part of the code. As you can see in my AutoIt Script, in some point after the "F4" spam i have to send a lot of key commands like Send ("X") or Send ("{TAB}". And that kind of stuff dont works in the VBA. Is kind of difficult to explain, but in botton line, i'll need to come back to the AutoIt. Since my only problem is the Key Spam Loop, anyone has any solution? Link to comment Share on other sites More sharing options...
water Posted August 23, 2017 Share Posted August 23, 2017 Sending keys to the host window should be on of the basic functions of the macro language or of the COM interface. I'm sure if you check the Programmer's Guide you will find a chapter describing how to send keys. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
AzgarD Posted August 23, 2017 Author Share Posted August 23, 2017 (edited) 48 minutes ago, water said: Sending keys to the host window should be on of the basic functions of the macro language or of the COM interface. I'm sure if you check the Programmer's Guide you will find a chapter describing how to send keys. Yeah, is difficult to explain, but i'll try. The thing is, the Interface kind have a little delay to change the screen to the other page, somethimes that delay is like 200ms or even less, and somethimes that can take like 2 seconds. I don't know exactely why, but when we do that key sending by hand or using the AutoIt you can keep pressing or sending the keys even when the screen is "frozen", and then when it changes all of the sended keys are there. Is like "the program freezes, but we can still send commands to him". In other hand in the Hummingbird i can't send simple KeyStrokes, they have to be sended by the Host Console, then they always "roll over" each other. Just for you know, to bypass this problem i had to do a copy function that i'll always check the screen to "see" if is changed and the send the commands, but this costs a lot o time and i can't express how fast that process ha to be made. Edited August 23, 2017 by AzgarD 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