Sign in to follow this  
Followers 0
slightly_abnormal

close selected window?

21 posts in this topic

#1 ·  Posted (edited)

I'm looking to close a particular window.. by pressing a hotkey.. e.g. pressing alt+esc which will close the currently active/selected window.. and no others unless they active too.

mixing shekanders script with autoitkings script would get it?

shekander (minimizes "any window" to tray")

http://www.autoitscript.com/forum/index.php?showtopic=20153

autoitkings ("closes" all open windows)

http://www.autoitscript.com/forum/index.php?showtopic=22915

dagamnit! cant cahnge the title it's supposed to be close active/selected window with hotkey.

Edited by slightly_abnormal

Share this post


Link to post
Share on other sites



WinClose('')

should work

~cdkid


AutoIt Console written in C#. Write au3 code right at the console :D_FileWriteToLineWrite to a specific line in a file.My UDF Libraries: MySQL UDF Library version 1.6 MySQL Database UDF's for AutoItI have stopped updating the MySQL thread above, all future updates will be on my SVN. The svn location is:kan2.sytes.net/publicsvn/mysqlnote: This will still be available, but due to my new job, and school hours, am no longer developing this udf.My business: www.hirethebrain.com Hire The Brain HireTheBrain.com Computer Consulting, Design, Assembly and RepairOh no! I've commited Scriptocide!

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

WinClose('')

should work

~cdkid

okay.. that seems easier :):mellow:

now how do i get this into a loop so it wont quit itself, and keep running until i close it. i dont know if it works.. ?

Global $Paused
HotKeySet("{f12}", "closewindow")

Func closewindow()
    WinClose('')    
    EndFunc
Edited by slightly_abnormal

Share this post


Link to post
Share on other sites

WinClose('')

should work

~cdkid

stuck it in one of my apps, and it didn't work.. :):mellow: i also tried

Global $Paused
HotKeySet("{f12}", "closewindow")
Func closewindow()
    opt ("WinTitleMatchMode",2)
    WinActive("","")
    Send("!f4")
    EndFunc

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

try something like

do 

CODE GOES HERE

until $GUI_EVENT_CLOSE

something wtih an if statement or a while statement :)

Edited by thatsgreat2345

Share this post


Link to post
Share on other sites

HotKeySet("{f12}","closewindow")
While 1
sleep(1000)
WEnd
func closewindow()
WinKill('')
endfunc

umm, dont use it if u have the desktop active, it'll kill Program Manager, which is never a good thing... other than that, it should work.

~cdkid


AutoIt Console written in C#. Write au3 code right at the console :D_FileWriteToLineWrite to a specific line in a file.My UDF Libraries: MySQL UDF Library version 1.6 MySQL Database UDF's for AutoItI have stopped updating the MySQL thread above, all future updates will be on my SVN. The svn location is:kan2.sytes.net/publicsvn/mysqlnote: This will still be available, but due to my new job, and school hours, am no longer developing this udf.My business: www.hirethebrain.com Hire The Brain HireTheBrain.com Computer Consulting, Design, Assembly and RepairOh no! I've commited Scriptocide!

Share this post


Link to post
Share on other sites

HotKeySet("{f12}","closewindow")
While 1
sleep(1000)
WEnd
func closewindow()
WinKill('')
endfunc

umm, dont use it if u have the desktop active, it'll kill Program Manager, which is never a good thing... other than that, it should work.

~cdkid

does it work for you?

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

i take that back :)

Edited by thatsgreat2345

Share this post


Link to post
Share on other sites

This isn't a really good idea IMHO!

You freaked when my UDF closed alot of your windows.... At least at the time it was in a semi controled enviroment (More so now).


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

This isn't a really good idea IMHO!

You freaked when my UDF closed alot of your windows.... At least at the time it was in a semi controled enviroment (More so now).

um.. this is a support forum. hello!!

I didn't freak. i didn't expect it to try to kill everything, since that wasn't what it was intended for :)

Edited by slightly_abnormal

Share this post


Link to post
Share on other sites

um.. this is a support forum. hello!!

I didn't freak. i didn't expect it to try to kill everything, since that wasn't what it was intended for :)

now please help another fellow "autoit" user out.

Nah... after that comment, you can help yourself, or get it from someone else... Cheers!

