# I can't get the confirm button yes of Sytem.gui.confirm?

**URL:** <https://forum.inductiveautomation.com/t/i-cant-get-the-confirm-button-yes-of-sytem-gui-confirm/56227>\
**Category:** Ignition\
**Created:** [February 16, 2022, 6:08pm UTC](https://forum.inductiveautomation.com/t/i-cant-get-the-confirm-button-yes-of-sytem-gui-confirm/56227 "2022-02-16T18:08:47Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Esme\_Lopez](https://avatars.discourse-cdn.com/v4/letter/e/ecb155/32.png) [@Esme\_Lopez](https://forum.inductiveautomation.com/u/Esme_Lopez)\
**Post date:** [February 16, 2022, 6:08pm UTC](https://forum.inductiveautomation.com/t/i-cant-get-the-confirm-button-yes-of-sytem-gui-confirm/56227/1 "2022-02-16T18:08:47Z")

</div>

I want to get the confirm button YES

---

<div class="post-metadata">

**Author:** ![andrews](https://avatars.discourse-cdn.com/v4/letter/a/898d66/32.png) [@andrews](https://forum.inductiveautomation.com/u/andrews)\
**Post date:** [February 16, 2022, 6:09pm UTC](https://forum.inductiveautomation.com/t/i-cant-get-the-confirm-button-yes-of-sytem-gui-confirm/56227/2 "2022-02-16T18:09:55Z")

</div>

Can you please share your current code, or explain what you are trying to do?

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [February 16, 2022, 6:16pm UTC](https://forum.inductiveautomation.com/t/i-cant-get-the-confirm-button-yes-of-sytem-gui-confirm/56227/3 "2022-02-16T18:16:45Z")

</div>

system.gui.confirm(“some message”) returns a bool per the documentation.

[https://docs.inductiveautomation.com/display/DOC79/system.gui.confirm](https://docs.inductiveautomation.com/display/DOC79/system.gui.confirm)

If the user clicks “Yes” then `system.gui.confirm("some message")` returns a True, or a 1.

This allows it to be used like so -

```auto
if system.gui.confirm("Are you sure you want to shutdown the plant?",
 "Really Shutdown?"):
   system.db.runUpdateQuery("UPDATE ControlTable SET Shutdown=1")

```

---

<div class="post-metadata">

**Author:** ![Esme\_Lopez](https://avatars.discourse-cdn.com/v4/letter/e/ecb155/32.png) [@Esme\_Lopez](https://forum.inductiveautomation.com/u/Esme_Lopez)\
**Post date:** [February 16, 2022, 6:18pm UTC](https://forum.inductiveautomation.com/t/i-cant-get-the-confirm-button-yes-of-sytem-gui-confirm/56227/4 "2022-02-16T18:18:18Z")

</div>

Yes, but I need to catch the event at the moment to press YES in the gui.confirm.  
That is what I am trying to do.  
And then change an user after press YES

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [February 16, 2022, 6:19pm UTC](https://forum.inductiveautomation.com/t/i-cant-get-the-confirm-button-yes-of-sytem-gui-confirm/56227/5 "2022-02-16T18:19:04Z")

</div>

It blocks the entire UI thread. What do you mean you need to catch the moment? You need the timestamp it is clicked?

Edit: Just saw your comment. I don’t see why you can’t use it the way I provided

```auto
if system.gui.confirm("Change user?"):
    # Logic to change user here

```

---

<div class="post-metadata">

**Author:** ![Esme\_Lopez](https://avatars.discourse-cdn.com/v4/letter/e/ecb155/32.png) [@Esme\_Lopez](https://forum.inductiveautomation.com/u/Esme_Lopez)\
**Post date:** [February 16, 2022, 6:26pm UTC](https://forum.inductiveautomation.com/t/i-cant-get-the-confirm-button-yes-of-sytem-gui-confirm/56227/6 "2022-02-16T18:26:46Z")

</div>

## Code:

system.gui.confirm(u'Do you want to close?', 'Confirm')

username = "user"  
password="1234"

## success = system.security.switchUser(username,password,event)

This works with a button but I need it in the client menu bar but needs an event ((username,password,event)) and I want to get the component of the window trying to do something like:

if system.gui.confirm = YES:  
Then change the user (but I still need the event )

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [February 16, 2022, 6:32pm UTC](https://forum.inductiveautomation.com/t/i-cant-get-the-confirm-button-yes-of-sytem-gui-confirm/56227/7 "2022-02-16T18:32:43Z")

</div>

Use triple backticks to format your code  
```

```auto
if something:
    #do something

```

```  
it’s heard to read otherwise.

If it’s in a client menu bar then you’re taking it out of all windows and it’s not asscoiated with a window. Either put it in a window and you can look at the parent window. Or if it’s the client menu bar and you want to see what windows are opened to do some extra logic on that, you can use `system.gui.getOpenedWindowNames` [system.gui.getOpenedWindowNames - Ignition User Manual 8.0 - Ignition Documentation](https://docs.inductiveautomation.com/display/DOC80/system.gui.getOpenedWindowNames)

---

<div class="post-metadata">

**Author:** ![Esme\_Lopez](https://avatars.discourse-cdn.com/v4/letter/e/ecb155/32.png) [@Esme\_Lopez](https://forum.inductiveautomation.com/u/Esme_Lopez)\
**Post date:** [February 16, 2022, 7:06pm UTC](https://forum.inductiveautomation.com/t/i-cant-get-the-confirm-button-yes-of-sytem-gui-confirm/56227/8 "2022-02-16T19:06:54Z")

</div>

OK thanks, and with this:  
success = system.security.switchUser(username,password,event)  
It is the only way to switch to other user?

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [February 16, 2022, 7:09pm UTC](https://forum.inductiveautomation.com/t/i-cant-get-the-confirm-button-yes-of-sytem-gui-confirm/56227/9 "2022-02-16T19:09:45Z")

</div>

According to the documentation  
[system.security.switchUser - Ignition User Manual 8.1 - Ignition Documentation](https://docs.inductiveautomation.com/display/DOC81/system.security.switchUser#:~:text=Attempts%20to%20switch%20the%20current,states%20that%20they%20were%20in).

The third parameter -  
EventObject event - **If specified** , the enclosing window for this event’s component will be closed in the switch user process. Refer to the list of [Event](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/EventObject.html) objects.

So it seems like an optional argument. I don’t think you need to pass the event - only if you are doing this from within a window, and want the window to close upon a successful switching of the users.

This then - `success = system.security.switchUser(username,password)` should suffice.
