Jump to content

Conflicting Hotkeys with multiple scripts


Recommended Posts

Hello, i am trying to make a "master script" that basically runs a bunch of other scripts so i dont have to search every time i want a new one.

The problem i am having however is that my scripts are basically confused. I pretty much use the hotkey "home" for all my scripts and therefore when i tell this script to open another and then i press home...instead of starting the function in the new script...it activates the function for home in the master script..

im just wondering if there is some way to like 'disable' the master script until the script opened is closed? or something like that

here is the master script:

Global $folder = True
HotKeySet("!w","dfwatch")
HotKeySet("!i","idler")
HotKeySet("{HOME}","help")
HotKeySet("{END}","stop")

MsgBox(0,"WATCH OUT!!!","This Master Script depends on the fact that all your files are in a certain directory and are named appropiatly. Please make sure that all your scripts have the following names. FILES ARE CASE-SENSITIVE!" & @CRLF & "" & @CRLF & "Debris Field Watcher = DF Watcher v1.2.exe" & @CRLF & "Idler = Idler.exe")

$folder = FileSelectFolder("Select the folder containing your OGame Scripts.","")

MsgBox(0,"Commands","The following are the commands to activate their respective functions." & @CRLF & "" & @CRLF & "ALT + w = DF Watcher v1.2" & @CRLF & "ALT + i = Idler" & @CRLF & "This window = Home")

While 1
    Sleep(100)
WEnd

Func dfwatch()
    Run("" & $folder & "\DF Watcher v1.2.exe")
EndFunc

Func idler()
    Run("" & $folder & "\Idler.exe")
EndFunc

Func help()
    MsgBox(0,"Commands","The following are the commands to activate their respective functions." & @CRLF & "" & @CRLF & "ALT + w = DF Watcher v1.2" & @CRLF & "ALT + i = Idler" & @CRLF & "This window = Home")
EndFunc

Func stop()
    Exit 0
EndFunc

if you need something else, or i didnt make any sense. let me know :) thanks :party:

Link to comment
Share on other sites

  • Moderators

dorkbrains,

From the HotKeySet Help file: Remarks - "If two AutoIt scripts set the same HotKeys, you should avoid running those scripts simultaneously. (The second script cannot capture the hotkey unless the first script terminates or unregisters the key prior to the second script setting the hotkey."

So you need to deregister the "Home" key in the master script just before calling the child script - that way your child can use the key. If the child script terminates, then it automatically frees the key for the main script to reregister it. If the child remains active, you will have to perform a similar "swap" as you return to the main script.

And before you ask: "function - [optional] The name of the function to call when the key is pressed. Not specifying this parameter will unset a previous hotkey" - from the same page. ;-)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

alright i did what you said melba but now im running into an issue where once i press end to stop the child script...i cant go back to the master and use its functions...this is what the new master looks like.

Global $folder = True
HotKeySet("!w","dfwatch")
HotKeySet("!i","idler")
HotKeySet("{HOME}","help")
HotKeySet("{END}","stop")

MsgBox(0,"WATCH OUT!!!","This Master Script depends on the fact that all your files are in a certain directory and are named appropiatly. Please make sure that all your scripts have the following names. FILES ARE CASE-SENSITIVE!" & @CRLF & "" & @CRLF & "Debris Field Watcher = DF Watcher v1.2.exe" & @CRLF & "Idler = Idler.exe")

$folder = FileSelectFolder("Select the folder containing your OGame Scripts.","")

MsgBox(0,"Commands","The following are the commands to activate their respective functions." & @CRLF & "" & @CRLF & "ALT + w = DF Watcher v1.2" & @CRLF & "ALT + i = Idler" & @CRLF & "This window = Home")

While 1
    Sleep(100)
WEnd

Func dfwatch()
    HotKeySet("{HOME}")
    HotKeySet("{END}")
    Run("" & $folder & "\DF Watcher v1.2.exe")
EndFunc

Func idler()
    HotKeySet("{HOME}")
    HotKeySet("{END}")
    Run("" & $folder & "\Idler.exe")
EndFunc

Func help()
    MsgBox(0,"Commands","The following are the commands to activate their respective functions." & @CRLF & "" & @CRLF & "ALT + w = DF Watcher v1.2" & @CRLF & "ALT + i = Idler" & @CRLF & "This window = Home")
EndFunc

Func stop()
    Exit 0
EndFunc
Link to comment
Share on other sites

  • Moderators

dorkbrains,

As I mentioned in my first post above, if you want your master to regain use of the HotKeys, you need to reregister them once the child script returns. An example:

Func dfwatch()
    ; Cancel HotKeys in the master script
    HotKeySet("{HOME}")
    HotKeySet("{END}")
    ; Run child script
    Run("" & $folder & "\DF Watcher v1.2.exe")
    ; Reregister HotKeys for use in the master script
    HotKeySet("{HOME}","help")
    HotKeySet("{END}","stop")
EndFunc

As long as only one script is using a HotKey at a time, all should be well.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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...