Script close all open windows

Script close all open windows

The script works fine for me
Have you tried debugging it?

eg with this variant, do you get any dialogs pop up?

Re: Script to close all open windows

Re: Script to close all open windows

Re: Script to close all open windows

«If I click OK OK OK all windows are closing»
Which windows? The dialog window or your open windows?

I see zero reason why the code would work with a msgbox in, but will not work without.

Re: Script to close all open windows

Re: Script to close all open windows

@Thouldre: This code doesn’t mess with «Start» or «Program Manager», so it doesn’t ask if you want to shut down Windows. You get a count of the windows closed at the end. You can just hit Escape to bail out. I’m running Win7 Pro, X64, works okay. Everything is running as Admin.

Edit: I’ll mess with it a little. The Shutdown dialog appears briefly, which is disconcerting. Does work, though.
Re-edit: My If statement doesn’t seem to do very much. Commented out.

Re: Script to close all open windows

It somehow closes even the desktop shortcuts but first there are a lot of random windows like those posted above.

Forget it, I don’t want to waste more of your time for something I already have an application for.

Re: Script to close all open windows

Thouldre wrote: It somehow closes even the desktop shortcuts but first there are a lot of random windows like those posted above.

Forget it, I don’t want to waste more of your time for something I already have an application for.

The author of the CloseAll application you linked wrote an open source Alt+Tab replacement for XP, TaskSwitchXP. The code for determining whether a window for switching to/closing should be displayed is mostly the same in both applications, so I took it and added the additional Windows 8+ specific checks CloseAll does. Thanks also to the authors of https://github.com/kvakulo/Switcheroo — better checks were able to be added.

EDIT: Also note CloseAll runs with UI Access privileges. For this script to have the same effectiveness (assuming this function itself is as effective as CloseAll’s code), you must either run this script as administrator or enable the UI Access option in the AutoHotkey installer and run this script with UI Access.

Sorry, I was being too vague here — because CloseAll is signed and has UI Access capability, it can close programs started as admin or other UI Access programs (like the on screen keyboard) without needing to be admin itself. For AutoHotkey to be able to do the same, the script must be run as admin or with UI Access.

EDIT 2: You’re welcome, Thouldre

Re: Script to close all open windows

Re. identifying windows with a taskbar button:
Recover accidentally closed window/program — AutoHotkey Community
https://autohotkey.com/boards/viewtopic . 28#p147928

Does anyone have any ideas on the differences between the taskbar button list and the alt-tab menu list. And also, how to remove Desktop or another window from the alt-tab menu (other than the method that makes the alt-tab menu look old school).

Читайте также:  Голосовое управление для линукс

Related question:
How can i remove a window from taskbar and Alt+Tab window but still have access to it through an hotkey? — AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=5&t=21152

Re: Script to close all open windows

Thouldre wrote: It somehow closes even the desktop shortcuts but first there are a lot of random windows like those posted above.

Forget it, I don’t want to waste more of your time for something I already have an application for.

The author of the CloseAll application you linked wrote an open source Alt+Tab replacement for XP, TaskSwitchXP. The code for determining whether a window for switching to/closing should be displayed is mostly the same in both applications, so I took it and added the additional Windows 8+ specific checks CloseAll does.

EDIT: Also note CloseAll runs with UI Access privileges. For this script to have the same effectiveness (assuming this function itself is as effective as CloseAll’s code), you must either run this script as administrator or enable the UI Access option in the AutoHotkey installer and run this script with UI Access.

Re: Script to close all open windows

Oi, I’m sorry I hadn’t noticed this earlier. @evilC was right in a post above that in my code, I omitted a space.

This should work all the same:

(But it might have the desktop icon-hiding behavior, not sure.)

But if qwerty12 came in with a good code for ya, no worries.

Re: Script to close all open windows

Re: Script to close all open windows

Thouldre wrote: It somehow closes even the desktop shortcuts but first there are a lot of random windows like those posted above.

Forget it, I don’t want to waste more of your time for something I already have an application for.

The author of the CloseAll application you linked wrote an open source Alt+Tab replacement for XP, TaskSwitchXP. The code for determining whether a window for switching to/closing should be displayed is mostly the same in both applications, so I took it and added the additional Windows 8+ specific checks CloseAll does. Thanks also to the authors of https://github.com/kvakulo/Switcheroo — better checks were able to be added.

