Jump to content

Are there any GPS api's for autoit ?


tonycst
 Share

Recommended Posts

Windows offers this API.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

a little clicking arround on the website provides you this HTML which describes how to use these objects with COM Automation.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">



<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<title>A Simple Latitude/Longitude Example</title>

</head>

<body onload = "GetLatLong()">

<!-- LatLong Location report factory object -->

<object id="LatLongFactory"

classid="clsid:9DCC3CC8-8609-4863-BAD4-03601F4C65E8"

type="application/x-oleobject">

</object>



<p>This example requires that you have installed and enabled a

driver that can provide latitude and longitude data.</p>

<br>



<!-- Text boxes used to display LatLong report fields. -->

Latitude: <input type="TEXT" name="txtLat" value=""> <br>

Longitude: <input type="TEXT" name="txtLon" value=""> <br>

Altitude: <input type="TEXT" name="txtAlt" value=""> <br>

Altitude error: <input type="TEXT" name="txtAltErr" value=""> <br>

Error radius: <input type="TEXT" name="txtErrRad" value=""> <br>

Timestamp: <input type="TEXT" name="txtTmL" value=""> <br>

<input type="BUTTON" name=btnLLr value="Get LatLong"

onclick="GetLatLong()"> <br>



<br>



<script>

<!--



// JScript date object assumes local time.

// If you display the timestamp directly, the

// the string will show UTC plus the local time zone,

// such as "PST". This function ensure that local time

// is displayed in the string.

function GetTimeString(timestamp)

{

var datetime = new Date(timestamp);

var dateLocal = new Date();



dateLocal.setTime(Date.UTC(datetime.getFullYear(),

datetime.getMonth(),

datetime.getDate(),

datetime.getHours(),

datetime.getMinutes(),

datetime.getSeconds(),

datetime.getMilliseconds()));



return dateLocal.toString();

}



// Get a latitude/longitude report

// and display the values.

function GetLatLong()

{

var reportstatus = LatLongFactory.Status;



if(reportstatus == 4)

{

var report = LatLongFactory.LatLongReport;



// Retrieve the properties required to be

// supported by all LatLong providers.

txtLat.value = report.Latitude;

txtLon.value = report.Longitude;

txtErrRad.value = report.ErrorRadius;

txtTmL.value = GetTimeString(report.Timestamp);



// Try to retrieve the non-required properties.

try

{

txtAlt.value = report.Altitude;

txtAltErr.value = report.AltitudeError;

}

catch(e)

{

txtAlt.value = "Altitude not supported.";

txtAltErr.value = "Altitude not supported.";

}

}

else

{

alert("No location data provider available.");

}

}

-->

</script>

</body>

</html>
 
Link to comment
Share on other sites

Yes i saw that. It confuses me even more.

I tried to come up with _WinApi_LocationDisp.LatLongReportFactory taken from Location.LocationDisp.LatLongReportFactory  and just added _WinAPI_ at its front but i doubt its gonna work since its not listed in autoit. And if its not listed, does that mean its not supported ?

Edited by tonycst
Link to comment
Share on other sites

I'm guessing the reason it hasn't been written yet is that it's such a niche thing. There's so few computers that actually have a GPS enabled device in them that it probably just hasn't come up before. I've never run into a computer that's GPS enabled myself, and didn't even know such a thing existed, or was needed by anyone.

EDIT: I wanted to clarify, I've never seen a computer with it built-in before, I've seen plenty of USB/Serial port connected GPS devices before.

Edited by BrewManNH

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Perhaps because those laptops were cheep.

Anyhow i need lots of help on this.

#include <WinAPI.au3>

Dim $latlongfactory
$latlongfactory = ObjCreate("LocationDisp.LatLongReportFactory")
Dim $Listen
$Listen = ObjCreate ("LocationDisp.LatLongReportFactory.ListenForReports")
Dim $Report
$Report= ObjCreate ("LocationDisp.LatLongReportFactory.LatLongReport",$Listen)




MsgBox(0,'',$Report)

I am trying to learn API's and this is what i came up with so far.

Am sure its wrong but it looks good :)

