AutoHotkey Community

It is currently May 27th, 2012, 12:13 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: October 13th, 2009, 11:55 am 
Offline

Joined: May 12th, 2009, 3:36 pm
Posts: 27
Hello,
I have following script:

Code:
SetTitleMatchMode,2

msgbox, I am message 1

#IfWinActive, Opera
{
   ^1::
   {
      msgbox, I am Opera
      return
   }
}

msgbox, I am message 2

#IfWinActive, Total
{
   ^1::
   {
      msgbox, I am Total
      return
   }
}

msgbox, I am message 3

^y::
{
   msgbox, I am hotkey ^y
   return
}


Questions:
1) Why does not appear message 2 and 3 after opening/starting the script?
2) The hotkey "^y" is only accessible within the programme with the title "Total" -- however it was defined after "#IfWinActive, Total". What is the reason?
3) So, how it is possible to define hotkeys independent of the active window?

Thanks!
Carlos


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 13th, 2009, 12:09 pm 
Offline

Joined: November 14th, 2007, 2:47 pm
Posts: 335
Location: London, England
Answer:

2) The HOtkey is defined after the #IfWinActive directive. If it is independant of the "Total" window it needs to be put before #IfWinActive.

3) See above.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 13th, 2009, 1:02 pm 
Offline

Joined: May 12th, 2009, 3:36 pm
Posts: 27
doyle wrote:
2) The HOtkey is defined after the #IfWinActive directive. If it is independant of the "Total" window it needs to be put before #IfWinActive.

So the brackets are useless and don't limit the things within the brackets to the shortcut?

It's a strange behaviour, isn't it?

Ok, I change the order.



thanks for your explanation
Carlos


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 13th, 2009, 1:57 pm 
Offline

Joined: November 14th, 2007, 2:47 pm
Posts: 335
Location: London, England
If you could explain what you are using this script for in context, then I might be able to suggest a better method of coding for it.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 13th, 2009, 2:38 pm 
Offline

Joined: October 2nd, 2009, 12:43 pm
Posts: 283
#IfWinActive works not how you think it works.
Here's what you need.
Code:
SetTitleMatchMode,2

msgbox, I am message 1
msgbox, I am message 2
msgbox, I am message 3

#IfWinActive, Opera
^1::msgbox, I am Opera

#IfWinActive, Total
^1::msgbox, I am Total

#IfWinActive
^y::msgbox, I am hotkey ^y

RTFM


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 13th, 2009, 3:00 pm 
Offline

Joined: May 12th, 2009, 3:36 pm
Posts: 27
flak wrote:
RTFM


changing the order -- I know now...


Thanks


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 13th, 2009, 3:10 pm 
Offline

Joined: May 12th, 2009, 3:36 pm
Posts: 27
doyle wrote:
If you could explain what you are using this script for in context, then I might be able to suggest a better method of coding for it.


the code was just for understanding these elements and the behaviour of AHK-scripts vs. e.g. Javascripts

Carlos


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: Bing [Bot], BrandonHotkey, Leef_me, Pulover, rjgatito, XstatyK, Yahoo [Bot] 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