function Window.BeginInput(C,Y,U)if GuiService.MenuIsOpen then C:Hide()end if U and C:IsVisible()==false then return end if C.Cmdr.ActivationKeys[Y.KeyCode]then if C.Cmdr.MashToEnable and not C.Cmdr.Enabled then if tick()-lastPressTime<1 then if pressCount>=5 then return C.Cmdr:SetEnabled(true)else pressCount=pressCount+1 end else pressCount=1 end lastPressTime=tick()elseif C.Cmdr.Enabled then C:SetVisible(not C:IsVisible())wait()C:SetEntryText("")if GuiService.MenuIsOpen then C:Hide()end end return end if C.Cmdr.Enabled==false or not C:IsVisible()then if C:IsVisible()then C:Hide()end return end if Y.KeyCode==Enum.KeyCode.Down then C:SelectVertical(1)elseif Y.KeyCode==Enum.KeyCode.Up then C:SelectVertical(-1)elseif Y.KeyCode==Enum.KeyCode.Return then wait()C:SetEntryText(((C:GetEntryText()):gsub("\n","")):gsub("\r",""))elseif Y.KeyCode==Enum.KeyCode.Tab then local Y=C.AutoComplete:GetSelectedItem()local U=C:GetEntryText()if Y and not((U:sub(#U,#U)):match("\037\115")and C.AutoComplete.LastItem)then local U=Y[2]local L local p=true local i=C.AutoComplete.Command if i then local Y=C.AutoComplete.Arg L=i.Alias p=C.AutoComplete.NumArgs~=#i.ArgumentDefinitions local g=i.Arguments for C=1,#g,1 do local p=g[C]local i=p.RawSegments if p==Y then i[#i]=U end local e=p.Prefix..table.concat(i,"\044")if e:find(" ")then e=("\037\113"):format(e)end L=("\037\115 \037\115"):format(L,e)if p==Y then break end end else L=U end wait()C:SetEntryText(L..(p and" "or""))else wait()C:SetEntryText(C:GetEntryText())end else C:ClearHistoryState()end end

function Window:BeginInput(input, gameProcessed)
	if GuiService.MenuIsOpen then
		self:Hide()
	end

	if gameProcessed and self:IsVisible() == false then
		return
	end

	if self.Cmdr.ActivationKeys[input.KeyCode] then -- Activate the command bar
		if self.Cmdr.MashToEnable and not self.Cmdr.Enabled then
			if tick() - lastPressTime < 1 then
				if pressCount >= 5 then
					return self.Cmdr:SetEnabled(true)
				else
					pressCount = pressCount + 1
				end
			else
				pressCount = 1
			end
			lastPressTime = tick()
		elseif self.Cmdr.Enabled then
			self:SetVisible(not self:IsVisible())
			wait()
			self:SetEntryText("")

			if GuiService.MenuIsOpen then -- Special case for menu getting stuck open (roblox bug)
				self:Hide()
			end
		end

		return
	end

	if self.Cmdr.Enabled == false or not self:IsVisible() then
		if self:IsVisible() then
			self:Hide()
		end

		return
	end

	if input.KeyCode == Enum.KeyCode.Down then -- Auto Complete Down
		self:SelectVertical(1)
	elseif input.KeyCode == Enum.KeyCode.Up then -- Auto Complete Up
		self:SelectVertical(-1)
	elseif input.KeyCode == Enum.KeyCode.Return then -- Eat new lines
		wait()
		self:SetEntryText(self:GetEntryText():gsub("\n", ""):gsub("\r", ""))
	elseif input.KeyCode == Enum.KeyCode.Tab then -- Auto complete
		local item = self.AutoComplete:GetSelectedItem()
		local text = self:GetEntryText()
		if item and not (text:sub(#text, #text):match("%s") and self.AutoComplete.LastItem) then
			local replace = item[2]
			local newText
			local insertSpace = true
			local command = self.AutoComplete.Command

			if command then
				local lastArg = self.AutoComplete.Arg

				newText = command.Alias
				insertSpace = self.AutoComplete.NumArgs ~= #command.ArgumentDefinitions

				local args = command.Arguments
				for i = 1, #args do
					local arg = args[i]
					local segments = arg.RawSegments
					if arg == lastArg then
						segments[#segments] = replace
					end

					local argText = arg.Prefix .. table.concat(segments, ",")

					-- Put auto completion options in quotation marks if they have a space
					if argText:find(" ") then
						argText = ("%q"):format(argText)
					end

					newText = ("%s %s"):format(newText, argText)

					if arg == lastArg then
						break
					end
				end
			else
				newText = replace
			end
			-- need to wait a frame so we can eat the \t
			wait()
			-- Update the text box
			self:SetEntryText(newText .. (insertSpace and " " or ""))
		else
			-- Still need to eat the \t even if there is no auto-complete to show
			wait()
			self:SetEntryText(self:GetEntryText())
		end
	else
		self:ClearHistoryState()
	end
end
