Single Out the number that does not repeat

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
User avatar
PepsiHog
Automation Wizard
Posts: 517
Joined: Wed Apr 08, 2009 4:19 pm
Location: Florida

Single Out the number that does not repeat

Post by PepsiHog » Wed Feb 25, 2015 4:21 pm

Hello,

I have a list of window handles. Only visible ones. Then I open a new window. Then I get the new list. I am trying to get the result to be the handle that does not repeat. (The window that was just opened.)

Code: Select all

let>WF_TYPE=2
let>win_usehandle=1
GetWindowList>VisibleOne
StringReplace>VisibleOne,crlf,;,VisibleOne
ExecuteFile>C:\Program Files\Google\Chrome\Application\chrome.exe,%AttWebPage%
wait>2
GetWindowList>VisibleTwo
StringReplace>VisibleTwo,crlf,;,VisibleTwo
let>Visible=%VisibleOne%%VisibleTwo%
RegEx>\b(\d+)\b(?=.*\b\1\b)(.*),Visible,0,match,nom,1,$1,IsLeft
mdl>(%IsLeft%)%crlf%%VisibleOne%%crlf%%VisibleTwo%
exit
If I use (?!=.*\b\1\b) it still shows all the others but removes the one I want. I want IsLeft to be the new window's handle.

Please help.

Thanks,
PepsiHog
Windows 7

PepsiHog. Yep! I drink LOTS of Pepsi (still..in 2024) AND enjoy programming. (That's my little piece of heaven!)

The immensity of the scope of possibilities within Macro Scheduler pushes the user beyond just macros!

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: Single Out the number that does not repeat

Post by Marcus Tettmar » Mon Mar 02, 2015 3:21 pm

I'm not sure I understand what you want to do or whether RegEx is right for this. Can you show an example?
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

mightycpa
Automation Wizard
Posts: 343
Joined: Mon Jan 12, 2004 4:07 pm
Location: Vienna, VA

Re: Single Out the number that does not repeat

Post by mightycpa » Tue Mar 03, 2015 4:50 pm

I do something like this for a dialog... if a user clicks on an item, and it already exists in the target dialog, then ignore it.

You can do this in a loop, but I'd also be interested in seeing it done with regular expressions.

Code: Select all

Let>VAREXPLICIT=0
let>WF_TYPE=2
let>win_usehandle=1
GetWindowList>VisibleOne
Separate>VisibleOne,crlf,v_old_list
wait>5
ExecuteFile>notepad.exe
wait>5
GetWindowList>VisibleTwo
Separate>VisibleTwo,crlf,v_new_list
If>v_old_list_count=v_new_list_count
  Goto>End
Endif
Let>v_decide=0
Let>v_new_items=
Let>v_delim=;
Let>k=0
Repeat>k
  Let>v_decide=0
  Let>k=k+1
  Let>j=0
  Repeat>j
    Let>j=j+1
    Let>v_new=v_new_list_%k%
    Let>v_old=v_old_list_%j%
      //MessageModal>v_old vs.  v_new
    If>%v_old%=%v_new%
      Let>v_decide=1
    Else
      Let>v_decide=v_decide+0
    Endif
  Until>j,v_new_list_count
  If>v_decide=0
      Concat>v_new_items,v_new
      //just in case there's more than one new window
      Concat>v_new_items,v_delim
  Endif
Until>k,v_old_list_count
Length>v_new_items,v_too_long
If>v_too_long=0
  Goto>End
Endif>
Let>v_just_right=v_too_long-1
MidStr>v_new_items,1,v_just_right,v_the_answer
MessageModal>v_the_answer
Label>End
I wrote this a little inefficiently for clarity.
"A facility for quotation covers the absence of original thought." - Lord Peter Wimsey

User avatar
PepsiHog
Automation Wizard
Posts: 517
Joined: Wed Apr 08, 2009 4:19 pm
Location: Florida

Re: Single Out the number that does not repeat

Post by PepsiHog » Fri Apr 03, 2015 3:08 pm

I am attempting to (1)get all window handles that are visible. This is the list of windows currently open. (2) Now I open a new instance of Google Chrome. (3)I get a list of all window handles again. (4)I want to remove the window handles that repeat. The new one just opened should be the only one that does not repeat in the list.

Simply put, I have a list of numbers. Some of those numbers repeat. Those numbers I want to exclude from the list. I have tried pos look-ahead and neg look-ahead. But both seem to exclude the window handle that I actually want. Can't say I understand why.

Comment: Boy, right when you think you're getting RegEx.......you get one that stumps you. Makes me realize how much I DON'T know. LOL!

Thanks for everyone that is trying to help. Sorry, I'm working on other projects as well, so I haven't been minding this post.

PepsiHog
Windows 7

PepsiHog. Yep! I drink LOTS of Pepsi (still..in 2024) AND enjoy programming. (That's my little piece of heaven!)

The immensity of the scope of possibilities within Macro Scheduler pushes the user beyond just macros!

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts