[Enginer Tool] Screen EX

Screen EX is an RPG maker XP enginers tool that allows to make screenshots of the editor more easily.

More precisely, it's a plug-and-play script, compatible with basically everything (including the similar tool Interpreter EX); you add it above Main, change its configuration, execute the game (in Debug mode) to obtain the result, and remove it later.

Description
Screen EX allows you to take screenshots of the editor of things that are not easy to capture.
I mean for example a long engine, a big map, the whole list of skills... There are a lot of options.

The script generates an image (or multiple) and saves it on the project's folder. To do so, you need to make the script call inside the script. There's a lot of information and some examples on the code, but I'll add some more below.

Similar to Interpreter EX, this script doesn't make changes on default methods, so you could have it in your project with the call region completely empty, and it wouldn't affect anything else. There's no point in having it in the final release of the project, though.

Terms of use
This code is completely free to use and doesn't require credits.

How to Use
Place the script over the script Main. Right after the instructions of the script there's an empty space inside the ScreenEX module with a basic example of usage; the only thing you need to do is define there what screenshot(s) you want to output. If you want to get tileset data as it appears in the database (passability, etc.) in the image, you will need the picture tile_flags.png in the main folder of the project.

No configuration is required, but you can modify some globals if you want:
Spoiler: Advanced configuration
FOLDER
Name of the folder where screenshots are saved. You can set it to "" to save them on the main project's folder. If the folder doesn't exist, it creates it automatically.

BACKGROUND_COLOR
When making map or tileset screenshots, empty tiles are displayed with a customizable color in the editor. I could've used the same in the script, but I decided to set it in the configuration instead.

GRID_COLOR
Tile grid color used when making map or tileset screenshots. Similar to the previous one.

Download
You can download both the English and Spanish versions here: Screen EX 1.1

Spoiler: More extended examples
Here are some examples of valid script calls.
Ruby:
      # Items list
      take_shot(:item, :list)
      save_bitmap("001")
      
      # Animation effects list
      take_shot(:animation, :effects, 5)
      save_bitmap("002")
      
      # Tileset block + terrain
      take_shot(:tileset, :block, 2)
      save_bitmap("003A")
      take_shot(:tileset, :terrain, 2)
      save_bitmap("003B")
      
      # Class states effectivity
      take_shot(:class, :states, 1)
      save_bitmap("004")
      
      # Class learning skills
      take_shot(:class, :skills, 1)
      save_bitmap("005")
      
      # Class equippable weapons
      take_shot(:class, :weapons, 1)
      save_bitmap("006")
      
      # State changes of an state
      take_shot(:state,  :states, 1)
      save_bitmap("007")
      
      # Enemy actions list
      take_shot(:enemy, :actions, 63)
      save_bitmap("008")
      
      # Troop enemy positions
      take_shot(:troop, :enemies, 1)
      save_bitmap("009")
      
      # List of events in a specific map
      take_shot(:event, :list, 26)
      save_bitmap("010")
      
      # Event commands (Engine)
      take_shot(:event, :commands, 26, 7)
      save_bitmap("011")
      
      # List of maps, and map hierarchy
      take_shot(:map, :list)
      save_bitmap("012A")
      take_shot(:system, :maps)
      save_bitmap("012B")
      
      # Map screenshot (example with each layer)
      take_shot(:map, :editor, 26, 0, false, true)
      save_bitmap("013A")
      take_shot(:map, :editor, 26, 1, false, true)
      save_bitmap("013B")
      take_shot(:map, :editor, 26, 2, false, true)
      save_bitmap("013C")
      take_shot(:map, :editor, 26, 3, true, true)
      save_bitmap("013D")
      
      # Switches full list
      take_shot(:system, :switches)
      save_bitmap("015")
      
      # Scripts list
      take_shot(:script, :list)
      save_bitmap("016")
      
      # List of all the files in the Titles folder
      take_shot(:files, "Titles")
      save_bitmap("017")

That's not all; soon I'll include here a big AddOn that uses Screen EX as a base.
I hope you find this useful!
That's not all; soon I'll include here a big AddOn that uses Screen EX as a base.
Sorry for the long wait... I present here the Screen EX Command! :ahappy:

This script allows breaking the character and line limits of the Show Text, Comment and Script event commands.

To use it, you have to place both the Screen EX and this one over the script Main and follow the instructions in this script.

With this, the width and height of those windows becomes unlimited. In addition, once the changes have been made, you can still see all the text in the editor.

