Jump to content

Two Scripts With The Same Hotkeys, A Solution?


Recommended Posts

I have 2 scripts with that share some of the same HotKeys. Let's call them A and B Script. A is primary and runs all the time. B is secondary and used only a few times a day. Let's assume that we do not want to change the HotKeys in either A or B. And, that we don't want to close one script when we have to run the other script.

Is there a way to Toggle the hotkeys or scripts so that the HotKeys can be used? Ideally, I would like to assign a HotKey on Script A, to open/close Script B, and when Script B is running, disable the shared HotKeys.

Thanks in Advance.

Link to comment
Share on other sites

I have 2 scripts with that share some of the same HotKeys. Let's call them A and B Script. A is primary and runs all the time. B is secondary and used only a few times a day.

I asked this very question a couple months ago.

My situation may be different. I have A run all the time like yours. Its a universal hotkey that does different things depending on what is on the screen at the time so there is a master case statement.

The soln that was suggested is to make A call a different key combo if my key does not match anything that script A cares about.

Then Script B just looks for the alternate key combo instead. This works good for me as A is always running anyway and will pass the alternate when I press the original key if its not a script A thing.

I'm sure there is a better way to handle this for more scripts at once. I have C and D doing the same as B but for now I've only had them running one at a time so there have been no conflicts.

Link to comment
Share on other sites

I know this isn't 100% the solution you are looking for but within a script you could call various functions, or a single function that changes it's actions based upon active window, existing window, pixel color, or any other variance.

EX:

Global $Window1 = "AutoIt Help"
Global $Window2 = "Database Error"
Global $Window3 = "InSource CS Login"
HotKeySet("{PAUSE}", "_PausePress")
While 1
    Sleep(100)
WEnd
Func _PausePress()
 If WinActive($Window1) then Send("{!}")
 If WinActive($Window2) then Send("1")
 If WinActive($WIndow3) then 
  ControlClick($Window3, "", "Edit1")
  Controlsend($Window3,"", "Edit1", "My Message String")
 EndIf
EndFunc

Yeah this really won't do anything functional, but it illustrates the point.

"I have discovered that all human evil comes from this, man's being unable to sit still in a room. " - Blaise Pascal
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...