EDIT: Also note CloseAll runs with UI Access privileges. For this script to have the same effectiveness (assuming this function itself is as effective as CloseAll’s code), you must either run this script as administrator or enable the UI Access option in the AutoHotkey installer and run this script with UI Access.

Sorry, I was being too vague here — because CloseAll is signed and has UI Access capability, it can close programs started as admin or other UI Access programs (like the on screen keyboard) without needing to be admin itself. For AutoHotkey to be able to do the same, the script must be run as admin or with UI Access.

Close a window opened with window.open() after clicking a button

I have a simple case here:

I use window.open(‘http://remoteserver.com/success’) to open a window in the browser like this:

Now the remote server sends an HTML like this:

Now when a user clicks on the «go back» button, it shows a warning that windows can only be closed by a script who opened it!

How do I close such window?

2 Answers 2

You can use window.postMessage() to post a message to the parent window. In the parent window, listen for new messages and close the window when you get a message with the correct data from the proper origin.

This is a security feature since scripts should not have full control over all open windows. From the window.close() spec we can get the following:

The close() method on Window objects should, if all the following conditions are met, close the browsing context A:

The corresponding browsing context A is script-closable.

Читайте также:  Linux настройка терминала bash

The responsible browsing context specified by the incumbent settings object is familiar with the browsing context A.

The responsible browsing context specified by the incumbent settings object is allowed to navigate the browsing context A.

A browsing context is script-closable if it is an auxiliary browsing context that was created by a script (as opposed to by an action of the user), or if it is a top-level browsing context whose session history contains only one Document.

One solution that you can use is the window.postMessage API (https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage) that enables cross-origin communication in a safe manner. Basically what you do is the following:

Your opening script keeps a reference to the opened window and registers a listener for incoming messages

The opened window’s html sends an event as soon as the user clicks the button

The script which opened the window actually closes the window in its listener method

AppleScript: Close all open Windows

I’m trying to write an apple script to close all open Windows. The following is what I tried:

This does not seem to work. I get:

Script Error: System Events got an error: Can’t get application (item 1 of every application process whose visible = true). number -1728

I don’t care if applications quit or if just the windows close.

I tried to debug this, but I could not get this script opened in Xcode.

Edit: Thanks to user3439894 I’ve settled on the following script which just sends Command + Q to each of the visible applications:

This works for me for now. As user3439894 suggested, I need to go through and understand the AppleScript Language Guide

1 Answer 1

The first issue is in what (application processes where visible is true) returns.

As an example, on a clean install of macOS 10.13 with just Finder and Script Editor open:

What you really want is to get a list of names of applications that are visible, e.g.:

The following example AppleScript code will try to close all open documents of each application and on error close all windows.

Now I opened some documents in TextEdit and Preview and some windows in Finder then ran the example AppleScript code. It closed all open documents in TextEdit and Preview and all windows in Finder, but not Script Editor.

Note: This will not close and Script Editor documents and silently errors out with:

Example AppleScript code:

Also note that with this example AppleScript code as coded will not close every document or close every window of an application that does not support those commands and should fail silently because of the try command.

This example AppleScript code is being presented to illustrate what’s wrong with your present code and an example of how to help achieve your goal.

Форум

Справочник

window.close

Синтаксис

Описание, примеры

Если закрываемое окно не было открыто при помощи window.open, то
при его закрытии выводится предупреждение. Посетитель может отклонить закрытие.

А как закрыть окно если открылось не через javascript ?

А также Но будет вопрос посетителю, хочет ли он закрыть окно.

function exit() <
var thisWindow = window.open(«Listing3.html»,’_self’);
var exit = confirm(«Хотите закрыть страницу?»);
if(exit) <
thisWindow.close();
>
>

Как из родительского окна можно передать фокус окну, открытому следующей командой?
wid = window.open(‘1.htm’,’wname’,’width=300,height=300′);
wname.focus()
wid.focus()
window.wid.focus()
window.wname.focus()
self.wid.focus()
помогите плиз.

а у меня не получается закрыть окно, которое открыто не скриптом.

window.close.php

js/window.js

Подскажите как закрыть страницу через javaScript

если вставить в страницу скрипт с window.close(); то ничего не происходит..

нежно что бы при открытии страницы она закрывалась скажем через 5 секунд.

Та же проблема. Не срабатывает window.close()

Читайте также:  Driverpack audio windows 10

Для доступа к свойствам текущего окна используется self. Используйте self.close();

Почему-то window.close(), self.close(), this.close() работают только в Opera.

Если окно создано через фрейм на jquery. Много вопросов на форумах, как закрыть модальное окно из фрейма, обычно ответ один — никак. Но решение есть и оно аналогично плагину thickbox.

Просто навесить код на элемент находящийся внутри фрейма.

По работе стоит задача сделать кнопку закрытия окна браузера без вопроса «Действительно ли вы хотите закрыть. » Пробую сейчас для IE 8 — работает прекрасно. На IE 6 — нет. Где посмотреть какими версиями експлорера поддерживается эта функциональность и нет ли аналога для шестого?

Почему все так сложно?
Работать не возможно.
Почему нельзя все упростить?
Простые вещи через жопу делать надо. Невероятно. 21 век.

Дело в том, что все упирается в политику безопасности.

Если вы хотите сделать что-бы было просто, то будьте готовы, что у вас будут «самопроизвольно» (с помощью кода в баннере например) закрываться все вкладки.

Дело в том, что все упирается в политику безопасности.

Если вы хотите сделать что-бы было просто, то будьте готовы, что у вас будут «самопроизвольно» (с помощью кода в баннере например) закрываться все вкладки.

Всегда открывал окно примерно таким кодом:

function ShowWin(src, width, height) <
obj = window.open(«», «», «scrollbars=0,dialog=0,minimizable=1,modal=1,width=»+width+»,height=»+height+»,resizable=0″ ) ;
obj.document.write(» » ) ;
obj.document.write(» » ) ;
obj.document.write(» » ) ;
>

Потребовалось закрытие окна, при клике вне него. Нашел в и-нете такой код:

Добавил в свою функцию, последней строкой, т.е. получилось:

function ShowWin(src, width, height) <
obj = window.open(«», «», «scrollbars=0,dialog=0,minimizable=1,modal=1,width=»+width+»,height=»+height+»,resizable=0″ ) ;
obj.document.write(» » ) ;
obj.document.write(» » ) ;
obj.document.write(» » ) ;
this.onfocus=function()
>

Все работает, окно закрывается при клике «снаружи».
Не понимаю, почему ONFOCUS, а не ONBLUR?
Может, кто-нибудь пояснить? Помогите пожалуйста разобраться!

Окно закрывается при клике по родительскому окну. В вашем случае, вызов функции showWin происходит в «глобальном» контексте, и внутри функции this указывает на window. Соответственно в последней строчке вы задаете обработчик получения фокуса родительским окном, а внутри обработчика — закрываете дочернее окно (которое внутри обработчка представлено переменной obj)

это какая-то магия, но работает
вызванная без аргументов, функция закрывает текущее окно

function close_window(url) <
var newWindow = window.open(», ‘_self’, »); //open the current window
window.close(url);
>

ааааа. это же просто чит !

А может ко сможет мне помочь? Мне нужно, чтоб по нажатию «ОК» в диалоговом окне alert закрывалась браузерная вкладка

Как сделать так что бы при нажатии на ОК посетитель переходил на другую страницу, а если отмена закрывалась вкладка?

Если кто мучался с закрытием модольного окна, открытого через jquery, (Например:
highslide), то вот таблетка:

играю в браузерную игру
минимальную информацию обо мне в игре можно узнать просто нажав на мой профиль
где откроется отдельное окно
но и этого я бы не хотел
там можно загрузить свою картинку (с любого сайта), вписать домашнюю страницу, оставить свою почту
вот в этих вариантах есть возможность закрытия окна с моим профилем?
что бы просто автоматически закрывалась открывшись
например когда обращается за картинкой на какой то ресурс а оттуда сразу команда закрыть окно

javascript:close() в ссылку и не парься

Есть ли способ закрыть текущую страницу в последнем chrome.
var newWindow = window.open(», ‘_self’, »); //open the current window
window.close();
Этот способ не работает.
В консоль падает warning Scripts may close only the windows that were opened by it.

Ребят, помогите.
Есть окно, из которого я открываю другое окно
var w = window.open(‘test2.html’, ‘MyWindow’);
во втором окне я делаю что надо, и жму кнопку закрыть
window.close();
как только эта страница закрывается через эту функцию, мне надо запустить скрипт на основной странице.
Как это отследить .

У меня работает только такой способ: self.close()

Доработал «читерский».
Пропишите следующего рода скрипт на закрываемую страницу.

И вызовите функцию DoCPExit();

Все успешно закрывается и без каких-либо подтверждений для пользователя.
Причем вызов функции можно настроить по времени истечения, например 5 секунд.

Оцените статью