 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
john tuomi
Joined: 22 May 2006 Posts: 150
|
Posted: Mon Feb 22, 2010 7:07 pm Post subject: AHK talking to MS Access |
|
|
Greetings!
I was wondering if any of you know of a simple way for AHK to talk with Access?
In my shop, I use an AHK script to count keystrokes using the script, below. What I would like to build instead is a bot that transfers the stored keystroke counts (including a timestamp) into MS Access. Any ideas of how I could get this done?
| Code: | FormatTime, Hour, , HH
IfNotExist, Data Corrections.xls
SetTimer, WatchActiveWindow, 5000
return
WatchActiveWindow:
line = %KC%
StringReplace, line, line, `n, %A_SPACE%, All
StringReplace, line, line, `r, , All
FileAppend, %line%`n,Data Corrections.xls
return
~*a::
~*b::
~*c::
~*d::
~*e::
~*f::
~*g::
~*h::
~*i::
~*j::
~*K::
~*l::
KC++
return |
|
|
| Back to top |
|
 |
Leef_me
Joined: 08 Apr 2009 Posts: 5336 Location: San Diego, California
|
Posted: Mon Feb 22, 2010 8:09 pm Post subject: |
|
|
I have not worked with Access, so the following don't have a firm foundation.
Excel can read from CSV file (comma separated Values). Those files can be written and read by Ahk.
Can Access read CSV files?
There is something referred to on this board as "COM" which allows better control of I.E. Word and other programs.
Perhaps it works with Access ? |
|
| Back to top |
|
 |
john tuomi
Joined: 22 May 2006 Posts: 150
|
Posted: Mon Feb 22, 2010 8:32 pm Post subject: |
|
|
Thanks for the info! I'm thinking it might be easier to build this in pieces. First, a keyboard hook that captures the user ID and the total for all the keys pressed, and writes them to an INI or a CSV file in a centralized location. These entries would need to have a timestamp.
Second, create a bot that can monitor data saved in the INI or CSV file, and sweep those items into the Access database form by user. The bot would need to empty the INI or CSV file so it starts off with a zero balance after retrieval.
The Access part should be easy to do, it's the loop/set timer that I am unfamiliar with. |
|
| Back to top |
|
 |
Leef_me
Joined: 08 Apr 2009 Posts: 5336 Location: San Diego, California
|
Posted: Mon Feb 22, 2010 9:22 pm Post subject: |
|
|
Btw, I somehow missed seeing you script.
I have a few comments about it:
1. don't use Data Corrections.xls as your output file. XLS has a particular format. You will destroy any useful data in the original XLS file.
2. Why are you uing StringReplace on a variable that has no `n and no `r ?
3. In "WatchActiveWindow" you write the current value of KC after removing non-existant `n and `r. But you don't clear KC.
This means that KC is an ever-increasing number. Is that what you want?
4. You probably wanted more than just a...L, correct ?
Edit:
INI files have a useful format, with sections and data & values.
It irks me that some would use this file extension for other types of files
that are non-INI in nature. Just my 2cents worth. |
|
| Back to top |
|
 |
ehagood
Joined: 30 Jan 2006 Posts: 51
|
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|