Utility
- Make longer lines when showing text.
- Make more extended script calls and annotations.
- Visualize the message window content in a more exact way than in the default editor preview.
- Check script calls don't return an error (and return which type and line it is if they do).
- Get the parameters list and "code" value of each event command by pressing a button.

Code
Ruby:
#==============================================================================
# ** [XP] Wecoc's Event Command Debugger [Screen EX Command]
#------------------------------------------------------------------------------
# Author: Wecoc (no credits required)
# Version: 1.0
#------------------------------------------------------------------------------
# WARNING! This code requires the Screen EX 1.1 or superior
#------------------------------------------------------------------------------
# * INTRODUCTION
#
# This script allows breaking the limit of some event commands.
# By default those commands are Show Text, Comments and Script, but you could
# extend it. It's main utility is writing many more characters per line and
# more lines on those windows, which by default are pretty small.
#------------------------------------------------------------------------------
# * USAGE INSTRUCTIONS
#
# First thing is defining the event you want to get, in the start of the code.
# Once that's done, you play the game in Debug mode, from the editor.
# A window will open with commands to select and edit.
#
# Once you've made the changes you have to close both the project and the editor
# DIRECTLY, without saving and without opening the event.
# Once you open the event again, the changes will have been applied.
#
# The lines you should add in the start of the script, inside the method "ini",
# are those below:
#
# - Event
#     get_event_command_list(map, event[, page])
#
# - Common Event
#     get_common_event_command_list(id)
#
# - Battle Event
#     get_battle_command_list(id[, page])
#
# Agreements to: Orochii, ForeverZer0
#==============================================================================

#==============================================================================
# ** WECD Module
#==============================================================================

module WECD
  #============================================================================
  # * WECD Class
  #============================================================================
  class << self
    #--------------------------------------------------------------------------
    # * Initialize module
    #--------------------------------------------------------------------------
    def ini
      @list = nil ; @mode = nil
      #----------------------------------------------------------------------
      # Define here the event you want to get
      # Example: get_event_command_list(1, 1)
      #----------------------------------------------------------------------
      
      
      
      
      
      #----------------------------------------------------------------------
      return if @list.nil?
      $scene = Scene_EVDebug.new(@map_id, @event_id, @page, @mode)
    end
    #--------------------------------------------------------------------------
    # * Get event
    #--------------------------------------------------------------------------
    def get_event_command_list(map_id, event_id, page=1)
      @mode = 'event'
      begin
        @map_id, @event_id, @page = map_id, event_id, page
        map = load_data(sprintf("Data/Map%03d.rxdata", map_id))
        event = map.events[event_id]
        page = page - 1
        @list = event.pages[page].list
      rescue
        ScreenEX.message "The event couldn't be loaded"
        return
      end
    end
    #--------------------------------------------------------------------------
    # * Get common event
    #--------------------------------------------------------------------------
    def get_common_event_command_list(event_id)
      @mode = 'common_event'
      data_system = load_data('Data/System.rxdata')
      data_common_events = load_data('Data/CommonEvents.rxdata')
      map_id = data_system.edit_map_id
      begin
        @map_id, @event_id, @page = map_id, 1, event_id
        @list = data_common_events[event_id].list
      rescue
        ScreenEX.message "The common event couldn't be loaded"
        return
      end
    end
    #--------------------------------------------------------------------------
    # * Get battle event
    #--------------------------------------------------------------------------
    def get_battle_command_list(event_id, page=1)
      @mode = 'troop'
      data_system = load_data('Data/System.rxdata')
      data_troops = load_data('Data/Troops.rxdata')
      map_id = data_system.edit_map_id
      begin
        @map_id, @event_id, @page = map_id, event_id, page
        event = data_troops[event_id]
        page = page - 1
        @list = event.pages[page].list
      rescue
        ScreenEX.message "The battle event couldn't be loaded"
        return
      end
    end
    #--------------------------------------------------------------------------
    FILE_NAME = "Event Command"
    #--------------------------------------------------------------------------
    def file_name
      FILE_NAME
    end
  end
end

#==============================================================================
# ** Scene_EVDebug
#==============================================================================

