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

Autohotkey open Resultsviewer and E+ error file [closed]

asked 10 years ago

LSurf's avatar

updated 7 years ago

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.

Preview: (hide)

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's avatar Julien Marrec  ( 10 years ago )

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

LSurf's avatar LSurf  ( 10 years ago )

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

Julien Marrec's avatar Julien Marrec  ( 10 years ago )

1 Answer

Sort by » oldest newest most voted
3

answered 10 years ago

LSurf's avatar

updated 10 years ago

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
Preview: (hide)
link

Training Workshops

Careers

Question Tools

1 follower

Stats

Asked: 10 years ago

Seen: 253 times

Last updated: Feb 17 '15