aa2zz6 Posted May 13, 2017 Posted May 13, 2017 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
InunoTaishou Posted May 13, 2017 Posted May 13, 2017 (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.
aa2zz6 Posted May 13, 2017 Author Posted May 13, 2017 Is there a way to resize google earth within the shellexecute parameters rather than after it appears on the screen?
spudw2k Posted May 16, 2017 Posted May 16, 2017 (edited) 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 May 16, 2017 by spudw2k Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now