... the user friendly GPS tool


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Animated Map
#5
Marking 15 second intervals on the map is well and good, but it's much easier to mark landmarks such as bridges but this results in varying time intervals between waypoints.

Keyboard and Mouse Simulator (KBMS) can't handle this easily so I wrote a routine in Visual Basic for Applications (VBA) hosted on Excel 365 to read a file exported from Route Converter and send down-key keystrokes at the required intervals to Route Converter.


Sub Steps()            'invoked by a "Start Buttton" on the spreadsheet
    PointCount = 0
    Open "c:\Temp\StepData.csv" For Input As 1
    Line Input #1, a$                                                                                                                            'strip header
       
    Input #1, aa$, ab$, ac$, ad$, ae$, af$, ag$, ah$, ai$, aj$, ak$, al$, am$, an$, ao$                                '1st data line
    InitialTime = Val(Mid$(ad$, 1, 2)) * 3600 + Val(Mid$(ad$, 3, 2)) * 60 + Val(Mid$(ad$, 5, 2))                 'Seconds
       
    ActiveSheet.Cells(2, 9).Select
    ActiveCell.Value = "Loading data from file"
    On Error Resume Next
   
    Do                                                                  'Load array with timing intervals
       
            Input #1, aa$, ab$, ac$, ad$, ae$, af$, ag$, ah$, ai$, aj$, ak$, al$, am$, an$, ao$                                              'Subsequent data lines
                 
            Time2 = Val(Mid$(ad$, 1, 2)) * 3600 + Val(Mid$(ad$, 3, 2)) * 60 + Val(Mid$(ad$, 5, 2)) - InitialTime                    'Seconds
            Interval = Time2 - Time1                   
               
            PointCount = PointCount + 1
            Waitlist(PointCount) = Interval
               
            Time1 = Time2
           
    Loop Until EOF(1)
   
    Close
   
    ActiveCell.Value = "Data loaded, 10sec. to select start position"
       
    newHour = Hour(Now())
    newMinute = Minute(Now())
    newSecond = Second(Now()) + 10                                                      'wait 10 secs before executing sendkeys
    Application.Wait TimeSerial(newHour, newMinute, newSecond)               'Time delay to allow selection of target window

    For n! = 1 To PointCount
        ActiveCell.Value = "Line " + Str$(n!) + "/" + Str$(PointCount) + "  Interval" + Str$(Waitlist(n!))
               
        newHour = Hour(Now())
        newMinute = Minute(Now())
        newSecond = Second(Now()) + Waitlist(n!)                                        'WaitList(n!) is the interval
        Application.Wait TimeSerial(newHour, newMinute, newSecond)            'Wait for the duration of the interval
   
        SendKeys "{DOWN}", False            'NB There is a bug in VBA which causes NumLocks to switch off !!
       
       
    Next
   
    End
End Sub


1) Export the position list as waypoints to c:\Temp\StepData.csv

2) Press the start button and the routine opens c:\Temp\StepData.csv, gives you about 10 seconds to click on the 1st entry in the position list and then starts outputting down-key keystrokes.

3) Do not click on any other windows until the program finishes, otherwise those keystrokes will be sent to the program you click on!

4) Always use copies of your data files in case anything goes wrong.  Under Microsoft Excel and Windows 10 it won't of course.

5) To interrupt the routine press Ctrl-Break (Ctrl-Pause on some keyboards).

6) There is a bug in the SendKeys instruction which switches Num Locks off.

This is the bare bones of a larger application I'm working on which will automatically switch to Route Converter and allow the user to select which file to import and so on.
Reply


Messages In This Thread
Animated Map - by Roger B - 11.05.2020, 16:36
RE: Animated Map - by Roger B - 12.05.2020, 19:15
RE: Animated Map - by Roger B - 12.05.2020, 20:26
RE: Animated Map - by routeconverter - 13.05.2020, 16:34
RE: Animated Map - by Roger B - 17.05.2020, 11:09
RE: Animated Map - by routeconverter - 24.05.2020, 10:25
RE: Animated Map - by Roger B - 24.05.2020, 18:23
RE: Animated Map - by routeconverter - 28.05.2020, 05:41
RE: Animated Map - by Roger B - 28.05.2020, 19:57

Forum Jump:


Users browsing this thread: 4 Guest(s)