Remember the last Command selected on Ksi's Simple Menu Script

Hello! 🙂
I'm usig the Simple Menu Script by Ksi (And modified by Zalerinian) and I'm wondering if its possible edit the script so it remembers the last command selected after you open one of the options and then you return to the command window again.
I explain myself:
  • Pressing "Esc" you open the Menu
  • Then you select the Command (In this case there's Items, Save and Exit), let's imagine we select the Save command, so the Save Window will open.
  • Then we pres "Esc" again to exit the Save Window and return to the Menu. But when we return, the Items command is selected instead of the Save command, which is the last command we selected.
Is there an option to correct that?

Here's the script:
Spoiler


Thanks in advance!
https://www.rpgmakercentral.com/topic/34450-remember-last-choice-in-selection-windows/
@Roninator2 Sorry about my ignorance but I'm trying to copy the script provided in the topic (And even switching on the switch indicated in the script) but nothing happens. What I'm suposed to do?

This is the script I'm talking about:
Spoiler
Code:
module Nataxinus
  module RememberSelection
   # Switch to remember the position of cursor
   ON_SWITCH = 1
   # The classes you want to be affected by this
   WINDOW_CLASSES = [Window_ChoiceList]
   # Reset position of cursor. Will deactivate last index if as long as set to
   # true.
   RESET_SWITCH = 2
  end
end

class Window_Selectable < Window_Base
  include Nataxinus::RememberSelection
 
  alias :remember_init :initialize
  def initialize(x, y, width, height)
   @locked = false
   remember_init(x, y, width, height)
   if reset_switch
     @@last_index = 0
   else
     @@last_index ||= 0
     return if !$game_switches[ON_SWITCH] || !WINDOW_CLASSES.include?(self.class)
     self.index = @@last_index if self.index
   end
  end
 
  alias :remember_activate :activate
  def activate
   remember_activate
   if reset_switch
     @@last_index = 0
   else
     return if !$game_switches[ON_SWITCH] || !WINDOW_CLASSES.include?(self.class)
     select(@@last_index)
   end
  end
 
  alias :remember_select :select
  def select(index)
   remember_select(index)
   if reset_switch
     @@last_index = 0
     @locked = false
     return
   end
   @@last_index = index if index && $game_switches[ON_SWITCH] &&
   WINDOW_CLASSES.include?(self.class) && @locked
   @locked = false
  end
 
  alias :remember_cursor_down :cursor_down
  def cursor_down(wrap = false)
   @locked = true
   remember_cursor_down(wrap)
  end
 
  alias :remember_cursor_up :cursor_up
  def cursor_up(wrap = false)
   @locked = true
   remember_cursor_up(wrap)
  end
 
  alias :remember_cursor_right :cursor_right
  def cursor_down(wrap = false)
   @locked = true
   remember_cursor_down(wrap)
  end
 
  alias :remember_cursor_left :cursor_left
  def cursor_left(wrap = false)
   @locked = true
   remember_cursor_left(wrap)
  end

  alias :remember_cursor_pagedown :cursor_pagedown
  def cursor_pagedown
   @locked = true
   remember_cursor_pagedown
  end
 
  alias :remember_cursor_pageup :cursor_pageup
  def cursor_pageup
   @locked = true
   remember_cursor_pageup
  end
 
  def reset_switch
   $game_switches[RESET_SWITCH]
  end
 
  alias :remember_cursor_update :update
  def update
   remember_cursor_update
   @@last_index = 0 if reset_switch && @@last_index != 0
  end
end
Have you tried to place the script he provided above the one you were using?
sorry, haven't used the script just found it and thought it would work for you.
Which switch are you using?
It says the first one sets the script to work, the second resets the selection.
But I never tested it as I never needed it.
@Ebanyle Yes! I just tried it and it doesn't work...
@Roninator2 I'm using the first switch, the "ON_SWITCH". I also tried editing the "WINDOW_CLASSES" part adding "Window_MenuHCommand" which I suposed that is the Simple Menu Script's command window. But I'm not a scripter so I don't know if it is what I have to do.
Maybe there's a way to merge the two scipts or so... I think the script in the other Topic is meant to be used in Choice List windows maybe that's why it doesn't work.
*Little Bump*
Works fine for me.

As long as you have Nataxus' script under the Ksi script and you have properly set up Nataxus' script to include the correct Window and you have the designated game switch turned on, it should work fine. If it still doesn't, there is probably a script clash with something else you are using, in which case nobody will be to able help if you don't specify what else you are running.
I also tried editing the "WINDOW_CLASSES" part adding "Window_MenuHCommand" which I suposed that is the Simple Menu Script's command window.
Yes, that is the correct window to add. It should look like:
Code:
WINDOW_CLASSES = [Window_ChoiceList, Window_MenuHCommand]

Original thread: https://forums.rpgmakerweb.com/threads/remember-the-last-command-selected-on-ksis-simple-menu-script.100812/