P.S.... IMHO = In My Humble Opinion ... meaning - If you could explain in a bit more detail of closing every singel active window (WinGetTitle('') << gets every active window ... Visible or Not) (You might/will find... that some of the 'windows' you can't see, are pertinent to every day activity of the programs you "might" not want to close). I wrote a UDF to do this already (Controled)... Not the one that shut down your windows in a former script.


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

HotKeySet("{ESC}","terminate")
HotKeySet("{f12}","close")
Func close()
    $close = WinGetTitle('')
    winclose($close)
EndFunc
Func terminate()
    Exit 
EndFunc
While 1
Sleep(100)
WEnd
Exit

Edited by thatsgreat2345

Share this post


Link to post
Share on other sites

HotKeySet("{ESC}","terminate")
HotKeySet("{f12}","close")
Func close()
    $close = WinGetTitle('')
    winclose($close)
EndFunc
Func terminate()
    Exit 
EndFunc
While 1
Sleep(100)
WEnd
Exit

by the way pussy its not his problem you ran the script, it didnt effect anything so shut the hell up and stop moaning and bitching like some PMSing whore jesus christ

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

DELETED

Edited by thatsgreat2345

Share this post


Link to post
Share on other sites

<nonsence>

Share this post


Link to post
Share on other sites

#16 ·  Posted (edited)

This isn't a really good idea IMHO!

You freaked when my UDF closed alot of your windows.... At least at the time it was in a semi controled enviroment (More so now).

I know it's not a good idea, i'm just helpin out. If he kills a window he wasnt supposed to, it's not my fault, he asked for the script.

-- :)

~cdkid

Edited by cdkid

AutoIt Console written in C#. Write au3 code right at the console :D_FileWriteToLineWrite to a specific line in a file.My UDF Libraries: MySQL UDF Library version 1.6 MySQL Database UDF's for AutoItI have stopped updating the MySQL thread above, all future updates will be on my SVN. The svn location is:kan2.sytes.net/publicsvn/mysqlnote: This will still be available, but due to my new job, and school hours, am no longer developing this udf.My business: www.hirethebrain.com Hire The Brain HireTheBrain.com Computer Consulting, Design, Assembly and RepairOh no! I've commited Scriptocide!

Share this post


Link to post
Share on other sites

I know it's not a good idea, i'm just helpin out. If he kills a window he wasnt supposed to, it's not my fault, he asked for the script.

-- :)

~cdkid

Well Atleast this time I know what the script does.. :mellow:

btw the way smoke_n your script wasn't the first script that did something that was unexpected :lmoa:

Share this post


Link to post
Share on other sites

...close the currently active/selected window.. and no others unless they active too...

Your definition of "active" might differ from AutoIt's.

Run this code:

$var = WinList()

For $i = 1 To $var[0][0]
    If BitAND( WinGetState($var[$i][1]), 8) Then MsgBox(0, "Details", "Title=" & $var[$i][0] & @LF & "Handle=" & $var[$i][1])
Next
and change the "8" in WinGetState($var[$i][1]), 8) until you see what you want, then replace the msgbox with whatever you want - perhaps WinKill

From the help file on WinGetState:

Success: Returns a value indicating the state of the window. Multiple values are added together so use BitAND() to examine the part you are interested in:

1 = Window exists

2 = Window is visible

4 = Windows is enabled

8 = Window is active

16 = Window is minimized

32 = Windows is maximized


[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

thanks for the help.. i got it going! :)

Share this post


Link to post
Share on other sites

#20 ·  Posted (edited)

stuck it in one of my apps, and it didn't work.. :):mellow: i also tried

Sorry, but WinClose('') (Note that it is not a double-quote, but rather two single-quotes) will close any currently active window save the scripts GUI window if it has one. If it doesn't then you're implementing it incorrectly.

As for your second script, try changing:

Send("!f4")

to

Send("!{F4}")

Note that this will do the same thing as WinClose('') except for it will close the script's own GUI if present. Also, it will attempt to shut down the computer when no active windows are present.

Edit: Sorry, didn't see the second page, and therefore that the topic had been fulfilled.

Edited by neogia

[u]My UDFs[/u]Coroutine Multithreading UDF LibraryStringRegExp GuideRandom EncryptorArrayToDisplayString"The Brain, expecting disaster, fails to find the obvious solution." -- neogia

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0