Close app

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
HSEIVANE
Junior Coder
Posts: 33
Joined: Thu Jan 02, 2020 2:52 am

Close app

Post by HSEIVANE » Sat Jan 04, 2020 12:17 pm

Hello all,

I want to check if chrome is opened, if yes, close it.

How do I do it?

Thanks

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1350
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: Close app

Post by Dorian (MJT support) » Mon Jan 06, 2020 11:39 am

Hi, yes we can do that. Use GetWindowList to generate a list of all open windows, then loop through them looking for "Google Chrome" in the title, and if it exists, close the window.

Code: Select all

GetWindowList>winlist
Separate>winlist,CRLF,windows
Let>k=1
Repeat>k
  Let>this=windows_%k%

  //Does the Window title contain "Google Chrome"?
  Pos>Google Chrome,%this%,1,ChrPos,
  
  //if yes, do something
  If>ChrPos>0
    CloseWindow>%this%
  Endif
  
  Let>k=k+1
Until>k>windows_count
Yes, we have a Custom Scripting Service. Message me or go here

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