topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Thursday March 28, 2024, 3:34 am
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: Make script work only on specific apps?  (Read 4777 times)

substep

  • Participant
  • Joined in 2010
  • *
  • default avatar
  • Posts: 6
    • View Profile
    • Donate to Member
Make script work only on specific apps?
« on: August 12, 2010, 08:22 PM »
Right now this script excludes apps. I want to invert it so it will work only on selected apps (*.exe preferrably).
Code: Autohotkey [Select]
  1. ~MButton::
  2. ifwinactive ahk_class MozillaUIWindowClass
  3. return
  4. ifwinactive ahk_class Progman
  5.     return
  6. ifwinactive ahk_class Shell_TrayWnd
  7.     return
  8. ifwinactive ahk_class MozillaDialogClass
  9.     return
  10. ifwinactive ahk_class NotifyIconOverflowWindow
  11.     return
  12.  
  13. Send !{F4}
  14. Return

skwire

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 5,286
    • View Profile
    • Donate to Member
Re: Make script work only on specific apps?
« Reply #1 on: August 12, 2010, 08:30 PM »
Take a look at the #IfWinActive directive in AHK:

http://www.autohotke...nds/_IfWinActive.htm

Target

  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 1,832
    • View Profile
    • Donate to Member
Re: Make script work only on specific apps?
« Reply #2 on: August 12, 2010, 10:01 PM »
simply substitute the returns in your ifwinactive statements for the send routine (and of course you'll need to amend the AHK classes as appropriate)


substep

  • Participant
  • Joined in 2010
  • *
  • default avatar
  • Posts: 6
    • View Profile
    • Donate to Member
Re: Make script work only on specific apps?
« Reply #3 on: August 13, 2010, 10:27 AM »
Thx, now it's finished.
Code: Autohotkey [Select]
  1.  
  2. #ifwinactive ahk_class TForm1
  3. ~MButton::
  4. Send !{F4}
  5. Return
  6.  
  7. #ifwinactive ahk_class TfrmStarter
  8. ~MButton::
  9. Send !{F4}
  10. Return
  11.  
  12. #ifwinactive ahk_class AkelPad4
  13. ~MButton::
  14. Send !{F4}
  15. Return
  16.  
  17. #ifwinactive ahk_class mp3DCWndClass
  18. ~MButton::
  19. Send !{F4}
  20. Return
  21.  
  22. #ifwinactive, Postbox
  23. ~MButton::
  24. Send !{F4}
  25. Return
  26.  
  27. #ifwinactive ahk_class XmainClass
  28. ~MButton::
  29. Send !{F4}
  30. Return

skwire

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 5,286
    • View Profile
    • Donate to Member
Re: Make script work only on specific apps?
« Reply #4 on: August 13, 2010, 10:37 AM »
You can shorten it up a bit by using groups.

Code: Autohotkey [Select]
  1.  
  2. GroupAdd, Alt_F4_Group, ahk_class TForm
  3. GroupAdd, Alt_F4_Group, ahk_class TfrmStarter
  4. GroupAdd, Alt_F4_Group, ahk_class AkelPad4
  5. GroupAdd, Alt_F4_Group, ahk_class mp3DCWndClass
  6. GroupAdd, Alt_F4_Group, ahk_class Postbox
  7. GroupAdd, Alt_F4_Group, ahk_class XmainClass
  8.  
  9. #ifwinactive ahk_group Alt_F4_Group
  10. ~MButton::
  11. Send !{F4}
  12. Return