tp9191 Posted November 25, 2012 Share Posted November 25, 2012 Or am I left to do these sort of things manually? Like for example, I have this on line 22 of my script: send ("{DOWN}{ENTER}") then 25 lines later, on line 47 I have: send ("{DOWN}{DOWN}{ENTER}") again another 25 lines later, on line 72 I have: send ("{DOWN}{DOWN}{DOWN}{ENTER}") You get the idea.... basically adding another {down} each time. I need to do this for about 15-20 more times. Is there a command in Autoit that you can direct me to, that tells it to add another key press automatically or something? Link to comment Share on other sites More sharing options...
water Posted November 25, 2012 Share Posted November 25, 2012 Which program do you try to automate? Sending keystrokes to a program this way isn't very reliable. If we know what you try to achieve we might show you another - more reliable - solution. 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...
tp9191 Posted November 25, 2012 Author Share Posted November 25, 2012 The program is Replay Media Catcher. I'm trying to use the Fix FLV tool to batch fix some FLV files.expandcollapse popupOpt("MouseCoordMode", 1) WinActivate ("[Class:WindowsForms10.Window.8.app.0.2e0c681]") send ("!t") send ("f") sleep(100) WinWait ("Select FLV file to fix ...") mouseclick ("left",400,140,1,40) sleep(100) send ("{DOWN}{ENTER}") winwaitactive ("Fix FLV", "Actual File Duration") controlclick ("Fix FLV", "", "Fix Duration") sleep(100) send ("{enter}") winwaitactive ("Fix FLV", "Actual File Duration") sleep(100) controlclick ("Fix FLV", "", "File Contents") winwaitactive ("Fix FLV", "Displaying the first") sleep(100) controlclick ("Fix FLV", "", "Fix Time") sleep(100) send ("{enter}") winactivate ("Fix FLV", "Displaying the first") sleep(100) controlclick ("Fix FLV", "", "Close") WinActivate ("[Class:WindowsForms10.Window.8.app.0.2e0c681]") send ("!t") send ("f") sleep(100) WinWait ("Select FLV file to fix ...") mouseclick ("left",400,140,1,40) sleep(100) send ("{DOWN}{DOWN}{ENTER}") winwaitactive ("Fix FLV", "Actual File Duration") controlclick ("Fix FLV", "", "Fix Duration") sleep(100) send ("{enter}") winwaitactive ("Fix FLV", "Actual File Duration") sleep(100) controlclick ("Fix FLV", "", "File Contents") winwaitactive ("Fix FLV", "Displaying the first") sleep(100) controlclick ("Fix FLV", "", "Fix Time") sleep(100) send ("{enter}") winactivate ("Fix FLV", "Displaying the first") sleep(100) controlclick ("Fix FLV", "", "Close") WinActivate ("[Class:WindowsForms10.Window.8.app.0.2e0c681]") send ("!t") send ("f") sleep(100) WinWait ("Select FLV file to fix ...") mouseclick ("left",400,140,1,40) sleep(100) send ("{DOWN}{DOWN}{DOWN}{ENTER}") winwaitactive ("Fix FLV", "Actual File Duration") controlclick ("Fix FLV", "", "Fix Duration") sleep(100) send ("{enter}") winwaitactive ("Fix FLV", "Actual File Duration") sleep(100) controlclick ("Fix FLV", "", "File Contents") winwaitactive ("Fix FLV", "Displaying the first") sleep(100) controlclick ("Fix FLV", "", "Fix Time") sleep(100) send ("{enter}") winactivate ("Fix FLV", "Displaying the first") sleep(100) controlclick ("Fix FLV", "", "Close") WinActivate ("[Class:WindowsForms10.Window.8.app.0.2e0c681]")As you can see my script is very ghetto but that's how I roll. And hey it works if I pre-setup things (such as the window size of the 'browse file' popup window.PS.. maybe I over did it with the sleeps. Link to comment Share on other sites More sharing options...
water Posted November 25, 2012 Share Posted November 25, 2012 You can add a number to the key you want to send. According to the help file:Single keys can also be repeated, e.g. Send("{DEL 4}") ; Presses the DEL key 4 timesor by using a counterIf you wish to use a variable for the count, try $n = 4 Send("{TAB " & $n & "}") ; Presses the TAB key 4 times 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...
tp9191 Posted November 25, 2012 Author Share Posted November 25, 2012 I assume the first one isn't going to accomplish what I want to do? but the second one, well i'm not sure yet as I can hardly understand what it means so i'll have to try and figure it out. thanks though, i'll report later to see what happens. Link to comment Share on other sites More sharing options...
water Posted November 25, 2012 Share Posted November 25, 2012 The second example does the same as the first one but is more flexible by using a variable. I would suggest you start reading the AutoIt help file and the tutorials in the wiki to get a good understanding of how AutoIt works! 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...
tp9191 Posted November 25, 2012 Author Share Posted November 25, 2012 Where is the tutorials at? Is it the zip file with the pdf and example scripts? If it is, then I just downloaded it and looked at a few of the scripts. I feel smarter already Link to comment Share on other sites More sharing options...
water Posted November 25, 2012 Share Posted November 25, 2012 The tutorials in the wiki can be found here. 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...
Myicq Posted November 25, 2012 Share Posted November 25, 2012 But for more complex examples when you have to enter repetitive code, you could benefit from looking at the included "msgbox wizard" (by Gary Frost / Guiseppe Criaco). It's real easy to make a small gui, input the values that can vary, and create some code to insert. Create logic and math as you please. Or, you can of course rely on the power behind many editors.. scite, UltraEdit etc etc. Have to say though that I often wish I had a wizard for this and that, but I never get around to writing it.. so just giving the idea on here. I am just a hobby programmer, and nothing great to publish right now. Link to comment Share on other sites More sharing options...
tp9191 Posted December 3, 2012 Author Share Posted December 3, 2012 (edited) Well, so I managed to view some video tutorials on youtube and I learned some more stuff. I now have:Global $n Opt("MouseCoordMode", 1) Opt("SendKeyDelay", 500) For $n = 1 To 5 Step + 1 Do WinActivate ("[Class:WindowsForms10.window.8.app.0.2e0c681]") send ("!t") send ("f") sleep(300) WinWait ("Select FLV file to fix ...") mouseclick ("left",400,140,1,10) sleep(300) Send ("{DOWN} + $n") send ("{enter}") winwaitactive ("Fix FLV", "Actual File Duration") sleep(300) controlclick ("Fix FLV", "", "File Contents") sleep(300) winwaitactive ("Fix FLV", "Displaying the first") sleep(300) controlclick ("Fix FLV", "", "Fix Time") sleep(300) send ("{enter}") winactivate ("Fix FLV", "Displaying the first") controlclick ("Fix FLV", "", "Close") Until $n = 5 NextTo summarize again so people can know what i'm doing.. when it gets toSend ("{DOWN} + $n")I basically need it to send an extra {DOWN} key press each time the script runs through it.As it stands, it simply isn't looping at all. Edited December 3, 2012 by tp9191 Link to comment Share on other sites More sharing options...
BrewManNH Posted December 3, 2012 Share Posted December 3, 2012 Send ("{DOWN " & $n & "}") If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
tp9191 Posted December 3, 2012 Author Share Posted December 3, 2012 (edited) Thanks for the quick response. It is looping through, but it is selecting the second file in the browse file menu every time, instead of going to the third, fourth, etc. I cleaned up the script a bit, but I didn't change anything: Global $n Opt("MouseCoordMode", 1 ) Opt("SendKeyDelay", 10 ) For $n = 1 To 5 Step + 1 Do WinActivate ("[Class:WindowsForms10.window.8.app.0.2e0c681]") Send ("!t") Send ("f") WinWait ("Select FLV file to fix ...") Sleep(500) MouseClick ("left",400,140,1,10) Send ("{DOWN " & $n & "}") Sleep(200) Send("{enter}") WinWaitActive ("Fix FLV", "Actual File Duration") Sleep(300) ControlClick ("Fix FLV", "", "File Contents") Sleep(300) WinWaitActive ("Fix FLV", "Displaying the first") Sleep(300) ControlClick ("Fix FLV", "", "Fix Time") Sleep(300) Send ("{enter}") WinActivate ("Fix FLV", "Displaying the first") ControlClick ("Fix FLV", "", "Close") Until $n = 5 Next Did I use the Do..For...Until correctly? Is there another loop function thing that I should use instead of this one? Edited December 3, 2012 by tp9191 Link to comment Share on other sites More sharing options...
tp9191 Posted December 3, 2012 Author Share Posted December 3, 2012 (edited) I want to get this down, first. Unless, is that an alternative which will accomplish what I'm trying to do? EDIT: where'd your post go? (Blue_Drache) Edited December 3, 2012 by tp9191 Link to comment Share on other sites More sharing options...
Blue_Drache Posted December 3, 2012 Share Posted December 3, 2012 (edited) I want to get this down, first. Unless, is that an alternative which will accomplish what I'm trying to do? You're on the right track, honestly. I read the code that you recently put in and it's solid. I'd still use ControlSend() though. My confusion is ... why the mouseclick() at a specific set of coordinates? That would be very easy to goof up, especially if the window gets moved. WinWait("Select FLV file to fix ...") Sleep(500) MouseClick("left",400,140,1,10) Also, with WinWait, you can put in a timer using the built in options of the function. For example: If not WinWait("Select FLV file to fix", "", 30) then ConsoleWrite("Error. FLV selection window did not appear." & @CRLF) Exit 99 EndIf Simple error trapping can also go a long way toward debugging at a later time. Edited December 3, 2012 by Blue_Drache Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache Link to comment Share on other sites More sharing options...
tp9191 Posted December 3, 2012 Author Share Posted December 3, 2012 (edited) "My confusion is ... why the mouseclick() at a specific set of coordinates? That would be very easy to goof up, especially if the window gets moved."http://i45.tinypic.com/xoqw68.jpgLong answer... The window always stays maximized unless I go and do something to it. Either way I always go and pre check things before I run the script to make sure everything is in position.Short answer... because i'm a noob.My code... solid? lol thanks for the compliment. Like I said I looked at some tutvids and I told myself 'hey that code piece could be useful for this' so i used it.Thanks for the suggestions. I will try what you said but it won't be until much later (this stuff is giving me a headache lol).Meanwhile, is there anything else you may want to suggest? It feels to me like all those WinWaitActives and ControlClicks could be tried with something different. I dunno.EDIT: Oh to answer your question a bit better. I have to click once (see pic) to give focus to that part of the window (the first file is clicked). Then it proceeds with the {DOWN} pressings... Edited December 3, 2012 by tp9191 Link to comment Share on other sites More sharing options...
Blue_Drache Posted December 3, 2012 Share Posted December 3, 2012 (edited) Oy... ok. The way I'd do it? You could use ControlSend to type in a filename in the bottom field and get rid of all the "up/down" Send() stuff. Global $n = 1, $hwnd_Main, $hwnd_File, $hwnd_Duration, $hwnd_Display Opt("MouseCoordMode", 1) Opt("SendKeyDelay", 10) While $n < 30 $hwnd_Main = WinActivate("[Class:WindowsForms10.window.8.app.0.2e0c681]") Send("!t") Send("f") ; you could probably replace the two lines above with a more reliable way to open the file dialog, but I left it alone. $hwnd_File = WinWait("Select FLV file to fix ...", "", 30) If Not $hwnd_File Then ConsoleWrite("Timeout waiting for File Open dialog" & @CRLF) ExitLoop EndIf ControlSend($hwnd_File, "", $controlID, $n & ".flv") $hwnd_Duration = WinWaitActive("Fix FLV", "Actual File Duration", 30) If Not $hwnd_Duration Then ConsoleWrite("Timeout waiting for Duration window" & @CRLF) ExitLoop EndIf ControlClick("Fix FLV", "", "File Contents") $hwnd_Display = WinWaitActive("Fix FLV", "Displaying the first", 30) If Not $hwnd_Display Then ConsoleWrite("Timeout waiting for Display window" & @CRLF) ExitLoop EndIf ControlClick("Fix FLV", "", "Fix Time") Sleep(300) Send("{enter}") WinActivate($hwnd_Display) ControlClick("Fix FLV", "", "Close") $n += 1 WEnd This was just me noodling about with your code and the picture given. Of course, change the While $n < 30 to whatever number of files are in the folder. You could get that with a $array = _FileListToArray() statment and pass the zero element of the array as your maximum iterations of the loop. ie: While $n < $array[0] Edited December 3, 2012 by Blue_Drache Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache Link to comment Share on other sites More sharing options...
tp9191 Posted December 4, 2012 Author Share Posted December 4, 2012 Oh god.. this is gonna be a while for me to absorb all this info..specifically the handlewindow variable stuff. Looks like it's back to the tut vids for me.. In the meantime I must mention that the filenames were changed for demonstrations purposes only. Is this going to affect something if the filesnames were actually something useful? Or is this where the array stuff comes into play (which I may add, i'm gonna have to hit the tutvids again for this)? As it stands now, the script gets as far as the file open window.. .and nothing happens. Link to comment Share on other sites More sharing options...
Blue_Drache Posted December 4, 2012 Share Posted December 4, 2012 It got as far as the open window because I couldn't troubleshoot it. I don't have access to your program, so I couldn't get the control ID of that edit box on the bottom of your window. $controlID is an undefined variable, so the program doesn't know which control to interact with. For all I know, it's trying to type in the folder box on the left. Also, if the filenames are not consecutive numbers as in the picture example, then something else will have to be written instead. I like to use window handles because, once generated, they never change until the window is destroyed. Window text and titles are fungible. Just substitute in the correct control ID on that window and it might just work. Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache Link to comment Share on other sites More sharing options...
tp9191 Posted December 4, 2012 Author Share Posted December 4, 2012 (edited) *sigh* I hate these class things. Seems like they give me are giving me a difficult time and they shouldn't be.. well at least not as much as the other stuff above... I'm getting an error about missing separator after keyword. Check the script below.Global $n = 1, $hwnd_Main, $hwnd_File, $hwnd_Duration, $hwnd_Display Opt("MouseCoordMode", 1) Opt("SendKeyDelay", 10) While $n < 34 $hwnd_Main = WinActivate("[Class:WindowsForms10.window.8.app.0.2e0c681]") Send("!t") Send("f") $hwnd_File = WinWait("Select FLV file to fix ...", "", 34) If Not $hwnd_File Then ConsoleWrite("Timeout waiting for File Open dialog" & @CRLF) ExitLoop EndIf ControlSend($hwnd_File, "", [CLASS:Edit, INSTANCE:1], $n & ".flv") $hwnd_Duration = WinWaitActive("Fix FLV", "Actual File Duration", 34) If Not $hwnd_Duration Then ConsoleWrite("Timeout waiting for Duration window" & @CRLF) ExitLoop EndIf ControlClick("Fix FLV", "", "File Contents") $hwnd_Display = WinWaitActive("Fix FLV", "Displaying the first", 34) If Not $hwnd_Display Then ConsoleWrite("Timeout waiting for Display window" & @CRLF) ExitLoop EndIf ControlClick("Fix FLV", "", "Fix Time") Sleep(300) Send("{enter}") WinActivate($hwnd_Display) ControlClick("Fix FLV", "", "Close") $n += 1 WEnd Edited December 4, 2012 by tp9191 Link to comment Share on other sites More sharing options...
BrewManNH Posted December 4, 2012 Share Posted December 4, 2012 This needs to be fixed. ;this is wrong ControlSend($hwnd_File, "", [CLASS:Edit, INSTANCE:1], $n & ".flv") ; needs to be like this ControlSend($hwnd_File, "", "[CLASS:Edit, INSTANCE:1]", $n & ".flv") I'm not sure about the rest, but that jumped out at me. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator 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