How's possible to minimize an extension window?

I’m creating my own extension, but sometimes I would like to minimize the extension window. How could I do it?


image

ps: I resized mannualy, i would like this automaticly, using an arrow for example.

Dialog window minimize and restore are not exposed to the Ruby API.

You can close() and when you need to reopen, reattach the callbacks then call show() again.


If you are only concerned about Windows platform, you can use the Windows Scripting Host Shell object and it’s SendKeys method. But your dialog must have the focus.

# MS Windows using English ...
def minimize_dialog(dialog)
  dialog.bring_to_front
  dialog.execute_script("window.focus();")
  require 'win32ole' unless defined?(WIN32OLE)
  shell = WIN32OLE.new("Wscript.Shell")
  shell.SendKeys("%( )") # ALT+SPACE, to activate the window menu
  shell.SendKeys("n") # then N to choose Minimize from the menu
end

However, be aware that the hotkeys for menus may vary if Windows is using a language other than English.

1 Like

How about dialog.set_size?

VideoToGif_GIF 2

2 Likes

I didn’t think of this, but it gives the appearance of minimization even though the window does not believe it has been minimized. (This means that there will not be a Restore button on the caption bar.)

dialog.set_size(dialog.get_size[0], 32)

It seems like 32 is the minimum height allowed on MS Windows.

1 Like

Was exactly it. Thank you.
are you changing the size with the html dialog dynamically?

It is being done when the user clicks the “Details” button, which fires a Ruby-side dialog callback proc, which makes the dialog.set_size call.

1 Like