class Scene_EVDebug
  #----------------------------------------------------------------------------
  # * Define starting parameters [General]
  #----------------------------------------------------------------------------
  def initialize(map_id, event_id, page, mode)
    rpgxp_load_data
    @map_id = map_id
    @event_id = event_id
    @page = page
    @mode = mode
    @map = load_data(sprintf("Data/Map%03d.rxdata", map_id))
    case @mode
    when 'event'
      @event = @map.events[event_id]
      page = page - 1
      @list = @event.pages[page].list
    when 'common_event'
      @event = $data_common_events[page]
      @list = @event.list
    when 'troop'
      @event_id = 1
      @event = $data_troops[event_id]
      page = page - 1
      @list = @event.pages[page].list
    end
    @interpreter = Interpreter.new
    set_window_data
    $game_map.setup(@map_id)
    @interpreter.setup(@list, @event_id)
  end
  #----------------------------------------------------------------------------
  # * Define starting parameters [Libraries]
  #----------------------------------------------------------------------------
  def set_window_data
    ini = Win32API.new('kernel32', 'GetPrivateProfileString','PPPPLP', 'L')
    @title = "\0" * 256
    ini.call('Game', 'Title', '', @title, 256, '.\\Game.ini')
    @title.delete!("\0")
    find_window = Win32API.new('user32', 'FindWindowA', 'PP', 'L')
    @main = find_window.call('RGSS Player', @title)
    @create_window = Win32API.new('user32','CreateWindowEx','lpplllllllll','l')
    @show_window = Win32API.new('user32','ShowWindow','ll','l')
    @destroy_window = Win32API.new('user32','DestroyWindow','p','l')
    @send_message = Win32API.new('user32', 'SendMessage', 'llll', '')
    @send_text = Win32API.new('user32', 'SendMessage', 'lllp', '')
    @create_font = Win32API.new("gdi32", "CreateFont", "iiiiiiiiiiiiip", "i")   
    @window_text = Win32API.new('user32','GetWindowText','npn','l')
    @metrics = Win32API.new('user32', 'GetSystemMetrics', 'I', 'I')
    @set_window_pos = Win32API.new('user32', 'SetWindowPos', 'LLIIIII', 'I')
    @window_rect = Win32API.new('user32','GetWindowRect','lp','i')
    @x = (@metrics.call(0) - 576) / 2
    @y = (@metrics.call(1) - 22) / 2 + 96
    @update_window = Win32API.new('user32','UpdateWindow','p','i')
    @input = Win32API.new('user32','GetAsyncKeyState','i','i')
  end
  #----------------------------------------------------------------------------
  # * Load game data
  #----------------------------------------------------------------------------
  def rpgxp_load_data
    $data_actors        = load_data('Data/Actors.rxdata')
    $data_classes       = load_data('Data/Classes.rxdata')
    $data_skills        = load_data('Data/Skills.rxdata')
    $data_items         = load_data('Data/Items.rxdata')
    $data_weapons       = load_data('Data/Weapons.rxdata')
    $data_armors        = load_data('Data/Armors.rxdata')
    $data_enemies       = load_data('Data/Enemies.rxdata')
    $data_troops        = load_data('Data/Troops.rxdata')
    $data_states        = load_data('Data/States.rxdata')
    $data_animations    = load_data('Data/Animations.rxdata')
    $data_tilesets      = load_data('Data/Tilesets.rxdata')
    $data_common_events = load_data('Data/CommonEvents.rxdata')
    $data_system        = load_data('Data/System.rxdata')
    $data_mapinfos      = load_data('Data/MapInfos.rxdata')
    $data_scripts       = load_data('Data/Scripts.rxdata')
    $game_temp          = Game_Temp.new
    $game_system        = Game_System.new
    $game_switches      = Game_Switches.new
    $game_variables     = Game_Variables.new
    $game_self_switches = Game_SelfSwitches.new
    $game_screen        = Game_Screen.new
    $game_actors        = Game_Actors.new
    $game_party         = Game_Party.new
    $game_troop         = Game_Troop.new
    $game_map           = Game_Map.new
    $game_player        = Game_Player.new
  end
  #----------------------------------------------------------------------------
  # * Set globals [General]
  #----------------------------------------------------------------------------
  TOP_Z = 999999999
  SELECT_COLOR = Color.new(254, 245, 168)
  SELECT_NULL = true
  CHR_MAX = 32768
  #----------------------------------------------------------------------------
  # * Set globals [Libraries]
  #----------------------------------------------------------------------------
  WS_BORDER      = 0x00000001
  WS_EDGE        = 0x00000200
  WS_BTHIN       = 0x00800000
  WS_POPUP       = 0x80000000
  WS_SIZABLE     = 0x00040000
  ES_MULTILINE   = 0x00000004
  ES_AUTOVSCROLL = 0x00000040
  ES_AUTOHSCROLL = 0x00000080
  WM_SETFONT = 0x0030
  WM_SETTEXT = 0x000C
  #----------------------------------------------------------------------------
  # * Show message window
  #----------------------------------------------------------------------------
  def show_message_window
    return if @script_window != nil
    # Draw window background
    @dummy_window.contents.clear
    @dummy_window.contents.draw_text(480, 80, 240, 32, "F5: Update data")
    @dummy_window.contents.draw_text(480, 104, 240, 32, "ESC: Cancel")
    color = Color.new(0, 0, 0)
    @dummy_window.contents.fill_rect(Rect.new(220, 23, 7, 1), color)
    @dummy_window.contents.fill_rect(Rect.new(221, 24, 5, 1), color)
    @dummy_window.contents.fill_rect(Rect.new(222, 25, 3, 1), color)
    @dummy_window.contents.fill_rect(Rect.new(223, 26, 1, 1), color)
    # Define window's style
    exst = [WS_EDGE]
    exstyle = 0
    for s in exst
      exstyle = exstyle | s
    end
    dwst = [WS_BTHIN, WS_POPUP, ES_MULTILINE, ES_AUTOVSCROLL, ES_AUTOHSCROLL]
    dwstyle = 0
    for s in dwst
      dwstyle = dwstyle | s
    end
    # Get window's contents
    content = @list[@index].parameters[0].clone
    i = @index
    loop do
      i += 1
      break if @list[i].code != 401
      content.concat("\r\n")
      content.concat(@list[i].parameters[0].clone)
    end
    content = String.utf82ansi(content)
    # Load window
    @script_window = @create_window.call(exstyle, 'Edit', '', dwstyle,
    @x, @y + 32, 348, 60, @main, 0, 0, 0)
    @font = @create_font.call(11,0,0,0,0,0,0,0,0,0,0,0,0,"Lucida Console")
    @send_message.call(@script_window, WM_SETFONT, @font, 1)
    @send_text.call(@script_window, WM_SETTEXT, 0, content)
    @show_window.call(@script_window, 1)
  end
  #----------------------------------------------------------------------------
  # * Show notes window
  #----------------------------------------------------------------------------
  def show_notes_window
    return if @script_window != nil
    # Draw window background
    @dummy_window.contents.clear
    @dummy_window.contents.draw_text(480, 80, 240, 32, "F5: Update data")
    @dummy_window.contents.draw_text(480, 104, 240, 32, "ESC: Cancel")
    # Define window's style
    exst = [WS_BORDER, WS_EDGE]
    exstyle = 0
    for s in exst
      exstyle = exstyle | s
    end
    dwst = [WS_POPUP, ES_MULTILINE, WS_SIZABLE, ES_AUTOVSCROLL, ES_AUTOHSCROLL]
    dwstyle = 0
    for s in dwst
      dwstyle = dwstyle | s
    end
    # Get window's contents
    content = @list[@index].parameters[0].clone
    i = @index
    loop do
      i += 1
      break if @list[i].code != 408
      content.concat("\r\n")
      content.concat(@list[i].parameters[0].clone)
    end
    content = String.utf82ansi(content)
    # Load window
    @script_window = @create_window.call(exstyle, 'Edit', '', dwstyle,
    @x, @y, 278, 98, @main, 0, 0, 0)
    @font = @create_font.call(13,0,0,0,0,0,0,0,0,0,0,0,0,"Tahoma")
    @send_message.call(@script_window, WM_SETFONT, @font, 1)
    @send_text.call(@script_window, WM_SETTEXT, 0, content)
    @show_window.call(@script_window, 1)
  end
  #----------------------------------------------------------------------------
  # * Show script window
  #----------------------------------------------------------------------------
  def show_script_window
    return if @script_window != nil
    # Draw window background
    @dummy_window.contents.clear
    @dummy_window.contents.draw_text(480, 80, 240, 32, "F5: Update data")
    @dummy_window.contents.draw_text(480, 104, 240, 32, "ESC: Cancel")
    # Define window's style
    exst = [WS_EDGE]
    exstyle = 0
    for s in exst
      exstyle = exstyle | s
    end
    dwst = [WS_BTHIN, WS_POPUP, ES_MULTILINE, ES_AUTOVSCROLL, ES_AUTOHSCROLL]
    dwstyle = 0
    for s in dwst
      dwstyle = dwstyle | s
    end
    # Get window's contents
    title = "Script call"
    content = @list[@index].parameters[0].clone
    i = @index
    loop do
      i += 1
      break if @list[i].code != 655
      content.concat("\r\n")
      content.concat(@list[i].parameters[0].clone)
    end
    content = String.utf82ansi(content)
    # Load window
    @script_window = @create_window.call(exstyle, 'Edit', '', dwstyle,
    @x, @y - 30, 316, 180, @main, 0, 0, 0)
    @font = @create_font.call(14,0,0,0,0,0,0,0,0,0,0,0,1,"Arial Unicode")
    @send_message.call(@script_window, WM_SETFONT, @font, 1)
    @send_text.call(@script_window, WM_SETTEXT, 0, content)
    @show_window.call(@script_window, 1)
  end
  #----------------------------------------------------------------------------
  # * Destroy editable window
  #----------------------------------------------------------------------------
  def destroy_window
    @destroy_window.call(@script_window)
    @script_window = nil
  end
  #----------------------------------------------------------------------------
  # * Start scene
  #----------------------------------------------------------------------------
  def main
    Audio.bgm_stop
    @viewport = Viewport.new(0, 0, 640, 316)
    # Show white background
    @back = Sprite.new(@viewport)
    @back.bitmap = Bitmap.new(640, 480)
    @back.bitmap.fill_rect(@back.bitmap.rect, Color.new(255, 255, 255))
    # Get event commands
    case @mode
    when 'event'
      ScreenEX.take_shot(:event, :commands, @map_id, @event_id, @page)
    when 'common_event'
      ScreenEX.take_shot(:common_event, :commands, @page)
    when 'troop'
      ScreenEX.take_shot(:troop, :commands, @event_id, @page)
    end
    ScreenEX.save_bitmap(WECD.file_name)
    bitmap = Bitmap.new("#{ScreenEX.folder}/#{WECD.file_name}")
    @sprite = Sprite.new(@viewport)
    @sprite.bitmap = bitmap
    @hover = Sprite.new(@viewport)
    @hover.bitmap = Bitmap.new(640, 28)
    @hover.bitmap.blt(0, 0, @sprite.bitmap, @hover.bitmap.rect)
    # Draw scroll arrows
    @scroll_arrow_up = Sprite.new
    @scroll_arrow_up.x = 640 - 24
    @scroll_arrow_up.y = 32
    @scroll_arrow_up.z = TOP_Z
    @scroll_arrow_up.bitmap = Bitmap.new(16, 16)
    @scroll_arrow_up.visible = false
    @scroll_arrow_down = Sprite.new
    @scroll_arrow_down.x = 640 - 24
    @scroll_arrow_down.y = 294
    @scroll_arrow_down.z = TOP_Z
    @scroll_arrow_down.bitmap = Bitmap.new(16, 16)
    @scroll_arrow_down.visible = false
    draw_arrows
    # Display bottom window
    @dummy_window = Window_Base.new(0, 316, 640, 164)
    @dummy_window.contents = Bitmap.new(640 - 32, 164 - 32)
    @dummy_window.contents.font.name = "Arial"
    @dummy_window.contents.font.size = 14
    @dummy_window.contents.font.bold = true
    # Draw cursor
    @cursor = Sprite.new(@viewport)
    @cursor.bitmap = Bitmap.new(1, 1)
    @cursor.blend_type = 2
    get_multi_data
    self.index = 0
    @trigger_frame = 0
    # Scene process
    Graphics.transition
    loop do
      Graphics.update
      Input.update
      update
      exit if $scene != self
    end
  end
  #----------------------------------------------------------------------------
  # * Draw scroll arrows
  #----------------------------------------------------------------------------
  def draw_arrows
    up = @scroll_arrow_up.bitmap
    down = @scroll_arrow_down.bitmap
    color = Color.new(0, 0, 0)
    up.fill_rect(Rect.new(7, 3,  2, 1), color)
    up.fill_rect(Rect.new(6, 4,  4, 1), color)
    up.fill_rect(Rect.new(5, 5,  6, 1), color)
    up.fill_rect(Rect.new(4, 6,  8, 1), color)
    up.fill_rect(Rect.new(3, 7, 10, 1), color)
    up.fill_rect(Rect.new(2, 8, 12, 1), color)
    up.fill_rect(Rect.new(1, 9, 14, 1), color)
    down.fill_rect(Rect.new(1, 6, 14, 1), color)
    down.fill_rect(Rect.new(2, 7, 12, 1), color)
    down.fill_rect(Rect.new(3, 8, 10, 1), color)
    down.fill_rect(Rect.new(4, 9,  8, 1), color)
    down.fill_rect(Rect.new(5, 10, 6, 1), color)
    down.fill_rect(Rect.new(6, 11, 4, 1), color)
    down.fill_rect(Rect.new(7, 12, 2, 1), color)
  end
  #----------------------------------------------------------------------------
  # * Get cursor index
  #----------------------------------------------------------------------------
  def index
    @index
  end
  #----------------------------------------------------------------------------
  # * Set cursor index
  #----------------------------------------------------------------------------
  def index=(index)
    return if @index == index
    @cursor.bitmap = Bitmap.new(640, 13 + @multi_index[index] * 13)
    s = SELECT_COLOR
    color = Color.new(255 - s.red, 255 - s.green, 255 - s.blue)
    @cursor.bitmap.fill_rect(@cursor.bitmap.rect, color)
    @cursor.y = 28 + index * 13 - @sprite.oy
    loop do
      if @cursor.y < 28
        @sprite.oy -= 13
        @cursor.y = 28 + index * 13 - @sprite.oy
      elsif @cursor.y > 312
        @sprite.oy += 13
        @cursor.y = 28 + index * 13 - @sprite.oy
      else
        break
      end
    end
    if @sprite.oy > 0
      @scroll_arrow_up.visible = true
    else
      @scroll_arrow_up.visible = false
    end
    if @sprite.oy + 316 < @sprite.bitmap.height
      @scroll_arrow_down.visible = true
    else
      @scroll_arrow_down.visible = false
    end
    @index = index
    refresh_window
  end
  #----------------------------------------------------------------------------
  def editable?(code)
    case code
    when 101, 108, 355
      return true
    end
    return false
  end
  #----------------------------------------------------------------------------
  def refresh_window
    @dummy_window.contents.clear
    command = @list[@index]
    @dummy_window.contents.font.color = Color.new(255, 255, 255)
    @dummy_window.contents.draw_text(480, 0, 120, 32, "Editable:")
    if editable?(command.code)
      @dummy_window.contents.font.color = Color.new(0, 255, 0)
      @dummy_window.contents.draw_text(600 - 120, 0, 120, 32, "TRUE", 2)
    else
      @dummy_window.contents.font.color = Color.new(255, 0, 0)
      @dummy_window.contents.draw_text(600 - 120, 0, 120, 32, "FALSE", 2)
    end
    @dummy_window.contents.font.color = Color.new(255, 255, 255)
    @dummy_window.contents.draw_text(480, 32, 120, 32, "S: View parameters")
    if command.code == 101 # Message
      @dummy_window.contents.draw_text(480, 56, 120, 32, "D: Preview")
    end
    if command.code == 355 # Message
      @dummy_window.contents.draw_text(480, 56, 120, 32, "D: Check")
      @dummy_window.contents.draw_text(480, 80, 120, 32, "Z: Execute")
    end
  end
  #----------------------------------------------------------------------------
  def get_multi_index(index)
    command = @list[index]
    m, i = 0, index
    case command.code
    when 101 # Message
      loop do
        i += 1
        break if @list[i].code != 401
        m += 1
      end
    when 102 # Choice
      loop do
        i += 1 ; m += 1
        break if @list[i].code == 404 && @list[i].indent == @list[index].indent
      end
    when 108 # Notes
      loop do
        i += 1
        break if @list[i].code != 408
        m += 1
      end
    when 111 # Condition
      loop do
        i += 1 ; m += 1
        break if @list[i].code == 412 && @list[i].indent == @list[index].indent
      end
    when 112 # Loop
      loop do
        i += 1 ; m += 1
        break if @list[i].code == 413 && @list[i].indent == @list[index].indent
      end
    when 209 # Move Event
      loop do
        i += 1
        break if @list[i].code != 509
        m += 1
      end
    when 301 # Battle
      loop do
        i += 1 ; m += 1
        break if @list[i].code == 604 && @list[i].indent == @list[index].indent
      end
    when 302 # Shop
      loop do
        i += 1
        break if @list[i].code != 605
        m += 1
      end
    when 355 # Script Call
      loop do
        i += 1
        break if @list[i].code != 655
        m += 1
      end
    end
    return m
  end
  #----------------------------------------------------------------------------
  def get_jump_index(index)
    command = @list[index]
    if SELECT_NULL == false
      return true if command.code == 0
    end
    case command.code
    when 401, 402, 403, 404, 408, 411, 412, 413, 509
      return true
    when 601, 602, 603, 604, 605, 655
      return true
    end
    return false
  end
  #----------------------------------------------------------------------------
  def get_multi_data
    @multi_index = []
    for i in [email hidden]
      @multi_index[i] = get_multi_index(i)
    end
    @jump_index = []
    for i in [email hidden]
      @jump_index[i] = get_jump_index(i)
    end
  end
  #----------------------------------------------------------------------------
  # * Update
  #----------------------------------------------------------------------------
  def update
    if $game_temp.message_window_showing
      @message_window.update
      if Input.trigger?(Input::C) or Input.trigger?(Input::B)
        @message_window.dispose
        @message_window = nil
        $game_temp.message_text = ""
        $game_temp.message_window_showing = false
        return
      end
    end
    if @script_window
      loop do
        Graphics.update
        @update_window.call(@script_window)
        # If you press F5 the content is refreshed
        if @input.call(0x74) & 0x01 == 1
          refresh_data
          destroy_window
          break
        end
        # If you press ESC all the changes are canceled
        Si pulsas ESC se cancelan los cambios
        if @input.call(0x1B) & 0x01 == 1
          destroy_window
          refresh_window
          break
        end
      end
    end
    @dummy_window.update
    @sprite.update
    update_cursor
    if Input.trigger?(Input::Y) # S: View parameters
      a = [@list[@index]]
      for i in 1..@multi_index[@index]
        a << @list[@index + i]
      end
      p *a
    end
    if Input.trigger?(Input::Z) # D: Preview / Check
      case @list[@index].code
      when 101 # Message
        previsualize_message
      when 355 # Script
        check_script
      end
    end
    if Input.trigger?(Input::A) # Z: Execute
      case @list[@index].code
      when 355 # Script
        evaluate_script
      end
    end
    if Input.trigger?(Input::C) # C: Open action
      get_action(@index)
    end
  end
  #----------------------------------------------------------------------------
  # * Preview message
  #----------------------------------------------------------------------------
  def previsualize_message
    content = @list[@index].parameters[0].clone
    i = @index
    loop do
      i += 1
      break if @list[i].code != 401
      content.concat("\n")
      content.concat(@list[i].parameters[0].clone)
    end
    $game_temp.message_text = content
    $game_temp.message_window_showing = true
    @message_window = Window_Message.new
  end
  #----------------------------------------------------------------------------
  # * Get script content
  #----------------------------------------------------------------------------
  def get_script_content
    content = @list[@index].parameters[0].clone
    i = @index
    loop do
      i += 1
      break if @list[i].code != 655
      content.concat(";")
      content.concat(@list[i].parameters[0].clone)
    end
    return content
  end
  #----------------------------------------------------------------------------
  # * Check script (find errors)
  #----------------------------------------------------------------------------
  def check_script
    content = get_script_content
    begin
      result = @interpreter.instance_eval(content)
      print "No errors found"
    rescue Exception => e
      message = "The code couldn't be executed \n"
      lines = e.message.scan(/\(eval\)\:\d+/)
      if lines.size > 0
        line = lines[0][7..lines[0].size].to_i
        message += "#{e.class} - Line:#{line}"
      end
      print message
    end
  end
  #----------------------------------------------------------------------------
  # * Evaluate script (get result)
  #----------------------------------------------------------------------------
  def evaluate_script
    content = get_script_content
    array = content.split(";")
    for line in array
      if line[0..1] == "p " or line[0..4] == "print"
        array.delete(line)
      elsif line.include?(" p ") or line.include?(" print ")
        array.delete(line)
      end
    end
    content = array.join(";")
    begin
      result = @interpreter.instance_eval(content)
      print result
    rescue
      return
    end
  end
  #----------------------------------------------------------------------------
  # * Apply action based on current index
  #----------------------------------------------------------------------------
  def get_action(index)
    command = @list[index]
    case command.code
    when 101 # Message
      show_message_window
    when 108 # Comment
      show_notes_window
    when 355 # Script
      show_script_window
    end
  end
  #----------------------------------------------------------------------------
  # * Get window text
  #----------------------------------------------------------------------------
  def get_window_text_array
    text = "\0" * CHR_MAX
    @window_text.call(@script_window, text, CHR_MAX)
    text.delete!("\0")
    text_array = text.split("\r\n")
    return text_array
  end
  #----------------------------------------------------------------------------
  def get_next_line(text_array)
    text = text_array.shift
    text = String.ansi2utf8(text) ; text.pop
    return text
  end
  #----------------------------------------------------------------------------
  # * Refresh data when changes are made
  #----------------------------------------------------------------------------
  def refresh_data
    command = @list[@index]
    case command.code
    when 101 # Message
      i = @index + 1
      loop do
        break if @list[i].code != 401
        @list.delete_at(i)
      end
      text_array = get_window_text_array
      @list[@index].parameters[0] = get_next_line(text_array)
      i = 1
      while text_array.size > 0 && i < 4
        text = get_next_line(text_array)
        n = RPG::EventCommand.new(401, command.indent, [text])
        @list.insert(@index + i, n)
        i += 1
      end
    when 108 # Comment
      i = @index + 1
      loop do
        break if @list[i].code != 408
        @list.delete_at(i)
      end
      text_array = get_window_text_array
      @list[@index].parameters[0] = get_next_line(text_array)
      i = 1
      while text_array.size > 0
        text = get_next_line(text_array)
        n = RPG::EventCommand.new(408, command.indent, [text])
        @list.insert(@index + i, n)
        i += 1
      end
    when 355 # Script
      i = @index + 1
      loop do
        break if @list[i].code != 655
        @list.delete_at(i)
      end
      text_array = get_window_text_array
      @list[@index].parameters[0] = get_next_line(text_array)
      i = 1
      while text_array.size > 0
        text = get_next_line(text_array)
        n = RPG::EventCommand.new(655, command.indent, [text])
        @list.insert(@index + i, n)
        i += 1
      end
    end
    @interpreter.setup(@list, @event_id)
    case @mode
    when 'event'
      save_data(@map, sprintf("Data/Map%03d.rxdata", @map_id))
      ScreenEX.take_shot(:event, :commands, @map_id, @event_id, @page)
    when 'common_event'
      $data_common_events[@page].list = @list
      save_data($data_common_events, 'Data/CommonEvents.rxdata')
      ScreenEX.take_shot(:common_event, :commands, @page)
    when 'troop'
      $data_troops[@event_id].pages[@page - 1].list = @list
      save_data($data_troops, 'Data/Troops.rxdata')
      ScreenEX.take_shot(:troop, :commands, @event_id, @page)
    end
    ScreenEX.save_bitmap(WECD.file_name)
    bitmap = Bitmap.new("#{ScreenEX.folder}/#{WECD.file_name}")
    @sprite.bitmap = bitmap
    get_multi_data
    self.index = @index
    refresh_window
  end
  #----------------------------------------------------------------------------
  # * Update cursor
  #----------------------------------------------------------------------------
  def update_cursor
    if Input.trigger?(Input::DOWN) || Input.trigger?(Input::UP)
      @trigger_frame = 0
    end
    if Input.press?(Input::DOWN) || Input.press?(Input::UP)
      @trigger_frame += 1
    end
    return if @trigger_frame > 1 && @trigger_frame < 8
    if Input.press?(Input::DOWN)
      i = @index
      loop do
        i += 1
        return if @jump_index[i].nil?
        break if @jump_index[i] == false
      end
      self.index = i
    end
    if Input.press?(Input::UP)
      i = @index
      loop do
        i -= 1
        return if i < 0
        break if @jump_index[i] == false
      end
      self.index = i
    end
  end
