AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Different Hotkeys for different Applications

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Wish List
View previous topic :: View next topic  
Author Message
Tekl



Joined: 24 Sep 2004
Posts: 813
Location: Germany

PostPosted: Mon Jan 24, 2005 11:59 pm    Post subject: Different Hotkeys for different Applications Reply with quote

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
View user's profile Send private message Visit poster's website
jonny



Joined: 13 Nov 2004
Posts: 3004
Location: Minnesota

PostPosted: Tue Jan 25, 2005 12:43 am    Post subject: Reply with quote

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! Razz
Back to top
View user's profile Send private message
Tekl



Joined: 24 Sep 2004
Posts: 813
Location: Germany

PostPosted: Tue Jan 25, 2005 1:06 am    Post subject: Reply with quote

Hi Jonny,

nice idea, I'll try it.

thank you.

Tekl
Back to top
View user's profile Send private message Visit poster's website
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10467

PostPosted: Tue Jan 25, 2005 2:01 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Wish List All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group