AutoHotkey Community

It is currently May 27th, 2012, 2:24 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 9 posts ] 
Author Message
PostPosted: February 8th, 2010, 8:23 am 
Offline

Joined: December 6th, 2007, 12:48 pm
Posts: 364
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 8th, 2010, 8:37 am 
Offline

Joined: November 28th, 2009, 4:45 am
Posts: 3089
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 8)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 9th, 2010, 12:34 am 
Offline

Joined: December 6th, 2007, 12:48 pm
Posts: 364
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 9th, 2010, 12:42 am 
Offline

Joined: November 28th, 2009, 4:45 am
Posts: 3089
If it causes a noticible lag make the timer longer. :D
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 9th, 2010, 1:01 am 
Offline

Joined: April 8th, 2009, 7:49 pm
Posts: 6071
Location: San Diego, California
@Da Rossa
You might have a look at this command
it allows you to specify windows by a criteria and add that criteria to a group, then the group can be used in place of a single window reference.

http://www.autohotkey.com/docs/commands/GroupAdd.htm

OTOH, it sure seems like you are "doing it the hard way"

Why not have "Context-sensitive Hotkeys" ?
http://www.autohotkey.com/docs/Hotkeys.htm#Context


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 9th, 2010, 1:11 am 
Offline

Joined: December 6th, 2007, 12:48 pm
Posts: 364
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 9th, 2010, 1:43 am 
Offline

Joined: December 6th, 2007, 12:48 pm
Posts: 364
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 9th, 2010, 2:24 am 
Offline

Joined: April 8th, 2009, 7:49 pm
Posts: 6071
Location: San Diego, California
Quote:
This is indeed the easier way.
I only recently found out about the GroupAdd command. Glad it worked for you.

Best Wishes.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 9th, 2010, 2:25 am 
Offline

Joined: December 6th, 2007, 12:48 pm
Posts: 364
Thanks!
And thanks to None too!

_________________
AHK is perfect.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Alpha Bravo, Google [Bot], LazyMan, rbrtryn and 24 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group