end

#==============================================================================

class Scene_Title
  alias start_debug_command main unless $@
  def main
    WECD.ini if $DEBUG
    start_debug_command
  end
end

#==============================================================================

class Interpreter
  # Wecoc's Message System (WMS) support
  if self.method_defined?(:clear_message)
    alias wms_support clear_message unless $@
    def clear_message
      return if $game_system.nil?
      wms_support
    end
  end
end

Spoiler: FAQ
Why was it made so you have to execute the project and edit it from there, and not from the editor directly?
Because to edit the editor you would need to create external software, which doesn't allow as much control as this code. Also, another option would be editing the RPGXP.exe, but that's against the EULA. On the other hand, this script does not modify any of that so it is totally legal to use it to change the content of the commands.

Why do I get an error of invalid event ID when I try to call a common event or battle event?
Those special events still require an event ID to work, because of the route command. The script uses event ID 1 of the current map in the editor; if it doesn't exist it will return that error. Simply change your current map to another one.

When I remove the script the windows with extended content will still have everything?
Yes. The script basically allows to extend the window limits, all the contents themselves have no limit by default.

Does the preview support message codes from a custom message system like UMS?
Yes, it does (as far as I could check).

Original thread: https://forums.rpgmakerweb.com/threads/enginer-tool-screen-ex.138270/