Jump to content

Recommended Posts

Posted (edited)

Greetings everyone. I'm an AutoIT newbie and was wondering if anyone has any tips on this topic or a code snippet they could share. I have a use-case for a population of Win10 computers which have an autologon account which stays logged in where multiple health care people use (Imprivata tap-in) and upon a different human user tapping into the device I need to gracefully close Edge if it is running. Currently I have VB scripts called via Imprivata that do process kills for previous user processes upon new login of a different user but I've found you should not kill the Edge process because if the prior user had multiple tabs they get restored for the next user upon browser launch. I've tried a couple of registry keys posted on the Internet about turning off Edge browser tab recovery but have not found anything that actually works. So I think I want to have Imprivata call an AutoIT script that does a simple window close [x] of Edge. I know the popup confirmation window of multiple tabs on close adds to the code complexity but I have no objection to using a registry key to turn off that prompt. Thanks in advance for any help. Tested the attached script which closes Edge if it is minimized but not if it not minimized.

Edgeclose-test.au3

Edited by OliverGrey
Tested a script that does not work
Posted

I already tried ProcessClose. That's the same as a taskkill of the process which causes the tabs to be restored on next launch of Edge since Edge sees that as an app crash. I need to close the window, similar to clicking [X] in the browser. 

 

Posted (edited)

@OliverGrey
Doing this, and running this script, it does what you're looking for :)

Global $arrWindows

$arrWindows = WinList("[REGEXPTITLE:(?i).*\- Microsoft Edge]")

For $i = 1 To $arrWindows[0][0] Step 1

    ; Strange Behaviour - Even if the popup shows up, and the window(s) is/are not closed, the function returns 1 (tried with WinKill too)
    If WinClose($arrWindows[$i][1], $arrWindows[$i][0]) Then
        ConsoleWrite("Closing '" & $arrWindows[$i][0] & "' OK!" & @CRLF)
    Else
        ConsoleWrite("Closing '" & $arrWindows[$i][0] & "' ERR!" & @CRLF)
    EndIf
Next

 

Edited by FrancescoDiMuro

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

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
  • Recently Browsing   0 members

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