Enable and Disable One Event

Ideas for new features & functions

Moderators: Dorian (MJT support), JRL

Post Reply
User avatar
Rain
Automation Wizard
Posts: 550
Joined: Tue Aug 09, 2005 5:02 pm
Contact:

Enable and Disable One Event

Post by Rain » Wed Oct 10, 2012 7:08 pm

I really like OneEvent, my only problem is that once an Event handler is activated it remains active until you exit the script. My Suggestion is to be able to disable and enable OneEvent. There are areas in my scripts I don't want event handlers to branch to the specified Subroutine when the event occurs.

E.g.

Let>DISABLE_ONEVENT=True

Let>DISABLE_ONEVENT=False

Thank you listening.

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

Post by Marcus Tettmar » Wed Oct 10, 2012 7:17 pm

You already can. Just specify a null string for the subroutine for the same event handler setup:

//enable
OnEvent>KEY_DOWN,VK32,0,KeyPress

...
...

//disable it
OnEvent>KEY_DOWN,VK32,0,

..
..

//enable it again
OnEvent>KEY_DOWN,VK32,0,KeyPress
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

User avatar
Rain
Automation Wizard
Posts: 550
Joined: Tue Aug 09, 2005 5:02 pm
Contact:

Post by Rain » Thu Oct 11, 2012 3:48 pm

Thanks Marcus!
I never thought to try that. Might be worth adding to the help file.

User avatar
jpuziano
Automation Wizard
Posts: 1085
Joined: Sat Oct 30, 2004 12:00 am

Post by jpuziano » Sat Oct 13, 2012 11:24 am

Rain wrote:Thanks Marcus!
I never thought to try that. Might be worth adding to the help file.
Neither did I... Yes, please add to help file... thanks and take care.
jpuziano

Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post - :-)

User avatar
migro
Macro Veteran
Posts: 152
Joined: Thu Nov 06, 2003 5:23 pm
Location: Germany
Contact:

Re: Enable and Disable One Event

Post by migro » Sun Nov 29, 2015 7:47 pm

Is there a known issue when jumping into a subroutine by using an dialog handler instead of Gosub>?
I like to give the opportunity closing the dialog by pressing the ESC key. But also want to avoid closing the Macro while running a subroutine with some actions.

See the following sample code:

Code: Select all

Dialog>Dialog1
object Dialog1: TForm
  Left = 3521
  Top = 278
  HelpContext = 5000
  BorderIcons = [biSystemMenu]
  Caption = 'CustomDialog'
  ClientHeight = 113
  ClientWidth = 476
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = True
  ShowHint = True
  OnTaskBar = False
  PixelsPerInch = 96
  TextHeight = 13
  object BtnStart: tMSButton
    Left = 202
    Top = 40
    Width = 75
    Height = 25
    Caption = 'Start'
    TabOrder = 8
    DoBrowse = False
    BrowseStyle = fbOpen
  end
end
EndDialog>Dialog1


Let>strActivateESC=True
Gosub>OnEventKey

AddDialogHandler>Dialog1,BtnStart,OnClick,DoAction
#Gosub>DoAction


Label>DlgShow
   Show>Dialog1,r


SRT>OnEventKey
   If>strActivateESC=True
      OnEvent>KEY_DOWN,VK27,0,DoClose
   ELSE
      OnEvent>KEY_DOWN,VK27,0,
   ENDIF
End>OnEventKey

SRT>DoAction
   MDL>Start Subroutine
   Let>strActivateESC=False
   Gosub>OnEventKey
   Wait>10
   MDL>Stop
END>DoAction

SRT>DoClose
   Exit>0
END>DoClose

Label>Exit
When using a dialog handler the onEvent handler isn't deaktivated.
In my productive script the subroutine hangs when jumping from the "DoAction" subroutine to OnEventKey to disable it.
regards
migro

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Re: Enable and Disable One Event

Post by JRL » Mon Nov 30, 2015 2:33 pm

Looks to me like this could be related to the issue hagchr reported in this thread

User avatar
migro
Macro Veteran
Posts: 152
Joined: Thu Nov 06, 2003 5:23 pm
Location: Germany
Contact:

Re: Enable and Disable One Event

Post by migro » Mon Nov 30, 2015 11:04 pm

Thx for the link, it looks very similar. Have you got any response from marcus upon your bugreport?
regards
migro

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