Script to show/hide UI elements

I’m looking for a script that I can put in a macro that will let me hide action bars, chat and quest list from the UI (so one script/macro that hides of all them at the same time). Anyone knows how to create one? Thanks!

I use the following:

/run UIParent:Hide(); Screenshot(); C_Timer.After(.01,function() UIParent:Show(); end);

I then rebind this macro to PrtSc, and set the keybind for in-game SS as ctrl+PrtSc (that way if I need to take a SS of UI elements, I still can)

This macro hides the entire UI, takes a screenshot, and unhides the UI after a very, very short delay.

If you just need to hide the UI, or certain elements, use the Hide() widget

3 Likes

First off, thanks for the reply!

It wouldn’t be for making screenshots. I am basically aiming in trying to put together a more minimal UI. I’ve noticed that while questing most of the time I don’t need to see action bars, chat and quests on my screen, but would still like to have them handy a keybind away, if that makes sense.

Regarding the script, would you mind explaining me how and what to modify to make it work? Sorry if I’m basically asking for you to make it for me, but I understand little to nothing about this. :frowning:

If you’re looking to set up a ‘minimalist’ UI then you probably want something with more functionality, like a UI overhaul addon (Tuk/ElvUI, LUI, etc). These UI overhaul addons have more functionality and customizable settings than just some line or two of script in a macro.

There’s plenty of examples and tutorials on how to achieve such settings.

As for the explaining, if you’re determined on trying it with macros… You can attach the Show/Hide() widgets to any valid frame. Minimap, ActionBars, ChatFrames… You just gotta find the name of the elements you want to hide. That can be done with the command ‘/fstack’

The Screenshot and C_Timer.After functions wouldn’t be of concern if you’re just looking to show/hide certain UI elements for making a minimal UI.

I’m specifically trying to avoid any UI addons. I have MoveAnything but unfortunatly it doesn’t seem to come with a “hide/show” keybind option. I will surely try to see if I can make that script work. I can’t check the names now, but something like this should work?

This to hide
/run UIParent:Hide(ActionBar, ChatFrame);

This to show
/run UIParent:Show(ActionBar, ChatFrame);

Of course the names are just placeholders, I will look for them more in depth when I get the chance. Also, is there any way to have a script that on first launch will hide and on the second will show? So that I can bind the “show/hide” on the same keybind without having to take two of them.

Thanks again for your support!

There is no real difference between using an addon and using scripts other than addons are generally better written, more reliable, and less prone to mistakes.

If you don’t want to use UI addons, you might find it interesting that the client itself is a collection of 85 or so (mostly poorly written) addons published by Blizzard.

There’s nothing magical or shameful about using addons when you have a need met by one and attempting to reinvent a wheel already working well and and distributed and produced professionally by people who know full well how to make wheels is a bit on the foolish side.

For one thing, there is, quite often, more to hiding something than simply hiding it. In many cases, whatever it is that you’re hiding will reappear because the show/hide status setter is buried down in some function that you need to hook (because some things, in the normal course of the game, hide and show themselves in different circumstances - like when you get in a vehicle or start a puzzle scenario) and will override your settings in frustrating ways.

Feel free to experiment, but for long-term satisfaction, I think you’re going to find that you need something a bit more robust than a couple lines of code you can run ad-hoc to make things look the way you want them to look.

My problem with UI addons is that they are generally kinda heavy, having - as you said - a lot of functionalities. And playing from a laptop I need to try to keep things as light as possible. I would love for a light addon that shows/hides groups of ui without having all the extras, but while I’ve been searching for it, I couldn’t find it.

I also understand that a line of script is not going to be as effective, but that’s something I can improve over time, maybe with the help of the community. I have read somewhere that there is a way to make a script not “reset” itself when such events occurs, but I really understand very little about scripts and coding. :\

In your example above, it would look like:

/run ChatFrame:Hide();
/run ActionBar:Hide();

If you were to do:

/run UIParent:Hide();

You’ll see that EVERYTHING becomes hidden on your screen.

If you want a boolean check to make a toggle-like macro:

/run if (Region:IsVisible() == TRUE) then Region:Hide() else Region:Show(); end;

Just replace “Region” with whatever UI element you want to toggle on/off. Minimap, ChatFrame, ActionBar, etc…

As for the “on first launch” stuff, that’s getting into writing your own customized addon, and listening to game events, specifically PLAYER_ENTERING_WORLD and such.

1 Like

“My problem with UI addons is that they are generally kinda heavy”

99% of heavy lifting for most addons is in the setup phase while you’re watching a bar scroll across your screen. As for the rest, anything additional is insignificant in the greater scheme of things unless the author has done a truly terrible job (those addons don’t tend to last long much less across expansions).

If you manually Hide()/Show() secure elements like action bars and unit frames in combat you will get errors and no result.

Whatever you do, you will not be able to fit everything into a single macro so an addon that sets up the secure frames that you can’t manualy toggle in combat and a function you can use in a macro to toggle the rest will be required.

Even though you see actionbar, minimap, chat frame, there is a whole lot more to them than that. Digging them all out and finding the best way to handle each one to work for you and then bring them all together will be a chore in itself, (hence addons where some kind soul has done all the hard work for you is the preferred option).

As a (very small, crude) starter, something along the lines of:

local ToggleFrames = true

