AutoHotkey Community

It is currently May 26th, 2012, 6:06 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: August 12th, 2007, 3:50 am 
Offline

Joined: August 12th, 2007, 3:49 am
Posts: 12
Displays a small GUI with the current Latitude and Longitude etc. from your Google Earth window.
Uses the ws4ahk.ahk "Embedded Windows Scripting and COM for Autohotkey" library and the Google Earth API
http://www.autohotkey.net/~easycom/

Code:
#include ws4ahk.ahk

WS_Initialize()

VBCode =
(
   Dim googleEarth
   Dim camPos
   
   Function testGe()
   Set googleEarth = CreateObject("GoogleEarth.ApplicationGE")
   testGe = googleEarth.IsInitialized()
   end Function

   Function gePos()
   Set googleEarth = CreateObject("GoogleEarth.ApplicationGE")
   Set camPos = googleEarth.GetCamera(0)
   gePos = camPos.FocusPointLatitude & ":" & camPos.FocusPointLongitude & ":" & camPos.FocusPointAltitude & ":" & camPos.FocusPointAltitudeMode & ":" & camPos.Range & ":" & camPos.Tilt & ":" & camPos.Azimuth & ":"
   end Function
   
)

Gui,Add, Text, x10, FocusPointLatitude:
Gui,Add, Edit, ReadOnly yp x140 w150 vFocusPointLatitude,
Gui,Add, Text, x10, FocusPointLongitude:
Gui,Add, Edit, ReadOnly yp x140 w150 vFocusPointLongitude,
Gui,Add, Text, x10, FocusPointAltitude:
Gui,Add, Edit, ReadOnly yp x140 w150 vFocusPointAltitude,
Gui,Add, Text, x10, FocusPointAltitudeMode:
Gui,Add, Edit, ReadOnly yp x140 w150 vFocusPointAltitudeMode,
Gui,Add, Text, x10, Range:
Gui,Add, Edit, ReadOnly yp x140 w150 vRange,
Gui,Add, Text, x10, Tilt:
Gui,Add, Edit, ReadOnly yp x140 w150 vTilt,
Gui,Add, Text, x10, Azimuth:
Gui,Add, Edit, ReadOnly yp x140 w150 vAzimuth,
Gui,Show,,Google Earth Position
Gui +LastFound
WinSet AlwaysOnTop

Loop {
  WS_Exec(VBCode)
  WS_Eval(theValue, "gePos()")
  StringSplit word_array,theValue,:,
  GuiControl,,FocusPointLatitude, %word_array1%
  GuiControl,,FocusPointLongitude, %word_array2%
  GuiControl,,FocusPointAltitude, %word_array3%
  GuiControl,,FocusPointAltitudeMode, %word_array4%
  GuiControl,,Range, %word_array5%
  GuiControl,,Tilt, %word_array6%
  GuiControl,,Azimuth, %word_array7%
  Sleep 100
}

WS_Uninitialize()


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 20th, 2008, 4:43 pm 
Offline

Joined: October 13th, 2007, 10:18 am
Posts: 24
Cool! :D

I'm new to COM, but i was looking for a way to use GE with the nintendo wiimote. I can't try it now since i'm not on my own PC, but if this script works it will be really helpful. Looking at that script and google's API documentation, i think i see what's going on, but could you post a script to set camera positions instead of getting them, since that's what i want to do? just from some variables holding the values, or something like that? I learn best from examples.

Hard to believe noone has replied to this yet. I guess not many people have the GE API.

Thanks


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 21st, 2008, 11:41 pm 
Offline

Joined: August 12th, 2007, 3:49 am
Posts: 12
Hi afromonkey,

SetCameraParams is what you want. Try something like this..

This function inside the VBCode:
Code:
   Function geSetPos(FocusPointLatitude, FocusPointLongitude, FocusPointAltitude, FocusPointAltitudeMode, Range, Tilt, Azimuth, Speed)
   Set googleEarth = CreateObject("GoogleEarth.ApplicationGE")
   Set geSetPos = googleEarth.SetCameraParams(FocusPointLatitude, FocusPointLongitude, FocusPointAltitude, FocusPointAltitudeMode, Range, Tilt, Azimuth, Speed)
   end Function


And this wrapper function in your AHK
Code:
SetGEpos(FocusPointLatitude,FocusPointLongitude,FocusPointAltitude,FocusPointAltitudeMode = 2,Range = 50000,Tilt = 0,Azimuth = 0,Speed = 1) {
   WS_Eval(returnval, "geSetPos(%v, %v, %v, %v, %v, %v, %v, %v)", FocusPointLatitude, FocusPointLongitude, FocusPointAltitude, FocusPointAltitudeMode, Range, Tilt, Azimuth, Speed)
   return returnval
}


Call with SetGEpos(FocusPointLatitude,FocusPointLongitude,FocusPointAltitude,FocusPointAltitudeMode,Range,Tilt,Azimuth,Speed)

Good luck :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 24th, 2008, 3:31 pm 
Offline

Joined: October 13th, 2007, 10:18 am
Posts: 24
Thanks very much for the code, but i think i might be doing something wrong, i always get an error 'Too many arguments passed to function' for the WS_Eval function. It does have a lot more than the others. Should i put the whole second argument in quotes or something?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 24th, 2008, 6:20 pm 
Offline

Joined: August 12th, 2007, 3:49 am
Posts: 12
Looks like something changed in the WS library - my previous example doesn't work any more with the latest version..

Try this way of calling it instead:

Code:
SetGEpos(FocusPointLatitude,FocusPointLongitude,FocusPointAltitude,FocusPointAltitudeMode = 2,Range = 50000,Tilt = 0,Azimuth = 0,Speed = 1) {
   wsfunction = geSetPos(%FocusPointLatitude%, %FocusPointLongitude%, %FocusPointAltitude%, %FocusPointAltitudeMode%, %Range%, %Tilt%, %Azimuth%, %Speed%)
   WS_Eval(returnval, wsfunction)
   return returnval
}


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Google Feedfetcher and 20 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group