Search the Community
Showing results for tags 'goto'.
-
Hello this is the code maybe you can figure it out I placed some comments to try and explain what I want #include <Array.au3> AnyDeskOpen() Func AnyDeskOpen() Global $aWinList = WinList("[REGEXPTITLE:(?i)(.*Anydesks*)]") ;get window name and handle from windows and store into an array $asd = $aWinList $aExtract = _ArrayExtract($asd) ; beginner babble clean this Sh** up Global $default = _ArrayToString($aExtract, "", 0, 0) EndFunc StartWait() ; check in the array to see how many windows are opened Func StartWait() While 1 AnyDeskOpen() If $Default = 1 Then Sleep (3500) Else Exitloop EndIf WEnd EndFunc If $default = "2" Then ; If two windows are opened than someone is trying to connect to that computer and needs a click to accept connection try and click accept Button in the first window and the second one by activating diffrent window handle $extra = _ArrayToString($aWinList, "", 1, 1) $sString = StringReplace($extra, "AnyDesk", "") $hGUI = $sString WinActivate(HWnd($hGUI)) winmove (HWnd($hGUI), "", 50, 50) Mouseclick ("left", 100, 500) Sleep (1500) $extra = _ArrayToString($aWinList, "", 2, 2) $sString = StringReplace($extra, "AnyDesk", "") $hGUI = $sString WinActivate(HWnd($hGUI)) winmove (HWnd($hGUI), "", 50, 50) Mouseclick ("left", 100, 500) EndIf While 1 ;up to here everything seems to work AnyDeskOpen() ; while there is a connection there are two AnyDesk windows, if we close the connection than only one window remains opened and we check the array to see how many values it has If $Default = 2 Then Sleep (3500) Else ; At this point the program exits code 0 instead of resseting to function above StartWait() Exitloop EndIf WEnd ; thank you the intent is to keep the program going so it clicks accept again when reconnecting
-
Hello, I am new to both Programming and this forum. I have done a few tiny projects that were successful and fell in love with Autoit. So now I am trying to learn new things as I go. I have read the Help docs on my following question, I have gone thru all of that. and I am sure as soon as you see my code you will be saying OMG why did he do that, or OMG how can you forget to add this.. But when your new you take the path of least resistance to get the outcome you want. SETUP: I am trying to make a code that will open a piece of software, then open a browser (which has a handful of tabs already open) go to a web page (one of the tabs) and search an area of the web page for a specific color, if that color is found I want it to close the browser and go back and start again. If that color is not found on that page I want it to switch tabs and search that page for the color. If the color is found on that page I want it to close the browser and start again. If the color is not found on either page, I want it to open another browser and go to website and do some things I will add once i get past this obstacle. I already have it almost there my code will open my software, open the browser, do the searches, find or not find the color, the part I am having trouble with is the if and else and what happens if and what it does if it does not. So the first code I have does everything I want except if it finds the color on the first run it closes the browser, but then when it starts the process again it doesnt check for the color. its like it skips the scanning part and goes straight to the opening of the second browser and finishes the code. Run( "C:\Programs\myprogram.exe", "", @SW_SHOWDEFAULT ) Sleep(4000) MouseClick("left", 613,272) ;click in program Sleep(500) Example() Func Example() MouseClick("left", 632,456) ;click in program Sleep(500) MouseClick("left", 527,456) ;click in program Sleep(15000) Run( "C:\Programs\browser1.exe", "", @SW_SHOWMAXIMIZED ) Sleep(Random(4000,6000)) EndFunc ;==>Example MouseClick("left", 162,14) ;switch tab Sleep(Random(5000,8000)) MouseClick("left", 354,14) ;switch tab Sleep(Random(5000,8000)) $aCoord = PixelSearch(873, 485, 900, 600, 0xDD0000, 10) ;search for color If Not @error Then MouseClick("left", 1338,6) ;close browser1 Sleep(1000) Call("Example") Else MouseClick("left", 162,14) ;switch tab Sleep(1000) EndIf MouseClick("left", 162,14) ;click tab again just to be sure its loaded Sleep(4000) $aCoord = PixelSearch(1052, 308, 1120, 431, 0xFF0000, 10) ;search for this color If Not @error Then MouseClick("left", 1338,6) ;close browser1 Sleep(1000) Call("Example") Else Run( "C:\Programs\browser2.exe", "", @SW_SHOWMAXIMIZED ) Sleep(2000) EndIf MouseClick("left", 134,45) ;click on address bar Sleep(1000) Send("aspecificwebpage.com") ;input website Send("{enter}") ;hit enter Sleep(15000) MouseClick("left", 1338,6) ;close browser2 Sleep(500) MouseClick("left", 1338,6) ;close browser1 Sleep(500) MouseClick("left", 625,454) ;click in program Sleep(500) MouseClick("left", 634,271) ;click in program Sleep(500) MouseClick("left", 917,245) ;close program Sleep(500) SO it makes the first scan and is successful, if the color is found it closes as I want, but then when nit starts the code again it does not scan anything the second time. and on the other side, if the color is not found naturally everything works as it is written. I want to guess by all the weird colors in the code sniplet I have a massive amount of errors. It is like a rainbow of text up there. different from what i see in AutoIT Any help would be appreciated.
-
hi , I have written a script to simulate keypresses and click on some windows The work is repetitive. Here I activate 'foobar' and click on a place in it then press few down arrow keys . Then some keypresses in 'reboot' window ... (1)It sometimes happen that am external window pops up taking focus away from action being performed by script . As a result ,say, 'reboot' window does not appear . How should I bring scipt to run from beginning (of while loop) again ? (2)I used window info tool to find coordinates of place to click . Is it possible that window info tool keeps updating mouse coordinate even when I do not drag its finder ? (3)I would also like to add functionality to do an action on window 'new IP' , if found , in the infinite while loop . Please give directions. Thanks. #include <AutoItConstants.au3> HotKeySet("{ESC}", "dummy") AutoItSetOption("WinTitleMatchMode",2); Local $hWnd, $x, $y, $pos, $reponse While 1 $hWnd = WinGetHandle("foobar") $pos = WinGetPos($hWnd) $x = 360 ; $y = 77 ; WinActivate($hWnd) MouseClick("left", $pos[0] + $x, $pos[1] + $y) Send("{DOWN}") WinWaitActive($hWnd) Send("{DOWN}") WinWaitActive($hWnd) Send("{DOWN}") WinWaitActive($hWnd) Send("{DOWN}") WinWaitActive($hWnd) Send("{DOWN}") Send("{DOWN}") WinWaitActive($hWnd) WinWaitActive($hWnd) Send("{ENTER}") $reboot_window = WinWait("Reboot") WinWaitActive($reboot_window) Send("{TAB}") WinWaitActive($reboot_window) Send("{SPACE}") WinWaitActive($reboot_window) Send("{TAB}") WinWaitActive($reboot_window) Send("{DOWN}") Send("{DOWN}") WinWaitActive($reboot_window) Send("{TAB}") WinWaitActive($reboot_window) Send("{DOWN}") WinWaitActive($reboot_window) Send("{TAB}") WinWaitActive($reboot_window) Send("{SPACE}") Sleep(1000) $response = WinGetHandle("Reboot") $pos = WinGetPos($response) $x = 168 ; 530-362 $y = 258 ; 376-118 WinActivate($response) MouseClick("left", $pos[0] + $x, $pos[1] + $y) Sleep(50000) WEnd Func dummy() EndFunc ;==>dummy