Jump to content

Launch Mapping Software With Defined Size


Recommended Posts

I'm trying to create a little script for our operators who use Google Earth with our .kml files. I'm trying to launch google earth with a certain screen resolution, center of screen, and then minimize. The idea is to set it up quickly each time, allowing the operators to click once so they don't waste time in the office.

I'm not sure how implement  a screen resolution using ShellExecute

$fileDir = "C:\Program Files (x86)\Google\Google Earth\client\googleearth.exe", -resolution?
;Google Earth ~ Field Operators 05/12/2017
$fileDir = "C:\Program Files (x86)\Google\Google Earth\client\googleearth.exe"
$GoogleEarth = ShellExecute($fileDir)

Sleep(500)

ConsoleWrite(_Middle("Google Earth") & @CRLF)

sleep(500)

Func _Middle($hWnd, $Text = "")
    Local $aWinGetPos = WinGetPos($hWnd, $Text)
    If Not IsArray($aWinGetPos) Then Return SetError(1, 0, 0)
    Local $iY = (@DesktopHeight / 2) - ($aWinGetPos[2] / 2)
    Local $iX = (@DesktopWidth / 2) - ($aWinGetPos[3] / 2)
    WinSetState($hWnd, "", @SW_MINIMIZE)
    Return WinMove($hWnd, $Text, $iX, $iY)
EndFunc   ;==>_Middle

 

Link to comment
Share on other sites

(Changed to notepad because I don't have google earth installed)

;Google Earth ~ Field Operators 05/12/2017
$fileDir = @WindowsDir & "\notepad.exe"
$GoogleEarth = ShellExecute($fileDir)

ConsoleWrite(_Middle("Untitled - Notepad", 1280, 768) & @CRLF)

Func _Middle($sTitle, $iWidth, $iHeight)
    Local $hWnd = WinGetHandle($sTitle)
    While (Not WinExists($hWnd))
        Sleep(100)
        $hWnd = WinGetHandle($sTitle)
    WEnd
    Local $iY = (@DesktopHeight / 2) - ($iHeight / 2)
    Local $iX = (@DesktopWidth / 2) - ($iWidth / 2)
    WinMove($hWnd, "", $iX, $iY, $iWidth, $iHeight)
    Return WinSetState($hWnd, "", @SW_MINIMIZE)
EndFunc   ;==>_Middle

You already have the resolution you want, and you are using winmove, so you can just use winmove to adjust the width/height. Just move WinSetState to the return and winmove before it. You can't move a window that's minimized.

Link to comment
Share on other sites

Not that I am aware of.  There may be a registry key somewhere that tracks the last state of the window and upon next launch it will "restore" to that state (size & pos), but I'm not sure if Google Earth supports that.

BTW, found this article which seems to indicate that using a automation script is the best method (after launching GE, resize and position window): https://productforums.google.com/forum/#!msg/earth/r6KFmB3bPos/rHGtlRI-V90J

I still don't see a way to do so using ShellExecute.

Edited by spudw2k
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...