 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
New User Guest
|
Posted: Tue Dec 12, 2006 1:18 am Post subject: Newby question - toggle, closing applications |
|
|
Hi Everyone,
I'm pretty new to AHK programme.
Any help with regards to my problems below would be most appreciated.
(1) I'm trying to create a simple toggle feature. So when I press "#n" notepad will open, if I press "#n" again it'll check to see if notepad is already opened. If so, then it'll close Notepad. Basically I'm trying to create a toggle feature for opening and closing notepad using the "#n".
;;This is what I've got so far.
;;Opens notepad but doesn't close it.
#n::
If WinExist("","Notepad")
WinClose, A
Else
Run Notepad
(2) Second question is kind of similar to the first. What is the syntax to close the currently active window (application). I mean is there a generic syntax that will close any application that is currently selected?
(3) To extend it even more. Is it possible to close all applications which are running the same process. For example, if I had eight IE browsers opened. Could I press a hotkey to close the current application and all other windows with the same application running on it? I'm pretty sure I'd need some kind of loop, and a property to check the class. But again I'm not too sure about the synatx.
Any help would be great.
Thanks in advance. |
|
| Back to top |
|
 |
.AHK
Joined: 26 Apr 2006 Posts: 662 Location: USA
|
Posted: Tue Dec 12, 2006 1:48 am Post subject: |
|
|
| Code: |
#n::
Process Exist, notepad.exe
If ErrorLevel <> 0
Process Close, notepad.exe
Else
Run notepad.exe
Return |
Should work. |
|
| Back to top |
|
 |
New User Guest
|
Posted: Tue Dec 12, 2006 2:13 am Post subject: |
|
|
Hi .AHK
The code works for (1). Thank you for the help. |
|
| Back to top |
|
 |
jps
Joined: 02 Sep 2006 Posts: 253 Location: Scotland
|
Posted: Tue Dec 12, 2006 4:30 am Post subject: |
|
|
(2)
(3) | Code: |
^!F4::
WinGetClass, ClassVar, A
GroupAdd, GroupVar , ahk_class %ClassVar%
GroupClose, GroupVar, A
return
|
|
|
| Back to top |
|
 |
New User Guest
|
Posted: Tue Dec 12, 2006 9:39 pm Post subject: |
|
|
Hi jps
Thank you for answering (2) and (3). They work great  |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|