Jump to content
Macro Express Forums

Detecting NON keypress


mts0987

Recommended Posts

Hello,

 

I'm writing a macro that I want to only execute if I'm away from the computer. Basically, if an Outlook window appears announcing a new message and I'm away from the computer, I want the computer to start beeping. I'm having trouble figuring out how to reliably detect *lack* of keyboard action without aborting the macro. Thanks in advance for any ideas.

 

Here are the details:

 

I have a simple routine that detects if the mouse moves over the course of 15 seconds. I grab the x,y of the mouse coords, and then check every second to see if the x,y has changed. If it has changed, I must be at the computer, and the macro stops. If the coords have not changed, then the macro goes into a loop playing an alert wav file every second until the coords do change.

 

But what if the mouse hasn't moved because I'm typing? I need something similar in place to sniff keyboard activity. There's no "get last key pressed" variable command. I tried "Wait for keypress" [space] since if I'm typing I can assume that I'll hit the space at least once in 10 seconds. But I discovered that the macro aborts if it reaches its max time. What I really wanted was for it to wait a max of 30 seconds, and then continue, but stop waiting if a key is pressed. If I detect a keypress, I stop the macro. If I detect that it waited the max time before giving up, I can assume I'm away and start beeping.

 

Ideas?

 

Thanks,

-- Mike

Link to comment
Share on other sites

Don't have time right now to test...

 

But, can you capture something outlook does to notifiy you a message came in. Like the ghost pop-up that shows for a few seconds (you can have outlook keep its forcus for quite a few seconds) when an email comes in....or the ping outlook gives when and email comes in, the cursor movement, etc.

 

Look at what Outlook does, kinda think in reverse of what you have been.

 

Just an idea. Will play with some ideas when I get the time if you haven't solved it by then.

Link to comment
Share on other sites

Thanks for getting back!

 

I'm not having trouble detecting that a message has come in. That's not the issue. I have the macro activation set to the window title "New Item Alert" which is the Outlook popup telling me I have a new message. That all works fine.

 

The issue is, once the macro is activated, I only need it to actually beep if I'm not at my computer. So, the problem is, how can the macro detect that I'm not here? First, look for mouse movement. If there's no mouse movement in X seconds, I'm probably away. But just in case I'm here but not using the mouse, look for keyboard action. If there's no mouse movement, and no keyboard action, after 30 seconds (or whatever), it's a safe bet that I'm not here, so start beeping.

 

I've figured out every piece of this except detecting keyboard activity.

Link to comment
Share on other sites

Here's a way to get a slightly-delayed audible alert. Activate a macro when the "New Item Alert" window appears. The first thing the macro will do is "wait time elapse" for 30 seconds or 60 seconds of whatever. Then "If Window New Item Alert is running" sound the audible beep alarm. Presumably if you are at the computer you will close the New Item Alert window before the 30 seconds has elapsed, so the macro will just end without beeping.

 

The only drawback I can see is that the macro will stay running for the full 30 seconds no matter what, and if you ARE at the computer you might want other macros to be able to run. You can take care of that by slightly elaborating on the above method. Fire off the macro when the New Item window appears. Set up a repeat loop for 30 or 60 or whatever iterations you want, with a one-second "wait time elapse" inside the loop. Each time through the loop, check whether the New Item window is (still) running, and Macro Stop if it is not. If you get through all iterations of the loop and the New Item window is still running, then sound the beep alarm.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...