Jump to content

How to work with multiple windows title


c7aesa7r
 Share

Recommended Posts

$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 :lol:

$winList = WinList("[TITLE:WhatsApp,Joana,Carlos]",  "")

?

$winList = WinList("[TITLE:WhatsApp]",  ""),WinList("[TITLE:Joana]",  ""),WinList("[TITLE:Carlos]",  "")

 

Edited by c7aesa7r
Link to comment
Share on other sites

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 :lol:

$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

Link to comment
Share on other sites

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 by c7aesa7r
Link to comment
Share on other sites

-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 by c7aesa7r
Link to comment
Share on other sites

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")

 

When the words fail... music speaks.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...