AutoHotkey Community

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

All times are UTC [ DST ]




Post new topic Reply to topic  [ 9 posts ] 
Author Message
PostPosted: February 12th, 2010, 9:57 pm 
Offline

Joined: April 24th, 2009, 7:06 pm
Posts: 87
Hi Guys,
I did some search on the Forum, but the results did not worked for me.
So i need to ask you for advice:

The problem that i have is, that the Traytip is only shown
when TargetWin is active, but the defined hotkeys still
work outside the active Window.

I do not get that fixed.
Any Ideas?

Thank You!


Code:

TargetWin = WinTitle

SetTimer, Label_Active_Window_Hotkey, 1000

Label_Active_Window_Hotkey:
WinGetTitle, Active_Title, A

IfEqual, Active_Title, %TargetWin%
   {
   TrayTip,CurrentTitle, %TargetWin% , ,
   
   ;Reload GUI
   Hotkey,^R, Re_Load

   ;Compress Text
   Hotkey,^ENTER, TextCompress

   ;GoForIt
   Hotkey, ^+ENTER, GoForIt
   }
Else
   {
   TrayTip
   Msgbox, Test
   }


Re_Load:
Return

TextCompress:
Return

GoForIt:
Return




Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 12th, 2010, 10:01 pm 
Offline

Joined: June 18th, 2008, 8:36 am
Posts: 4923
Location: AHK Forum
Have you tried using
Code:
Hotkey, IfWinActive/Exist [, WinTitle, WinText]

You can also turn off the Hotkey
Code:
Hotkey,^R, Re_Load,Off

_________________
AHK_H (2alpha) AHF TT _Struct WatchDir Yaml _Input ObjTree RapidHotkey DynaRun :wink:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 12th, 2010, 10:02 pm 
Offline

Joined: November 28th, 2009, 4:45 am
Posts: 3089
Or #IfWinActive


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 12th, 2010, 10:51 pm 
Offline

Joined: April 24th, 2009, 7:06 pm
Posts: 87
Thanks, but this code does not work, for some strange reason.

HotKeyIt wrote:
Have you tried using
Code:
Hotkey, IfWinActive/Exist [, WinTitle, WinText]

You can also turn off the Hotkey
Code:
Hotkey,^R, Re_Load,Off



I have put together that code, which does not work, too.

Code:

TargetWin = Test
Gui, Show, h309 w500, %TargetWin%

SetTimer, Hotkey_Label, 1000

Hotkey_Label:
IfWinActive, %TargetWin%,
   {
   Hotkey,^R, Re_Load
   Hotkey,^ENTER, TextCompress
   Hotkey, ^+ENTER, Goforit
   TrayTip,CurrentTitle, %TargetWin% , ,
   }
Else
   {
   Hotkey,^R, Re_Load,Off
   Hotkey,^ENTER, TextCompress,Off
   Hotkey, ^+ENTER, Goforit,Off
   TrayTip
   }
   
Return
   
Re_Load:
Msgbox, Reload_it
Return

TextCompress:
Msgbox, Text_Compress
Return

Goforit:
Msgbox, Goforit
Return



Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 12th, 2010, 11:46 pm 
Offline

Joined: June 18th, 2008, 8:36 am
Posts: 4923
Location: AHK Forum
Try that:
Code:
TargetWin = Test
Gui, Show, h309 w500, %TargetWin%

SetTimer, Hotkey_Label, 1000

Hotkey_Label:
   IfWinActive, %TargetWin%,
      TrayTip,CurrentTitle, %TargetWin% , ,
   Else
      TrayTip
   Hotkey,IfWinActive,%TargetWin%
   Hotkey,^R, Re_Load
   Hotkey,^ENTER, TextCompress
   Hotkey, ^+ENTER, Goforit
   Hotkey,IfWinActive
Return
   
Re_Load:
Msgbox, Reload_it
Return

TextCompress:
Msgbox, Text_Compress
Return

Goforit:
Msgbox, Goforit
Return


Does title have to be dynamic :?:

_________________
AHK_H (2alpha) AHF TT _Struct WatchDir Yaml _Input ObjTree RapidHotkey DynaRun :wink:


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

Joined: April 24th, 2009, 7:06 pm
Posts: 87
Thanks, Your Code works.
Really Great!

Now i need to step through it.
And Yes, the title is gonna be dynamic.
This Hotkey Section is only a part of a larger Script.
From time to time i renew the Title definition to keep it
up2date.

Is there no need to put the code following the "Else" into brackets?
e.g.

Code:
{
TrayTip
Hotkey,IfWinActive,%TargetWin%
Hotkey,^R, Re_Load
Hotkey,^ENTER, TextCompress
Hotkey, ^+ENTER, Goforit
Hotkey,IfWinActive
}


Thank you again
HotKeyIt


HotKeyIt wrote:
Try that:
Code:
TargetWin = Test
Gui, Show, h309 w500, %TargetWin%

SetTimer, Hotkey_Label, 1000

Hotkey_Label:
   IfWinActive, %TargetWin%,
      TrayTip,CurrentTitle, %TargetWin% , ,
   Else
      TrayTip
   Hotkey,IfWinActive,%TargetWin%
   Hotkey,^R, Re_Load
   Hotkey,^ENTER, TextCompress
   Hotkey, ^+ENTER, Goforit
   Hotkey,IfWinActive
Return
   
Re_Load:
Msgbox, Reload_it
Return

TextCompress:
Msgbox, Text_Compress
Return

Goforit:
Msgbox, Goforit
Return


Does title have to be dynamic :?:


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

Joined: June 18th, 2008, 8:36 am
Posts: 4923
Location: AHK Forum
Deep-Silence wrote:
Is there no need to put the code following the "Else" into brackets?


This is the if part for Hotkeys :!:
Code:
Hotkey,IfWinActive,%TargetWin%
Hotkey,IfWinActive

_________________
AHK_H (2alpha) AHF TT _Struct WatchDir Yaml _Input ObjTree RapidHotkey DynaRun :wink:


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

Joined: April 24th, 2009, 7:06 pm
Posts: 87
As i part of my larger script if have cut your code
down to my needs:

I try to follow it logically, without success.
if you wouldn't mind, could you please explain
your code with the help of comments?

Thank You...

Code:
SetTimer, Hotkey_Label, 1000

Hotkey_Label:
IfWinActive, %TargetWin%,
   {
   ;TrayTip,CurrentTitle, %TargetWin% , ,
   }
Else
   {
   ;TrayTip
   Hotkey,IfWinActive,%TargetWin%
   Hotkey,^R, Re_Load
   Hotkey,^ENTER, TextCompress
   Hotkey, ^+ENTER, Goforit
   Hotkey,IfWinActive
   }



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

Joined: June 18th, 2008, 8:36 am
Posts: 4923
Location: AHK Forum
Read about Hotkey,IfWinActive in help. Each time you run it, your hotkeys will change.
Code:
SetTimer, Hotkey_Label, 1000

Hotkey_Label:
   Hotkey,IfWinActive,%TargetWin% ;Hotkeys below that line will be only active for given window
   Hotkey,^R, Re_Load
   Hotkey,^ENTER, TextCompress
   Hotkey, ^+ENTER, Goforit
   Hotkey,IfWinActive ;reset Hotkey command back to normal
Return

_________________
AHK_H (2alpha) AHF TT _Struct WatchDir Yaml _Input ObjTree RapidHotkey DynaRun :wink:


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, LazyMan, rbrtryn and 21 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