c7aesa7r Posted September 10, 2017 Posted September 10, 2017 (edited) $key = "{ctrldown}{a}{ctrlup}{backspace}{tab}{ctrldown}{a}{ctrlup}{backspace}{t}{o}{d}{a}{y}{tab}{i}{n}{}{h}{o}" $winList = WinList("[TITLE:WhatsApp]", "") For $i = 1 to $winList[0][0] $title = $winList[$i][0] $handle = $winList[$i][1] $controlid = "" $text = "" ControlSend($handle,$text,$controlid,$key) Next Exit Is possible edit that script to work with multiple window titles? I tried edit it to work with multiple windows titles, with no success $winList = WinList("[TITLE:WhatsApp,Joana,Carlos]", "") ? $winList = WinList("[TITLE:WhatsApp]", ""),WinList("[TITLE:Joana]", ""),WinList("[TITLE:Carlos]", "") Edited September 10, 2017 by c7aesa7r
MattHiggs Posted September 11, 2017 Posted September 11, 2017 8 minutes ago, c7aesa7r said: $key = "{ctrldown}{a}{ctrlup}{backspace}{tab}{ctrldown}{a}{ctrlup}{backspace}{t}{o}{d}{a}{y}{tab}{i}{n}{}{h}{o}" $winList = WinList("[TITLE:WhatsApp]", "") For $i = 1 to $winList[0][0] $title = $winList[$i][0] $handle = $winList[$i][1] $controlid = "" $text = "" ControlSend($handle,$text,$controlid,$key) Next Exit Is possible edit that script to work with multiple window titles? I tried edit it to work with multiple windows titles, with no success $winList = WinList("[TITLE:WhatsApp,Joana,Carlos]", "") ? $winList = WinList("[TITLE:WhatsApp]", ""),WinList("[TITLE:Joana]", ""),WinList("[TITLE:Carlos]", "") If you want to use multiple windows, you will need to assign them to different variables: $winlist1 = WinList("WhatsApp") $winlist2 = WinList("Joana") $winlist3 = WinList("Carlos") BTW, "title" is automatically implied as the first parameter to Winlist. You don't have to explicitly declare it. And the "text" parameter is optional and does not need to be included if you just leave it blank. But let me also ask: I assume you are trying to automate Whatsapp windows, is that correct? If so, use the Autoit Window info tool and see what the "Class" property for the windows you are trying to automate is. If the class property is the same for all of them, then you can modify your script to simply read: $winlist = Winlist ("[CLASS:<name>]") Where "<name>" is whatever the value is
c7aesa7r Posted September 11, 2017 Author Posted September 11, 2017 (edited) Thanks for willing to help, and sorry I did not express myself well. What im trying is send different messages to different windows. $key1 = {h}{i} $key2 = {h}{e}{l}{l}{o} $winlist1 = WinList("Carlos") $winlist2 = WinList("Joana") I need know how edit the script to work this way. I cant use: $winlist = Winlist ("[CLASS:<name>]") Because all windows have the same class name, they just differ in the title. My actual script, just send the key1 to first window, and dont send key2 to the second $key1 = "{a}" $key2 = "{b}" $key3 = "{c}" $winlist1 = WinList("Carlos") $winlist2 = WinList("Joana") $winlist3 = WinList("Fenne") For $i = 1 to $winList1[0][0] $title = $winList1[$i][0] $handle = $winList1[$i][1] $controlid = "" $text = "" ControlSend($handle,$text,$controlid,$key1) Next Exit For $i = 1 to $winList2[0][0] $title = $winList2[$i][0] $handle = $winList2[$i][1] $controlid = "" $text = "" ControlSend($handle,$text,$controlid,$key2) Next Exit Edited September 11, 2017 by c7aesa7r
Andreik Posted September 11, 2017 Posted September 11, 2017 Use AutoItSetOption() like this: AutoItSetOption("WinTextMatchMode",2) ;Send something to Joana $hWin = WinGetHandle("Joana") ControlSend($hWin,'',[ControlID],[Message])
jguinch Posted September 11, 2017 Posted September 11, 2017 ... or REGEXPTITLE with WinList() #Include <Array.au3> Local $aList = WinList("[REGEXPTITLE:(?i)WhatsApp|Joana|Carlos]") _ArrayDisplay($aList) Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF
c7aesa7r Posted September 11, 2017 Author Posted September 11, 2017 Guys could give me a example, how to make it work with 2 title string, then i can edit as many i need?
c7aesa7r Posted September 11, 2017 Author Posted September 11, 2017 (edited) -EDIT- I got it working this way: $key1 = "{a}" $key2 = "{b}" AutoItSetOption("WinTextMatchMode",2) ;Send something to Joana $hWin = WinGetHandle("Joana") $hWin2 = WinGetHandle("Carlos") $controlid = "" $text = "" ControlSend($hWin,$text,$controlid,$key1) ControlSend($hWin2,$text,$controlid,$key2) Could it get better? Is possible insert delay between keys send? Example: $key1 = "{a}, sleep(500), {b}" Edited September 11, 2017 by c7aesa7r
Andreik Posted September 13, 2017 Posted September 13, 2017 I'm not sure if you talk about delay between two ControlSend() calls or the delay between keystrokes. In first case: ControlSend($hWin,$text,$controlid,$key1) Sleep(1000) ; Pause 1 second ControlSend($hWin2,$text,$controlid,$key2) In the second case you have to set the flag SendKeyDelay: AutoItSetOption("SendKeyDelay","1000")
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