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 

Interaction if two scripts binding the same hotkey

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
keyboardfreak



Joined: 09 Oct 2004
Posts: 216
Location: Budapest, Hungary

PostPosted: Sat Jun 20, 2009 2:29 pm    Post subject: Interaction if two scripts binding the same hotkey Reply with quote

I have a script which does something if insert is pressed and necessary condition is satisfied, otherwise it simply sends an insert keypress:

Code:
$insert::
  if (condition)
    dostuff
  else
    send {insert}
  return


I also have an other script which does something else with the insert key in a similar fashion:

Code:
$insert::
  if (someothercondition)
    dosomeotherstuff
  else
    send {insert}
  return


According to my tests the script which was started later overrides the hotkey binding of the previous one. Is is possible to send the insert key if the script started first doesn't want to do anything special with it, so that it triggers the hotkey in the other script?

The two scripts are fairly complex and do different things, so merging them is not an option.
Back to top
View user's profile Send private message
Z_Gecko
Guest





PostPosted: Sat Jun 20, 2009 2:42 pm    Post subject: Reply with quote

i might be wrong, but IMHO
if you can produce your desired behavior,
you will end up in an endless loop
as soon as both conditions are false and Insert is pressed.

So it would be better to change the logic of your scripts.
Would it harm if both scripts would send Insert on any conditions?
like
Code:

~Insert::
  if (condition)
    dostuff
  return
Back to top
keyboardfreak



Joined: 09 Oct 2004
Posts: 216
Location: Budapest, Hungary

PostPosted: Sat Jun 20, 2009 2:50 pm    Post subject: Reply with quote

Z_Gecko wrote:
Would it harm if both scripts would send Insert on any conditions?


Yep, e.g. it would toggle annoyingly insert/overwrite if the current window is an editor. Smile
Back to top
View user's profile Send private message
Z_Gecko
Guest





PostPosted: Sat Jun 20, 2009 3:00 pm    Post subject: Reply with quote

sorry, then you must probably rethink your logic.
Back to top
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help 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