Jump to content


Photo

Use of 'or' variable and what to do if window title changes


  • Please log in to reply
2 replies to this topic

#1 jamieblue

jamieblue
  • Members
  • 2 posts

Posted 15 July 2012 - 07:08 PM

I'm new to making scripts - just made my first one yesterday! Quite exciting!!

Anyway, it's just a simple script I guess that involves using facebook. If you want I can provide you with the WORKING (but as you'll see not ideal) code. Here is the code so far:

Loop, 200
{ 
  WinWait, Marvel: Avengers Alliance on Facebook - Google Chrome, 
  IfWinNotActive, Marvel: Avengers Alliance on Facebook - Google Chrome, , WinActivate, Marvel: Avengers Alliance on Facebook - Google Chrome, 
  WinWaitActive, Marvel: Avengers Alliance on Facebook - Google Chrome, 
  MouseClick, left,  903,  618
  MouseClick, left,  903,  618
  Sleep, 387
  MouseClick, left,  502,  442
  MouseClick, left,  502,  442
  Sleep, 367
  MouseClick, left,  593,  410
  MouseClick, left,  593,  410
  Sleep, 402
  MouseClick, left,  891,  749
  MouseClick, left,  891,  749
  Sleep, 398
  MouseClick, left,  876,  596
  MouseClick, left,  876,  596
  Sleep, 295
  MouseClick, left,  581,  442
  MouseClick, left,  581,  442
  Sleep, 201
  MouseClick, left,  887,  731
  MouseClick, left,  887,  731
  Sleep, 273
  MouseClick, left,  822,  582
  MouseClick, left,  822,  582
  Sleep, 305
  MouseClick, left,  598,  448
  MouseClick, left,  598,  448
  Sleep, 298
  MouseClick, left,  861,  757
  MouseClick, left,  861,  757
  Sleep, 306
  MouseClick, left,  801,  556
  MouseClick, left,  801,  556
  Sleep, 312
  MouseClick, left,  599,  450
  MouseClick, left,  599,  450
  Sleep, 341
  MouseClick, left,  878,  743
  MouseClick, left,  878,  743
  Sleep, 299
  MouseClick, left,  761,  542
  MouseClick, left,  761,  542
  Sleep, 301
  MouseClick, left,  582,  447
  MouseClick, left,  582,  447
  Sleep, 309
  MouseClick, left,  835,  728
  MouseClick, left,  835,  728
  Sleep, 329
  MouseClick, left,  724,  526
  MouseClick, left,  724,  526
  Sleep, 326
  MouseClick, left,  594,  437
  MouseClick, left,  594,  437
  Sleep, 298
  MouseClick, left,  814,  734
  MouseClick, left,  814,  734
  Sleep, 286
  MouseClick, left,  686,  499
  MouseClick, left,  686,  499
  Sleep, 288
  MouseClick, left,  594,  440
  MouseClick, left,  594,  440
  Sleep, 299
  MouseClick, left,  816,  743
  MouseClick, left,  816,  743
  Sleep, 308
  MouseClick, left,  658,  484
  MouseClick, left,  658,  484
  Sleep, 204
  MouseClick, left,  591,  409
  MouseClick, left,  591,  409
  Sleep, 267
  MouseClick, left,  828,  732
  MouseClick, left,  828,  732
  Sleep, 245
  MouseClick, left,  907,  543
  MouseClick, left,  907,  543
  Sleep, 182000
  WinWait, Marvel: Avengers Alliance on Facebook - Google Chrome, 
  IfWinNotActive, Marvel: Avengers Alliance on Facebook - Google Chrome, , WinActivate, Marvel: Avengers Alliance on Facebook - Google Chrome, 
  WinWaitActive, Marvel: Avengers Alliance on Facebook - Google Chrome, 
  MouseClick, left,  904,  624
  Sleep, 279
  MouseClick, left,  910,  662
  Sleep, 6089
}
Esc::ExitApp

The problem I've got is that if I get a notification on facebook, the title of the window changes. For example, it goes to '(1) Marvel: Avengers...' etc. So as soon as I get a notification it stops working.. :evil:

I tried to put in an 'or' function, so like basically 'or (1) Marvel Avengers...' etc after every original title; but this didn't seem to work...

Anyone got any ideas on what I could do? I thought about if functions too but got a bit confused :roll:

#2 girlgamer

girlgamer
  • Moderators
  • 2039 posts

Posted 15 July 2012 - 07:46 PM

First what you need is to find out the differences between the two window titles then focus on what is unique to each title. Then you do a WinActivate in your script using the unique part of the title. If you use WinWaitActive, and the title changes, the script will wait til the window again becomes active. you could also check to see if the title contains an open parenthesis '(' in the title and move or not move based on that.

#3 jamieblue

jamieblue
  • Members
  • 2 posts

Posted 15 July 2012 - 07:59 PM

Thanks for the response.

The only difference between the changing titles is if they either have brackets with different numbers before the title or not.

If I just add:

SetTitleMatchMode, 2
SetTitleMatchMode, Fast

as the first line below the loop command to the code, and again further down, this will be okay right? Since it's saying that you only need the core part of the title only (the bit which really matters) for it to execute.

Will just have to wait and see what happens when I get a notification to see if it works I guess.. :p

*Update/edit: .. It worked! :p