| View previous topic :: View next topic |
| Author |
Message |
Da Rossa
Joined: 06 Dec 2007 Posts: 361
|
Posted: Mon Feb 08, 2010 7:23 am Post subject: Suspend the script when some applications are active |
|
|
Hi, I'd like to have my script suspended when the active window is one of the programs I have on a list.
So far, I managed to suspend the script only in one application, which is FileZilla, adding the following to the beginning of the code.
| Code: | Loop,
{
WinWaitActive, ahk_class wxWindowClassNR
{
Suspend, on
Sleep, 5
WinWaitNotActive, ahk_class wxWindowClassNR
{
Suspend, off
}
}
}
return |
This is because my hostrings mess with the directories navigation. Other applications that require the hotstrings to be suspended are the command prompts, so as the file managers like Windows Explorer and its alternatives.
The downside is that this block cannot be repeated. If I copy-paste this block replacing the ahk_class for the other program, only the first will cause the script to suspend.
How to circumvent this?
Thanks! _________________ AHK is perfect. |
|
| Back to top |
|
 |
None
Joined: 28 Nov 2009 Posts: 3086
|
Posted: Mon Feb 08, 2010 7:37 am Post subject: |
|
|
I would use a SetTimer
| Code: | SetTimer CheckWindow, 100
CheckWindow:
IfWinActive ahk_class wxWindowClassNR
{
Suspend , On
Return
}
IfWinActive ahk_class ConsoleWindowClass ;Comand prompt in XP
{
Suspend , On
Return
}
Suspend , Off
Return
a::MsgBox This is a Hotkey to Test | You can put as many in this as you want  |
|
| Back to top |
|
 |
Da Rossa
Joined: 06 Dec 2007 Posts: 361
|
Posted: Mon Feb 08, 2010 11:34 pm Post subject: |
|
|
Oh my God man, that seem to work, thanks! Never heard of the SetTimer command also... But won't this routine executed every 100 miliseconds hog a little my resources (my pc is kinda old), enough to have the hotstrings to feel that undesired delay? Or am I paranoid?
Thanks anyway! _________________ AHK is perfect. |
|
| Back to top |
|
 |
None
Joined: 28 Nov 2009 Posts: 3086
|
Posted: Mon Feb 08, 2010 11:42 pm Post subject: |
|
|
If it causes a noticible lag make the timer longer.
Edit: I just checked with Task Manager on My 1 Gig machine it uses less than 1 persent as is. But even if you make it 1000 chances are you are still moving the mouse around or getting your hands in position when the next pass comes around. |
|
| Back to top |
|
 |
Leef_me
Joined: 08 Apr 2009 Posts: 5336 Location: San Diego, California
|
|
| Back to top |
|
 |
Da Rossa
Joined: 06 Dec 2007 Posts: 361
|
Posted: Tue Feb 09, 2010 12:11 am Post subject: |
|
|
Hmm, just like I suspected...
My code endep up like this:
| Code: | SetTimer CheckWindow, 100
CheckWindow:
IfWinActive ahk_class wxWindowClassNR
{
Suspend , On
Return
}
IfWinActive ahk_class ConsoleWindowClass ;Comand prompt in XP
{
Suspend , On
Return
}
Suspend , Off
IfWinActive ahk_class ATL:ExplorerFrame
{
Suspend , On
Return
}
Suspend , Off
Return |
And, when ahk_class ATL:ExplorerFrame is active, the icon keeps blinking at the system tray. The same for ahk_class ExploreWClass. So this is lag.
Curiously, when ahk_class wxWindowClassNR is active, it doesn't blink. Why?
Edit: @Leef: looking at your idea now. I was writing my post when you posted yours. _________________ AHK is perfect. |
|
| Back to top |
|
 |
Da Rossa
Joined: 06 Dec 2007 Posts: 361
|
Posted: Tue Feb 09, 2010 12:43 am Post subject: |
|
|
Ok, here we go.
I implemented the following, which appers to be working very fine:
| Code: | GroupAdd, ExcluirDasHotstrings, ahk_class ATL:ExplorerFrame
GroupAdd, ExcluirDasHotstrings, ahk_class ExploreWClass
GroupAdd, ExcluirDasHotstrings, ahk_class ConsoleWindowClass
GroupAdd, ExcluirDasHotstrings, ahk_class wxWindowClassNR
[...]
#IfWinNotActive, ahk_group ExcluirDasHotstrings,
|
"Excluir das hotstrings" means exclude from hotstrings scope.
This is indeed the easier way.
Thanks!! _________________ AHK is perfect. |
|
| Back to top |
|
 |
Leef_me
Joined: 08 Apr 2009 Posts: 5336 Location: San Diego, California
|
Posted: Tue Feb 09, 2010 1:24 am Post subject: |
|
|
| Quote: | | This is indeed the easier way. | I only recently found out about the GroupAdd command. Glad it worked for you.
Best Wishes. |
|
| Back to top |
|
 |
Da Rossa
Joined: 06 Dec 2007 Posts: 361
|
Posted: Tue Feb 09, 2010 1:25 am Post subject: |
|
|
Thanks!
And thanks to None too! _________________ AHK is perfect. |
|
| Back to top |
|
 |
|