Betrayal Posted November 28, 2013 Posted November 28, 2013 Hi, I'm relatively new to AutoIT, and my problem is that I don't know how to send the letter "a" to two Notepads in the background. Global $WinTitle ="Untitled - Notepad" While 1 If WinExists($WinTitle) Then ControlSend($WinTitle, "", "", "a", 1) Else Exit EndIf WEnd This, I believe, only works on one (the most recent one?). I want it to work on both. What I'm planning to do later is close and save them, one of them as the current month, the other as the current day. But that's a different problem from the one I have right now, calling each instance individually. Thanks in advance.
Moderators Melba23 Posted November 28, 2013 Moderators Posted November 28, 2013 Betrayal,Welcome to the AutoIt forum. Use WinList to get an array of the existing Notepad GUIs - then loop through the array using the returned handles, rather than the title, in the ControlSend call. Better still, use [CLASS:Edit; INSTANCE:1] as the controlID parameter. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
Betrayal Posted November 28, 2013 Author Posted November 28, 2013 Betrayal, Welcome to the AutoIt forum. Use WinList to get an array of the existing Notepad GUIs - then loop through the array using the returned handles, rather than the title, in the ControlSend call. Better still, use [CLASS:Edit; INSTANCE:1] as the controlID parameter. M23 Oh, that would solve both my problems. I'll try it out in a few minutes.
Moderators Melba23 Posted November 28, 2013 Moderators Posted November 28, 2013 Betrayal,When you reply, please use the "Reply to this topic" button at the top of the thread or the "Reply to this topic" editor at the bottom rather than the "Quote" button - I know what I wrote and it just pads the thread unneccessarily. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
Betrayal Posted November 28, 2013 Author Posted November 28, 2013 My apologies. So the basis of this method consists of looping through all instances with the same name, correct? I also don't know where I can find information on Control ID; I don't know what that is, but I do know that it is a parameter. Thanks, Betrayal.
Moderators Melba23 Posted November 28, 2013 Moderators Posted November 28, 2013 Betrayal,No problem - now you know. So the basis of this method consists of looping through all instances with the same nameExactly. where I can find information on Control IDLook in the Help file (which should become a reflex action) under <Using AutoIt - Controls>. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
Betrayal Posted November 28, 2013 Author Posted November 28, 2013 Not exactly sure how this works. It writes 'a' twice to one of the documents. I know that $list[0][0] returns 2. $list = WinList("Untitled - Notepad") For $i = 1 To $list[0][0] If WinExists($list[$i][0]) Then ControlSend($list[$i][0], "", "[CLASS:Edit; INSTANCE:1]", "a", 1) Else Exit EndIf Next
monax Posted November 29, 2013 Posted November 29, 2013 $list = WinList("[CLASS:Notepad]") For $i = 1 To $list[0][0] $controlHandle = ControlGetHandle($list[$i][1],"","[CLASS:Edit]") ControlSend("","",$controlHandle,"a") Next There you go
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