 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Tekl
Joined: 24 Sep 2004 Posts: 813 Location: Germany
|
Posted: Mon Jan 24, 2005 11:59 pm Post subject: Different Hotkeys for different Applications |
|
|
Hi,
the common way to make conditional Hotkey is this:
| Code: |
Hotkey::
ifWinActive, Program 1
{
do something
}
ifWinActive, Program 2
{
do something
}
return
|
is it possible to implement something like this?
| Code: |
ifWinActive, Programm 1
{
HotkeyA::Send, bla
HotkeyB::Send, blub
}
ifWinActive, Programm 2
{
HotkeyA::Send, blibb
HotkeyB::Send, blaebb
}
|
That could be used for example to disable a lot of keys for only one application.
| Code: |
ifWinActive, Opera
{
*RWin::
*LWin::
*^ESC::
*!F4::
*!Tab::
return
}
|
maybe a different, more logical syntax could be used. (context-blocks)
Tekl |
|
| Back to top |
|
 |
jonny
Joined: 13 Nov 2004 Posts: 3004 Location: Minnesota
|
Posted: Tue Jan 25, 2005 12:43 am Post subject: |
|
|
Something like this is already possible, avoiding the use of putting context-sensitive code within every single hotkey. I remember doing this before, unfortunately I don't have the exact original code. I'll try to reproduce it from memory, but this is untested:
| Code: | **auto-execute section**
; This loop if infinite, running until
; the script exits.
loop
{
WinWaitActive, Opera
Hotkey,RWin,on
Hotkey,LWin,on
Hotkey,^ESC,on
Hotkey,!F4,on
Hotkey,!Tab,on
WinWaitNotActive, Opera
Hotkey,RWin,off
Hotkey,LWin,off
Hotkey,^ESC,off
Hotkey,!F4,off
Hotkey,!Tab,off
}
*RWin::
*LWin::
*^ESC::
*!F4::
*!Tab::
return
**rest of script** |
I hope it works!  |
|
| Back to top |
|
 |
Tekl
Joined: 24 Sep 2004 Posts: 813 Location: Germany
|
Posted: Tue Jan 25, 2005 1:06 am Post subject: |
|
|
Hi Jonny,
nice idea, I'll try it.
thank you.
Tekl |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10467
|
Posted: Tue Jan 25, 2005 2:01 am Post subject: |
|
|
Tekl, it's a good idea but the way the program is structured now it would be hard to do. This is because labels (such as hotkeys) are recognized at an earlier stage in the loading process, before the script starts executing. And labels must be unique to prevent ambiguity when using Gosub.
Here is another topic that provides a way similar to jonny's to have context-sensitive hotkeys without having to put IF-statements in every hotkey: http://www.autohotkey.com/forum/viewtopic.php?t=591 |
|
| 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
|