AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

GroupAdd and WinClose - I can't make it work

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
j0989
Guest





PostPosted: Tue Jan 08, 2008 3:44 am    Post subject: GroupAdd and WinClose - I can't make it work Reply with quote

This is my first script.

I am trying to learn how to use GroupAdd.

I want to close all the windows whose titles include keywords passed into the script from the command line.

Code:

SetTitleMatchMode, 2
loop %0%
{
     GroupAdd, ToBeClosed, %a_index%
}
WinClose, ahk_group ToBeClosed


"autohotkey.exe thiscript.ahk Calculator Calendar Word"

But this doesn't seem to work. I'll appreciate your hints and suggestions.

Andrzej
Back to top
freakkk



Joined: 29 Jul 2005
Posts: 128

PostPosted: Tue Jan 08, 2008 4:27 am    Post subject: Reply with quote

Your usage of GroupAdd is fine.. but the A_Index in your loop is literally converting to be the number of the current loop iteration. If you use it as an expression it would work. Smile
Code:
SetTitleMatchMode, 2
Loop, %0%
  GroupAdd, ToBeClosed, % %A_Index%    ; <-- the contents of the var N
WinClose, ahk_group ToBeClosed

_________________
.o0[ corey ]0o.
Back to top
View user's profile Send private message
j0989
Guest





PostPosted: Wed Jan 09, 2008 1:24 am    Post subject: Reply with quote

Many thanks freakkk for your help. It does work, indeed.

However, I must be missing something аbout loops because when I try to use the same pattern for stopping Windows services:

Code:
Loop, %0%
    Run, %comspec% /c net stop % %a_index%
return


I get the following error when executing "autohotkey.exe thisScript.ahk Mysql Apache2" from the command line:
Quote:
the following variable name contains an illegal character: "". The program will exit.




Could you give me a hint, please?
Back to top
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group