Disable onEvent not working? And how to make ripple through?

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
Dick99999
Pro Scripter
Posts: 84
Joined: Thu Nov 27, 2008 10:25 am
Location: Netherlands

Disable onEvent not working? And how to make ripple through?

Post by Dick99999 » Tue Nov 19, 2013 6:56 pm

The following script reacts on a left mouse click. When the first click is caught by the event handler, the handler is disabled by my code.

However, it seems that the disabling the handler is not working. The handler is being called by all clicks after the first click.

One more question I have, it seems that mouse click do not ripple through to other windows handlers, so the click is just caught by my handler. Is there any way to let the click go on?

Code: Select all

SetFocus>firefox*
let>n=0
//
onevent>key_down,VK1,0,doMouseClick
label>idle_loop
wait>1
goto>idle_loop
//
// SRT called on tap
srt>doMouseClick
**BREAKPOINT**
onevent>key_down,VK1,0,
Let>WIN_USEHANDLE=1
Let>GAW_TYPE=0
GetActiveWindow>activeWn,actWinX,actWinY,actWinW,actWinH
// get tap X,Y and relative to window
END>doMouseClick

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 Nov 27, 2013 9:28 am

Naturally this will fire several times as the event is detected several times WHILE the key is down. Perhaps detecting a key going UP is better?

Don't think you can "ripple through".
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

AnomalyNick
Newbie
Posts: 3
Joined: Thu Nov 28, 2013 2:03 am
Location: Australia
Contact:

CUSTOM OnEvent handler

Post by AnomalyNick » Thu Nov 28, 2013 2:25 am

I have a similar problem. I cant disable a CUSTOM OnEvent handler. I use the disable command with and without the Extra parm and it makes no difference. I step through the code and it just keeps looping through WAIT-FOR-MACACTION after it has completed the MACACTION-FAILED routine.
Thanks,
Nick

Code: Select all

at start ...

// Setup OnEvent processes
///////////////////////////////////////////////////////////////////
OnEvent>FILE_EXISTS,%BotFolder%\MacAction.txt,0,PROCESS-ACTION
OnEvent>WINDOW_OPEN,Microsoft Visual Basic,2,CLOSE-VB-ERROR-WINDOW
OnEvent>CUSTOM,WAIT-FOR-MACACTION,Flag_MacAction_Failed,MACACTION-FAILED
///////////////////////////////////////////////////////////////////

then later on ...

SRT>MACACTION-FAILED
//********************
Let>Flag_MacAction_Failed=FALSE
// Temporarily Disable On Event proceeses
OnEvent>FILE_EXISTS,%BotFolder%\MacAction.txt,0,
OnEvent>WINDOW_OPEN,Microsoft Visual Basic,2,
OnEvent>CUSTOM,WAIT-FOR-MACACTION,,

Dick99999
Pro Scripter
Posts: 84
Joined: Thu Nov 27, 2008 10:25 am
Location: Netherlands

Post by Dick99999 » Thu Nov 28, 2013 8:48 am

Marcus Tettmar wrote:Naturally this will fire several times as the event is detected several times WHILE the key is down. Perhaps detecting a key going UP is better?

Don't think you can "ripple through".
Thanks. I have modified the code and took the disable out of the click handler. So there is a little delay of 0.2 sec after the tap before disabling. That works!
The rest of the code is there for completeness. But the part of trying to see whether the text carrot is near the tap, is not working yet, please ignore.

Code: Select all


//Set IGNORESPACES to 1 to force script interpreter to ignore spaces.
//If using IGNORESPACES quote strings in {" ... "}
//Let>IGNORESPACES=1
//
Let>WIN_USEHANDLE=0
Let>WF_TYPE=1
Let>WIN_REGEX=0
SetFocus>firefox*
GetCaretPos>textX,textY,0
//
let>disableClick=False
//
onevent>key_down,VK1,0,doMouseClick
label>idle_loop
if>disableClick=True
   onevent>key_down,VK1,0,
endif
wait>0.2
goto>idle_loop
//
// SRT called on tap
srt>doMouseClick
**BREAKPOINT**
let>disableClick=True
onevent>key_down,VK1,0,
Let>WIN_USEHANDLE=1
Let>GAW_TYPE=0
GetActiveWindow>activeWn,actWinX,actWinY,actWinW,actWinH
// get tap X,Y and relative to window
getcursorpos>tapX,tapY
let>tapXrel={%tapX%-%actWinX%}
let>tapYrel={%tapY%-%actWinY%}
wait>0.1
**BREAKPOINT**
// get text cursor X,Y and relative to window
GetCaretPos>textX,textY,0
let>textXrel={%textX%-%actWinX%}
let>textYrel={%textY%-%actWinY%}
// test whther not really a text cursor postion (in 100,100 box relative to window)
if>{(%textXrel%>100) or (%textYrel%>100)}
  // test whether tap is within text cursor range (Tap max 150,40 from text cursor postion)
  if>{(%tapXrel%-%textXrel%<350) and (abs(%tapYrel%-%texYrel%)<100>notepad
  'run>%sys_native%\osk.exe
  endif
endif
END>doMouseClick

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