RegisterStateDriver(MultiBarBottomLeft, "visibility", "[target=target, noexists] hide; show")
RegisterStateDriver(MultiBarBottomRight, "visibility", "[target=target, noexists] hide; show")
RegisterStateDriver(PlayerFrame, "visibility", "[target=target, noexists] hide; show")

function ToggleMyFizzleBits()
	ToggleFrames = not ToggleFrames
	for i=1, NUM_CHAT_WINDOWS do
		_G["ChatFrame"..i]:SetShown(ToggleFrames)
	end
	GeneralDockManager:SetShown(ToggleFrames)
	ObjectiveTrackerFrame:SetShown(ToggleFrames)
end

Where the action bars I’ve included and player frame will automatically hide until you have a target. Other frames in the function you can toggle on/off in a macro using:

/run ToggleMyFizzleBits()

2 Likes

Thanks to all replies. Seems like I’ll have to try and download an interface addon again and see how much memory it takes. I was hoping I could solve with a simple script but seems it’s not the case, unfortunately. Regardless, I appreciated your inputs on the matter. Thanks!

Unless you’re running very, very short of system memory, “how much memory it takes” isn’t really a good indicator of the impact of an addon.

A very small addon, written very poorly, can totally disrupt your play.

An enormous addon that makes very few calls can be virtually impact-free.

Generally, the more comprehensive the UI addon is, the more versatile it is, but that doesn’t mean it’s going to take up more of your CPU time.

I find that addons often impact on my frame rate so I tend to be as lightweight as possible. That being said all your statements are right and make sense! I guess my next question would be if you know of any interface addon that meet the following requirements:

  • Have a “hide/show group of ui element” settable on keybind
  • Can be found on Twitch app rather than having to download it from their own website (i.e. ElvUi).

Thanks in advance!

I only use ElvUI as a UI mod because it’s incredibly well-maintained and the staff that does it is very responsive to well-documented bugs (when they show up - very rare).

Only the main ElvUI module has to be downloaded outside of Twitch and TukUI.org has a desktop app that manages that (and many other addons as well), so it shouldn’t be a huge issue to use that if you want to.

If you choose to and you want help with it, you can reach out to me as Kaldara#11970 and I’ll walk you though much of the setup complexity (there is a bit - but that’s true of any complex system).

I’ve also got a solid baseline profile I can share as well as some custom code that makes ElvUI even better.

If you take this approach, my advice is to download a few other ElvUI-related addons.

The base addon will actually include two addons:

  • ElvUI
  • ElvUI_Config

Beyond that, i strongly recommend these:

  • ElvUI_ExtraActionBars (to give you controllable access to 48 action slots otherwise not available)
  • ElvUI_CustomMedia (to give you access additional fonts and status bars)
  • ElvUI_DTBars2 (to give you access to configurable custom datatext bars)
  • ElvUI_ExtraDataTexts (to give you access to some pre-defined extra data elements that can be included in any datatext bar)
  • ElvUI_Textures (to give you access to (so far) one extra texture overlay)

I can also send you copy of my companion addon (uncreatively named “StartUp”) that tunes that stuff just a bit and will provide a place to put code needed to make further adjustments (like custom commands to mess with placement, visibility, and size of frames managed by ElvUI).

As to what can be made to appear and disappear at will? That can vary. Some things I know work. Some things I know don’t work or don’t work well. But you won’t likely find anyone who knows more about the inner workings of ElvUI. I’ve been . . . well . . . I guess the word would be “hacking” that addon for about three years trying to find the boundaries of what I can do with it.

Some frames are relatively simple to manipulate, others less so.

Really thank you for your availability! At the end I’ve decided I’ll stick with the normal UI. As said I have used ElvUI for over a year, but at the end of the day, I prefer the standard UI. The only thing I would’ve used on ElvUI (if there’s even such setting) would have been hiding groups of UI elements on keybind. I don’t care for the rest of the costumization. But really thank you for taking the time to reply to me and for telling me to feel free to reach you for support. Much appreciated.

You know you can shut off almost all elements of ElvUI in the Config Panel and those you don’t shut off, you can make appear to look like Blizzard’s UI through the skinning (or not skinning) options, right?

I hate to see anyone stuck with that g-dawful standard UI - depending on your setup choices, you’re missing direct bind access to between half and a quarter of the possible action slots, for one thing, and placement of the elements is, from an ergonomic perspective, a freaking nightmare (your eyes literally have to scan all four corners of the screen and the center to get vital tactical information).

Let me know if you change your mind.

Would any of you geniusii here know how to hide/toggle the ‘Dominos’ extra bar (for quests/zone abilities) ? Would be MUCH appreciated; I’ve managed to get it to fade in on mouseover for now… I’d like to have more of my own of these “toggling” scripts in-game - of course this functionality is not really a necessity but would be nice to learn how to do! Thanks!

I don’t know if this has already been discovered by OP but just wanted to reach out here as i was looking for a simple solution myself. It turns out you can simply hide and show UI with Alt+Z. This will toggle all UI elements on/off. Hope this is useful for others out there!

Do these scripts still work in-game? Can’t seem to get the following logic to do anything…

/run if (ActionBar:IsVisible() == TRUE) then ActionBar:Hide() else ActionBar:Show(); end;

This is the script I use for toggling the show hide of UI elements:

/run local m=ObjectiveTrackerFrame if m:IsShown()then m:Hide()else m:Show()end

That one toggles the Objective Tracker, but you can replace ObjectiveTrackerFrame with the name of the frame you want to toggle.

1 Like