AutoHotkey Community

It is currently May 27th, 2012, 3:43 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: July 24th, 2010, 12:45 pm 
Offline

Joined: November 21st, 2009, 11:06 am
Posts: 63
I have recently started using emacs, and have found that most of my ahk shortcuts conflict with the emacs keys.

Is there a way for me to specify for all of my commands to be ignored while in emacs, even better if there was a way for me to specify a few to still include, but without having to put #IfWinNotActive's around every command - i tried putting them after the autoload section and at the end and that didn't work.

Thanks :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 24th, 2010, 1:28 pm 
Offline

Joined: February 19th, 2010, 8:07 pm
Posts: 614
you dont have to put #IfWinNotActive's around every command...

just do:

Code:
#IfWinNotActive, EMACS TITLE HERE
; a::action
; b::action
; c::
;  long
;  action
;return
;d::another action
#IfWinNotActive

;These two will always execute even if EMACS is on
; e::action
; f::action


That way you effectively make ALL the hotkeys surrounded by that directive only available when emacs is not active... to keep the others active even when EMACS is on, then just put them outside that directive.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 24th, 2010, 2:03 pm 
Offline

Joined: November 21st, 2009, 11:06 am
Posts: 63
I had tried that originally - so I had another look and realised the problem - it seems to be because I am nesting the IfWinActive statements. Is there any way around that?


Ideally a better solution, but if worst comes to worst how could I combine calls, like my existing:
Code:
#IfWinActive ahk_group Blahblah
^!a:: ;action
do something
return
#IfWinActive


eg
Code:
#IfWinActive ahk_group Blahblah and #IfWinNotActive Emacs
^!a:: ;action
do something
return
#IfWinActive


Because I don't want any of the commands running w/ emacs.

Worst case, i would create separate #ifwinnotactives, but that would mean that for sections where there is already a #statement, it would still execute in emacs.

So any ideas? Thanks again for the help :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 24th, 2010, 2:15 pm 
Offline

Joined: February 19th, 2010, 8:07 pm
Posts: 614
if I understand correctly you already have those hotkeys binded to an #IfWinActive statement right?
So do they only run on a specific program?

if they do, then you dont need to exclude them from EMACS because they only run on the other program

I think you are confusing something here. Can you post your code so I can see exactly what you have? because my solution should work as I posted it.

Read and try to understand the following code:

Code:
; this will never get executed on EMACS... or anywhere else
; because it ONLY works on notepad.
#IfWinActive, NotePad
a::
; do something
return
#IfWinActive

; this will execute everywhere *except* EMACS...
#IfWinNotActive, EMACS
b::
; do something
return
#IfWinNotActive

; you can set up a bunch of hotkeys to work only outside EMACS
; and other set of them to work even if EMACS is on, in the following way

; these wont work on EMACS but will work in any other window/app
#IfWinNotActive, EMACS
a::
; action
return
b::
; action
return
c::
; action
return
d::
;another action
return
#IfWinNotActive

;These two will always execute even if EMACS is on
e::
; action
return
f::
; action
return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 24th, 2010, 2:36 pm 
Offline

Joined: November 21st, 2009, 11:06 am
Posts: 63
Woops - yes that is correct, they will only run in that specific program.

However, the main issue that I was describing is just that the statements can't be nested - so i cant have
Code:
#IfWinNotActive Emacs

hotkey

#ifwinactive explorer
hotkey
#ifwinactive

#ifwinnotactive


So i suppose there is no issue, as i can just separate the ifwinactive statements, however I was just wondering if it was possible to automatically exclude the whole thing without adding those unnecessary bits into my code.


So in essence - thank you very much for your help - it works fine now, and if there is a way to get it all with only 2 lines of code that would be an awesome bonus :)[/code]


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 24th, 2010, 4:28 pm 
Offline

Joined: February 19th, 2010, 8:07 pm
Posts: 614
unknowingly wrote:
however I was just wondering if it was possible to automatically exclude the whole thing without adding those unnecessary bits into my code.



unknowingly wrote:
it works fine now, and if there is a way to get it all with only 2 lines of code that would be an awesome bonus :)


I am still not sure what exactly you want to achieve, but yes you are right, you cannot nest #IfWin directives.

If you want to solve your problem in 1 line you can try making the first line of your script "#IfWinNotActive, EMACS TITLE".

The other #IfWin directive is optional. In other words, if you want to make all your hotkeys obey only one rule, then only use 1 #IfWin directive, if you want them to be separated (some work in a specific window, other are triggered no matter where) then you can use several #IfWinActive, TITLE followed by the closing #IfWinActive's to separate the hotkeys for different rules.

Not sure if I am over-complicating my explanation but im kind of not understanding your goal either. xD


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 25th, 2010, 12:50 am 
Offline

Joined: November 21st, 2009, 11:06 am
Posts: 63
:P thats cool, thanks for the help :)
Appreciate it :)


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: bobbysoon, Google Feedfetcher, Wicked and 18 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