Question-and-Answer Resource for the Building Energy Modeling Community
Get s tarted with the Help page
Ask Your Question
4

Autohotkey open Resultsviewer and E+ error file [closed]

asked 2015-02-17 07:31:28 -0500

LSurf gravatar image

updated 2017-09-25 15:37:59 -0500

In my workflow I open Resultsviewer a lot, and look at the EnergyPlus .err file.

Since this debugging is quite time-consuming, I was looking for a way to optimize my workflow using AutoHotKey (http://www.autohotkey.com/)

I wrote a script that can for instance open ResultsViewer, and is easily modifiable to perform other actions.

edit retag flag offensive reopen merge delete

Closed for the following reason not a real question by __AmirRoth__
close date 2017-04-16 15:00:24.151188

Comments

This is great, thanks for sharing. But can you please phrase it as a question ("How can you automate opening results viewer to see the latest .err file?) and put your solution as an answer?

Julien Marrec gravatar image Julien Marrec  ( 2015-02-17 07:48:14 -0500 )edit

Sure! I realized this wasn't a question, but wanted to share in case someone should find it helpful

LSurf gravatar image LSurf  ( 2015-02-17 07:54:13 -0500 )edit

Answering your own question is perfectly fine and even recommended! Thanks for adjusting.

Julien Marrec gravatar image Julien Marrec  ( 2015-02-17 08:13:19 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
3

answered 2015-02-17 08:00:34 -0500

LSurf gravatar image

updated 2015-02-17 08:09:47 -0500

When the script below is active, some functionality is added when an OpenStudio window has focus.

The following shortcuts are available, and work on the most recently run .osm-file (based on modified date):

  • Ctrl+R: Opens Resultsviewer (and goes to tree view + collapses the tree)
  • Ctrl+E: Opens the .err in Notepad++
  • Ctrl+D: Opens the folder in explorer
  • Ctrl+Q: Closes Resultsviewer (so that no file conflict occurs when running simulation)

I didn't do any thorough testing, so it may need modifications on your system. Feel free to use/modify.

SetTitleMatchMode, 2

; OpenStudio Shortcuts
OSDir()
{
    NewestTime = 20100101000000
    NewestName = 0
    Loop, %USERPROFILE%\AppData\Local\Temp\OpenStudio*,2
    {
        ;dt = %A_LoopFileTimeModified%
        FileGetTime, dt, %A_LoopFileFullPath%\resources
        EnvSub, dt, %NewestTime%, seconds
        if dt > 0  ; Source file is newer than destination file.
        {
            IfExist, %A_LoopFileFullPath%\resources\run ; Folder contains run data
            {
                ;NewestTime = %A_LoopFileTimeModified%
                FileGetTime, NewestTime, %A_LoopFileFullPath%\resources
                NewestName = %A_LoopFileFullPath%
            }
        }
    }
    ;Newest folder is %NewestName%
    return %NewestName%
}

#IfWinActive, osm ahk_class Qt5QWindowIcon

; Open most recent SQL database in ResultsViewer
^r::
OSD := OSDir()
Run "C:\Program Files\OpenStudio 1.6.0\bin\ResultsViewer.exe" "%OSD%\resources\run\5-EnergyPlus-0\eplusout.sql"
WinWait, ResultsViewer, 
IfWinNotActive, ResultsViewer, , WinActivate, ResultsViewer, 
WinWaitActive, ResultsViewer,
;MouseClick, left,  136,  182
ControlClick, x136 y182
Sleep, 100
;MouseClick, left,  152,  208
ControlClick, x152 y208
Sleep, 100
Send, {DOWN}{LEFT}{DOWN}{LEFT}{DOWN}{LEFT}{DOWN}{LEFT}{DOWN}{LEFT}{DOWN}{LEFT}{DOWN}{LEFT}{DOWN}{LEFT}{DOWN}{LEFT}{DOWN}{LEFT}{DOWN}{LEFT}
Return

; Open E+ Error file with Notepad++
^e::
OSD := OSDir()
Run "C:\Program Files (x86)\Notepad++\notepad++.exe" "%OSD%\resources\run\5-EnergyPlus-0\eplusout.err"
Return

; Open Directory containing files
^d::
OSD := OSDir()
Run explorer.exe "%OSD%\resources\run"
Return

; Close ResultsViewer so no file conflict occurs when running simulation in OpenStudio
^q::
WinClose ResultsViewer ahk_class Qt5QWindowIcon
Return

#IfWinActive
edit flag offensive delete link more

 

Question Tools

1 follower

Stats

Asked: 2015-02-17 07:31:28 -0500

Seen: 131 times

Last updated: Feb 17 '15