# Perspective: Scripting a Momentary Button

**URL:** <https://forum.inductiveautomation.com/t/perspective-scripting-a-momentary-button/35684>\
**Category:** Ignition\
**Tags:** ignition80, perspective\
**Created:** [June 15, 2020, 11:32pm UTC](https://forum.inductiveautomation.com/t/perspective-scripting-a-momentary-button/35684 "2020-06-15T23:32:09Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![AIO](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/aio/32/87549_2.png) [@AIO](https://forum.inductiveautomation.com/u/AIO)\
**Post date:** [June 15, 2020, 11:32pm UTC](https://forum.inductiveautomation.com/t/perspective-scripting-a-momentary-button/35684/1 "2020-06-15T23:32:09Z")

</div>

Hey folks,

Ignition 8.0.7

I’m trying to implement a momentary button in Perspective, but the feature doesn’t appear to be available. The One-Shot Button documentation states, [“If your PLC expects the HMI to reset the bit, use the Momentary Button.”](https://docs.inductiveautomation.com/display/DOC80/Perspective+-+One-Shot+Button)

Since it seems as though the feature is not yet supported, does anyone have an example script for the button component that can reliably perform the Momentary function? I’m having a hard time replicating the function of the momentary button from Vision, and altering the PLC code is sub-optimal.

Much appreciated!

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [June 16, 2020, 12:00am UTC](https://forum.inductiveautomation.com/t/perspective-scripting-a-momentary-button/35684/2 "2020-06-16T00:00:27Z")

</div>

I wouldn’t be using momentary buttons in _ **any** _ SCADA platform. They are inherently flawed, as any comms hiccup will leave the bit high. I’ve seen this on many occasions  
I suggest you fix it in the PLC by resetting the bit. If you need push-to-activate, then use a local hardwired input.

EDIT: If you (or rather the customer) **really** want to do it (which you/they shouldn’t), then you can use the onMouseDown and onMouseUp event handlers to write to the tag

---

<div class="post-metadata">

**Author:** ![AIO](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/aio/32/87549_2.png) [@AIO](https://forum.inductiveautomation.com/u/AIO)\
**Post date:** [June 16, 2020, 12:04am UTC](https://forum.inductiveautomation.com/t/perspective-scripting-a-momentary-button/35684/3 "2020-06-16T00:04:54Z")

</div>

I appreciate the input, and I agree.

Unfortunately, I’ve been asked to port over the vision functionality for a client without affecting the PLC (I do not have access to the PLC currently). So while I agree with your solution, my question still stands.

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [June 16, 2020, 12:05am UTC](https://forum.inductiveautomation.com/t/perspective-scripting-a-momentary-button/35684/4 "2020-06-16T00:05:19Z")

</div>

See my edit above

> [@nminchin](#):
>
> EDIT: If you (or rather the customer) **really** want to do it (which you/they shouldn’t), then you can use the onMouseDown and onMouseUp event handlers to write to the tag

---

<div class="post-metadata">

**Author:** ![aspatchek2013](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/aspatchek2013/32/85339_2.png) [@aspatchek2013](https://forum.inductiveautomation.com/u/aspatchek2013)\
**Post date:** [April 1, 2021, 6:41pm UTC](https://forum.inductiveautomation.com/t/perspective-scripting-a-momentary-button/35684/5 "2021-04-01T18:41:33Z")

</div>

I had the same application where I could not alter the PLC code and needed a momentary script. This would write a tag on, delay 1.5 seconds, and then write it off again.

```auto
from threading import Timer

def writeOn():
    system.tag.write("[default]Testing Tags/Bool Test", 1)
def delayOff():
    system.tag.write("[default]Testing Tags/Bool Test", 0)

writeOn()
t = Timer(1.5, delayOff)
t.start()

```

Again, as stated - it is not recommended as there is no way to guarantee it gets written off again. However, it works in a pinch.

---

<div class="post-metadata">

**Author:** ![richard\_espinal](https://avatars.discourse-cdn.com/v4/letter/r/8797f3/32.png) [@richard\_espinal](https://forum.inductiveautomation.com/u/richard_espinal)\
**Post date:** [May 11, 2024, 6:35pm UTC](https://forum.inductiveautomation.com/t/perspective-scripting-a-momentary-button/35684/6 "2024-05-11T18:35:12Z")

</div>

i have this issue how can i put it back the way it was ? i wrote this:

````python
import time
system.tag.write("[default]IS15_Overheight_Rst_PB", 1)
time.sleep(1)
system.tag.write("[default]IS15_Overheight_Rst_PB", 0)

```now i want everything back to normal because my plc keep show 1 and that deactivates when the sensor is blocked but activates right way after the sensor is unblock. please advice
````

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [May 11, 2024, 6:57pm UTC](https://forum.inductiveautomation.com/t/perspective-scripting-a-momentary-button/35684/7 "2024-05-11T18:57:15Z")

</div>

> [@richard\_espinal](#):
>
> i have this issue

Please don't double-post. [Persistent Tag Issue and Forced Value in PLC After Script Execution - #5 by Transistor](https://forum.inductiveautomation.com/t/persistent-tag-issue-and-forced-value-in-plc-after-script-execution/90271/5).

---

<div class="post-metadata">

**Author:** ![akaric](https://avatars.discourse-cdn.com/v4/letter/a/a88e57/32.png) [@akaric](https://forum.inductiveautomation.com/u/akaric)\
**Post date:** [April 11, 2026, 10:15am UTC](https://forum.inductiveautomation.com/t/perspective-scripting-a-momentary-button/35684/8 "2026-04-11T10:15:11Z")

</div>

Unfortunately, even though I did NOT want to accept it, I learned it the harder way that you are 100% right.  
Pre-SCADA days, all of my programs used to rely on momentary HMI buttons and it was very hard for me to accept that moving to SCADA this is not going to work. Especially with perspective, and portability to tablets and touchscreens, it is just NOT POSSIBLE to introduce momentary button function that will be reliable. I hope one day somebody will be able to prove you wrong but I doubt it will be soon.  
After so many painful experiences and frustration, I just learned to accept the fact and move on. Designed very simple function block to reset the bits being set by buttons in perspective, and never looked back.

Thank you!
