modern Posted February 4, 2019 Share Posted February 4, 2019 What I am trying to accomplish: Automate the task for selecting all episodes (Click on an episode and then ctrl+a to highlight all) for a podcast in my iTunes Library and choosing "Download Episodes" and then once all episodes are done downloading select all the episodes (Click on an episode and then ctrl+a to highlight all) and choose "Remove Download". Using Au3Record I was able to get: _WinWaitActivate("iTunes") MouseClick("left",659,332,1) Send("{CTRLDOWN}a{CTRLUP}") MouseClick("right",659,332,1) MouseClick("left",680,344,1) From doing more searching it seems this is very primitive and not an ideal way of doing this based on this. By going off that I would assume I should start with using something like this: #include "WinAPI.au3" #include "WindowsConstants.au3" ; #VARIABLES# =================================================================================================================== Local $hWnd ; #CONSTANTS# =================================================================================================================== ; Open iTunes Run("iTunes.exe") Sleep(1000) ; Get iTunes handle $hWnd = WinGetHandle("[Class:iTunes]") So from there I'm not sure how to proceed. Using Inspect I have been able to get the following which I believe are what I would need to use (just not sure how). class="iTunesTableView" (When moused over episodes) class="#32768" (When moused over Remove Download in context menu after right clicking) Name: "Remove Download" Name: "Download Episodes" Any help I could get would be greatly appreciated! Disclaimer: I have no idea what I am doing but trying to learn. Link to comment Share on other sites More sharing options...
Beege Posted February 5, 2019 Share Posted February 5, 2019 What your doing reminds me so much of my first scripts that started it all for me Based on what you have given me I can only give you some general direction. When It comes to the mouseclicks() that au3record gave you, that is the most primitive clicks can get and will simply click on your screen at that coordinate no matter what, even if the itunes window moved. A non-primitive way to click (sure why not) is to use the inspector to send commands to the control using the details like class and IDs to describe the control instead of blindly clicking a coordinate hoping the itunes window has not moved. Check out the documenations on controls. Do be warned though that you cant always do this with every control so you have to test a lot. If you dont get any kind of change happening in the inspector when when you are mousing over the "remove download" button then you may not be able to send a command directly to that control. If that would be the case coordinates may be the fall back but if that is the case you can still most of the time send commands to a cordinate somewhere within a certian window (like the itunes window) as opposed to sending a mouseclick() just somewhere on the screen. Also for your task you will need to have some way of identifying when the episodes are "all done" Assembly Code: fasmg . fasm . BmpSearch . Au3 Syntax Highlighter . Bounce Multithreading Example . IDispatchASMUDFs: Explorer Frame . ITaskBarList . Scrolling Line Graph . Tray Icon Bar Graph . Explorer Listview . Wiimote . WinSnap . Flicker Free Labels . iTunesPrograms: Ftp Explorer . Snipster . Network Meter . Resistance Calculator Link to comment Share on other sites More sharing options...
modern Posted February 5, 2019 Author Share Posted February 5, 2019 4 hours ago, Beege said: What your doing reminds me so much of my first scripts that started it all for me Based on what you have given me I can only give you some general direction. When It comes to the mouseclicks() that au3record gave you, that is the most primitive clicks can get and will simply click on your screen at that coordinate no matter what, even if the itunes window moved. A non-primitive way to click (sure why not) is to use the inspector to send commands to the control using the details like class and IDs to describe the control instead of blindly clicking a coordinate hoping the itunes window has not moved. Check out the documenations on controls. Do be warned though that you cant always do this with every control so you have to test a lot. If you dont get any kind of change happening in the inspector when when you are mousing over the "remove download" button then you may not be able to send a command directly to that control. If that would be the case coordinates may be the fall back but if that is the case you can still most of the time send commands to a cordinate somewhere within a certian window (like the itunes window) as opposed to sending a mouseclick() just somewhere on the screen. Also for your task you will need to have some way of identifying when the episodes are "all done" Thanks for some of that insight! I'm wondering if using imagesearch to check for this would do it for checking when they are done (disappears when done downloading): Link to comment Share on other sites More sharing options...
water Posted February 5, 2019 Share Posted February 5, 2019 (edited) Welcome to AutoIt and the forum! Please check the wiki. You'll find two UDFs to automate iTunes. Edited February 5, 2019 by water My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
modern Posted February 8, 2019 Author Share Posted February 8, 2019 Little update since I'm getting a little frustrated and probably just need to step away from this for a little bit. What I'm working with now: #include "WinAPI.au3" #include "WindowsConstants.au3" #include "iTunes.au3" HotKeySet("!a", "Main") ;wait for ALT-a keystroke, then go to Main() While 1 Sleep(100) WEnd Func Main() ; Run iTunes _iTunes_Start() ; Wait 15 seconds for the iTunes window to appear. Local $hWnd = WinWait("[CLASS:iTunes]", "", 15) ; Click on iTunesTable where podcast episodes are. ControlClick($hWnd, "", "[CLASS:iTunesTableView]") ;Start Loop While 1 MouseClick("left") Send("{CTRLDOWN}a{CTRLUP}") ControlClick($hWnd, "Download Episodes", "[CLASS:#32768]") ; Sleep(2000) MouseClick("left") Send("{CTRLDOWN}a{CTRLUP}") ControlClick($hWnd, "Remove Download", "[CLASS:#32768]") ; Sleep(1800000) WEnd EndFunc iTunes opens (Had issues with getting the focus right but even with manually clicking on iTunes after it opens it did not see to click the iTunesTable. I also have a feeling I have my loop incorrect too but haven't gotten to that yet. Link to comment Share on other sites More sharing options...
caramen Posted February 8, 2019 Share Posted February 8, 2019 (edited) Hello, 1) If you loose focus, then you can use WinActivate 2) Your loop seem to be correct, if you want to do that for life after hotkey press. If not, dont forget : ExitLoop Or even : If <Expression> Then ExitLoop EndIf At the end of your second loop: While (1) Sleep(1800000) ;<<<< Here WEnd I dont got Itunes installed on my pro laptop so if you can give us full windows info. So all peoples in my case can still help you about ControlClick($hWnd, "", "[CLASS:iTunesTableView]") Edited February 8, 2019 by caramen modern 1 My video tutorials : ( In construction ) || My Discord : https://discord.gg/S9AnwHw How to Ask Help || UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote Spoiler Water's UDFs:Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - Wiki Tutorials:ADO - Wiki Link to comment Share on other sites More sharing options...
Earthshine Posted February 8, 2019 Share Posted February 8, 2019 for these types of modern applications, it's best to use UI Automation as described here. I will use it and do some testing. LarsJ and modern 2 My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
modern Posted February 8, 2019 Author Share Posted February 8, 2019 (edited) 3 hours ago, Earthshine said: for these types of modern applications, it's best to use UI Automation as described here. I will use it and do some testing. I will definitely take a look at this, thank you! 4 hours ago, caramen said: Hello, 1) If you loose focus, then you can use WinActivate 2) Your loop seem to be correct, if you want to do that for life after hotkey press. If not, dont forget : ExitLoop Or even : If <Expression> Then ExitLoop EndIf At the end of your second loop: While (1) Sleep(1800000) ;<<<< Here WEnd I dont got Itunes installed on my pro laptop so if you can give us full windows info. So all peoples in my case can still help you about ControlClick($hWnd, "", "[CLASS:iTunesTableView]") This is with my mouse over an episode (where I need to click) Edited February 8, 2019 by modern Link to comment Share on other sites More sharing options...
caramen Posted February 8, 2019 Share Posted February 8, 2019 (edited) I dont know this Windows info tool This sceenshot is omitting the instance number. Maybe you can use the AutoIT Windows info tool to get the instance number and do a ControlClick with the good syntax it s lookîng Like this : ControlClick("Program Manager", "", "[CLASS:SysListView32; INSTANCE:1]", 'right') Edited February 9, 2019 by caramen My video tutorials : ( In construction ) || My Discord : https://discord.gg/S9AnwHw How to Ask Help || UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote Spoiler Water's UDFs:Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - Wiki Tutorials:ADO - Wiki Link to comment Share on other sites More sharing options...
modern Posted February 8, 2019 Author Share Posted February 8, 2019 5 minutes ago, caramen said: I dont know this Windows info rooo This sceenshot is omitting the instance number. Maybe you can use the AutoIT Windows info rooo to get the instance number and do a controleclick with the good syntax it s lookîng Like this : ControlClick("Program Manager", "", "[CLASS:SysListView32; INSTANCE:1]", 'right') Summary from using AutoIT Window Info expandcollapse popup>>>> Window <<<< Title: iTunes Class: iTunes Position: 356, 158 Size: 959, 725 Style: 0x16CF0000 ExStyle: 0x00000100 Handle: 0x000B183E >>>> Control <<<< Class: Static Instance: 1 ClassnameNN: Static1 Name: Advanced (Class): [CLASS:Static; INSTANCE:1] ID: 1573925840 Text: Position: 501, 265 Size: 443, 460 ControlClick Coords: 194, 125 Style: 0x52010000 ExStyle: 0x00010020 Handle: 0x000D1714 >>>> Mouse <<<< Position: 1051, 548 Cursor ID: 0 Color: 0xFFFFFF >>>> StatusBar <<<< >>>> ToolsBar <<<< >>>> Visible Text <<<< Search LCD section Application Podcast Help Account Controls View Edit File >>>> Hidden Text <<<< switch to miniplayer show next view show previous view airplay genius shuffle Link to comment Share on other sites More sharing options...
caramen Posted February 8, 2019 Share Posted February 8, 2019 (edited) with this : Advanced (Class): [CLASS:Static; INSTANCE:1] you can do this : Advanced (Class): ControlClick($hHND, "", "[CLASS:Static; INSTANCE:1]", 'right') But maybe it wont work. You will be sometime ( dépend of what you trying to automate ) obliged to use iuia-automation. Try controlclick first, the easy way. Edited February 8, 2019 by caramen My video tutorials : ( In construction ) || My Discord : https://discord.gg/S9AnwHw How to Ask Help || UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote Spoiler Water's UDFs:Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - Wiki Tutorials:ADO - Wiki Link to comment Share on other sites More sharing options...
modern Posted February 8, 2019 Author Share Posted February 8, 2019 14 minutes ago, caramen said: with this : Advanced (Class): [CLASS:Static; INSTANCE:1] you can do this : Advanced (Class): ControlClick($hHND, "", "[CLASS:Static; INSTANCE:1]", 'right') But maybe it wont work. You will be sometime ( dépend of what you trying to automate ) obliged to use iuia-automation. Try controlclick first, the easy way. Doing that now gives me: Link to comment Share on other sites More sharing options...
caramen Posted February 8, 2019 Share Posted February 8, 2019 Show full code please My video tutorials : ( In construction ) || My Discord : https://discord.gg/S9AnwHw How to Ask Help || UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote Spoiler Water's UDFs:Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - Wiki Tutorials:ADO - Wiki Link to comment Share on other sites More sharing options...
modern Posted February 8, 2019 Author Share Posted February 8, 2019 (edited) 3 minutes ago, caramen said: Show full code please expandcollapse popup; #INDEX# ======================================================================================================================= ; Title .........: iTunes Podcast Download Automation ; AutoIt Version : 1.0.0.0 ; Description ...: Automate downloading and removing podcast episodes in iTunes ; Author(s) .....: MODERN ; =============================================================================================================================== #include "WinAPI.au3" #include "WindowsConstants.au3" #include "iTunes.au3" HotKeySet("!a", "Main") ;wait for ALT-a keystroke, then go to Main() While 1 Sleep(100) WEnd Func Main() ; Run iTunes _iTunes_Start() ; Wait 30 seconds for the iTunes window to appear. Local $hWnd = WinWait("[CLASS:iTunes]", "", 30) WinActivate( "iTunes", "iTunes") ; Send a mouse click to the edit control of iTunes using the handle returned by WinWait. ControlClick($hHND, "", "[CLASS:Static; INSTANCE:1]", 'right') MouseClick("left") Send("{CTRLDOWN}a{CTRLUP}") While 1 MouseClick("left") Send("{CTRLDOWN}a{CTRLUP}") MouseClick("right") MouseClick("left") Sleep(2000) MouseClick("left") Send("{CTRLDOWN}a{CTRLUP}") MouseClick("right") MouseClick("left") Sleep(1800000) WEnd EndFunc Edited February 8, 2019 by modern Link to comment Share on other sites More sharing options...
caramen Posted February 8, 2019 Share Posted February 8, 2019 (edited) Dont say me you pasted this lol... m’y faut i guess. Advanced (Class): Remove this Line lol. Post what you included. I am talking to you with my iOS and i got hard Time to write sry Edited February 8, 2019 by caramen My video tutorials : ( In construction ) || My Discord : https://discord.gg/S9AnwHw How to Ask Help || UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote Spoiler Water's UDFs:Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - Wiki Tutorials:ADO - Wiki Link to comment Share on other sites More sharing options...
modern Posted February 8, 2019 Author Share Posted February 8, 2019 1 minute ago, caramen said: Dont say me you pasted this lol... m’y faut i guess. Advanced (Class): Remove this Line lol. Post what you included lol removing that I get Link to comment Share on other sites More sharing options...
caramen Posted February 8, 2019 Share Posted February 8, 2019 Ok this is the $hHND adapt to your needs. Please RUN in SciTE first My video tutorials : ( In construction ) || My Discord : https://discord.gg/S9AnwHw How to Ask Help || UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote Spoiler Water's UDFs:Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - Wiki Tutorials:ADO - Wiki Link to comment Share on other sites More sharing options...
caramen Posted February 8, 2019 Share Posted February 8, 2019 (edited) If you look carefully you just have to change one letter change $hHND to $hWND Edited February 8, 2019 by caramen My video tutorials : ( In construction ) || My Discord : https://discord.gg/S9AnwHw How to Ask Help || UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote Spoiler Water's UDFs:Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - Wiki Tutorials:ADO - Wiki Link to comment Share on other sites More sharing options...
modern Posted February 8, 2019 Author Share Posted February 8, 2019 Just now, caramen said: If you look carefully you just have to change one letter derp! haha i see it Link to comment Share on other sites More sharing options...
caramen Posted February 8, 2019 Share Posted February 8, 2019 Re Read all msg before. Becose i edited all. As i said my iPhone is not familiar with english. Same as me ;p. i gave you the answer. My video tutorials : ( In construction ) || My Discord : https://discord.gg/S9AnwHw How to Ask Help || UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote Spoiler Water's UDFs:Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - Wiki Tutorials:ADO - Wiki 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