Solved

Visual Basic Code

Posted on 2011-02-22
5
223 Views
Last Modified: 2012-08-14
Was trying to figure this out for a while now - but cant at all.
Basically what i want to do is, using Visual Basic:

I want VB to analyze a specific file and, if that file has not been updated for the last 15 minutes, i want the R key to be pressed.

I also have another, similar thing i need to do which i cant figure out:

I want VB to analyze the same as the above file and, if that file has been updated within the last 5 minutes, i want the NUM lock to be toggled on

Sounds simple enough i know, but i, nor my google attempts, can figure it out
much appreciated to anyone who can help
0
Comment
Question by:kakashisharingun
  • 2
  • 2
5 Comments
 
LVL 19

Accepted Solution

by:
darbid73 earned 500 total points
ID: 34958499
1 if file has not been modified for 15 minutes

If DateDiff("n", FileDateTime("C:\Somefile.txt"), Now) > 15 Then
    MsgBox "Modified more than 15 minutes ago"
End If

Open in new window


You can change this around for Greater than or Less than 15

You could use the Sendkeys to press r

SendKeys "r"

Open in new window


You might find that the num lock is a little harder see here for how Microsoft suggests Toggle Num Lock
0
 
LVL 19

Expert Comment

by:darbid73
ID: 34958509
Also see here for NUM LOCK

FreeVBCode.com
0
 

Author Comment

by:kakashisharingun
ID: 35186981
I thaught i did accept their answer already
0
 

Author Comment

by:kakashisharingun
ID: 35186989
I am attempting to accept his solution now - but it doesn't appear to be letting me...
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now