 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Deep-Silence
Joined: 24 Apr 2009 Posts: 87
|
Posted: Fri Feb 12, 2010 8:57 pm Post subject: Want a hotkey only Active on certain Window |
|
|
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
|
|
|
| Back to top |
|
 |
HotKeyIt
Joined: 18 Jun 2008 Posts: 4652 Location: AHK Forum
|
|
| Back to top |
|
 |
None
Joined: 28 Nov 2009 Posts: 3086
|
Posted: Fri Feb 12, 2010 9:02 pm Post subject: |
|
|
| Or #IfWinActive |
|
| Back to top |
|
 |
Deep-Silence
Joined: 24 Apr 2009 Posts: 87
|
Posted: Fri Feb 12, 2010 9:51 pm Post subject: |
|
|
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
|
|
|
| Back to top |
|
 |
HotKeyIt
Joined: 18 Jun 2008 Posts: 4652 Location: AHK Forum
|
Posted: Fri Feb 12, 2010 10:46 pm Post subject: |
|
|
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  |
|
| Back to top |
|
 |
Deep-Silence
Joined: 24 Apr 2009 Posts: 87
|
Posted: Fri Feb 12, 2010 11:08 pm Post subject: |
|
|
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  |
|
|
| Back to top |
|
 |
HotKeyIt
Joined: 18 Jun 2008 Posts: 4652 Location: AHK Forum
|
|
| Back to top |
|
 |
Deep-Silence
Joined: 24 Apr 2009 Posts: 87
|
Posted: Fri Feb 12, 2010 11:34 pm Post subject: |
|
|
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
}
|
|
|
| Back to top |
|
 |
HotKeyIt
Joined: 18 Jun 2008 Posts: 4652 Location: AHK Forum
|
Posted: Sat Feb 13, 2010 10:09 am Post subject: |
|
|
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  |
|
| 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
|