I need the $report to report something but it gives 0. :(

Because most of these return no value, i cant be sure i do it right.

Edited by tonycst
Link to comment
Share on other sites

i have a lenovo with "build in GPS" aswell

and i have used this code to get the GPS data just change the com port to the one your GPS i connected to

This is NOT my code all credit goes to the original author here from autoit forum :D

#include <WinAPI.au3>
Global $Port1, $Port, $Buffer, $String, $Data
$Port1 ="COM17"
_OpenPort()

for $I = 1 to 100 ; Let's do the cycle 5 times
    _GetData()
   Global $TimeStamp = $DATA[2] ; UTC time
   Global $Lat1= Round((StringRight($DATA[4],7)/60) + StringLeft($DATA[4],2),6) ; Latitude converted to decimal degrees
   if $DATA[5] = "S" Then
   $Lat1=$Lat1 * -1
   EndIf
   Global $Lon1= Round((StringRight($DATA[6],7)/60) + StringLeft($DATA[6],3),6) ; Longitude converted to decimal degrees
   if $DATA[7] = "W" Then
   $Lon1=$Lon1 * -1
   EndIf
   Global $Speed = Round($DATA[8]*1.852,0) ; Speed is in Knots. Multiply by 1.852 for Km or 1.150779 for miles
   Global $Bearing = $DATA[9] ; In degrees
    If $Lat1<>0 And $Lon1<>0 Then
        consolewrite("Time: " & $TimeStamp  & "   Latitude: " & $Lat1  & "   Longitude:  " & $Lon1  & "   Speed: " & $Speed&" Km" & "   Bearing:  " & $Bearing & @CR )
        ;FileWriteLine(@ScriptDir&"\GPSLog.txt","Time: " & $TimeStamp  & "   Latitude: " & $Lat1  & "   Longitude:  " & $Lon1  & "   Speed: " & $Speed & "   Bearing:  " & $Bearing)
    Else
        consolewrite("Waiting for $GPRMC Data from COM port that is different then 0,0" &@CR)
    EndIf
next

Func _OpenPort()
   $Port = _WinAPI_CreateFile($Port1, 2, 2)
   If $Port = 0 then
   msgbox(16, "", "No response from port " & $Port1)
   exit
   else
   $Buffer = DllStructCreate("byte[1]")
   EndIf
EndFunc
Func _GetData()
   While 1
   _GetString()
   if StringLeft($String,6) = "$GPRMC" then ; $GPGGA $GPGSV $GPGLL $GPGSA $GPGST
   $Data = stringsplit($String, ",")
   Return
   EndIf
   WEnd
EndFunc
Func _GetString()
   Local  $C = 0, $TempString = "", $sText
   While 1
    Local $nBytes=1
   _WinAPI_ReadFile($Port, DllStructGetPtr($Buffer), 1, $nBytes)
   $sText = BinaryToString(DllStructGetData($Buffer, 1))
   if $stext=chr(13) or $sText=chr(10) then
   $C=$C+1
   if $C=2 then
      $String = $TempString
      $TempString = ""
      $C=0
      Return
   endif
   else
   $TempString= $TempString & $sText
   EndIf
   WEnd
EndFunc
Link to comment
Share on other sites

Yes different COM#

Right mouse click Computer -> Properties -> Device Manager -> Ports (COM & LPT) -> Your device

at least under windows 7

i have windows 7. no such thing as Ports under device manager, just list of all devices.

I am not sure what category this device is and what would it be named.

Link to comment
Share on other sites

The GPS devices I've seen have all been serial port devices, even the ones that plug into a USB port.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Have you tried expanding all of the trees to see where it's located?

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Have you tried expanding all of the trees to see where it's located?

I did. I have nothing there that would make me think about GPS or LOCATION

Laptop model is Samsung ATIV Book 8

Looking at its specs, i found no clue about its location device name or even if it has one.

Its a feature that even manufacturer thought was not important to specify.

Edited by tonycst
Link to comment
Share on other sites

#include <WinAPI.au3>
#include <WinAPILocale.au3>
#include <APILocaleConstants.au3>

Local $ID = _WinAPI_GetUserGeoID()

ConsoleWrite('ID:        0x' & Hex($ID) & @CRLF)
ConsoleWrite('Latitude:  ' & _WinAPI_GetGeoInfo($ID, $GEO_LATITUDE) & @CRLF)
ConsoleWrite('Longitude: ' & _WinAPI_GetGeoInfo($ID, $GEO_LONGITUDE) & @CRLF)
ConsoleWrite('Name:      ' & _WinAPI_GetGeoInfo($ID, $GEO_FRIENDLYNAME) & @CRLF)
ConsoleWrite('ISO code:  ' & _WinAPI_GetGeoInfo($ID, $GEO_ISO3) & @CRLF)

Link to comment
Share on other sites

  • Moderators

tonycst,

Are you running the Beta? :huh:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...