From c12a2660447b44d1de55c57d22f12179aa0f3e2a Mon Sep 17 00:00:00 2001 From: joten Date: Sun, 8 Feb 2015 17:40:19 +0100 Subject: [PATCH] Added some kind of remote control ... ... i. e. the possibility for sending commands to bug.n from another AutoHotkey script, as suggested by franckspike with issue #20 (a pull request). --- doc/CHANGES.md | 1 + doc/CREDITS.md | 4 +++- doc/Usage.md | 9 +++++++++ src/Bar.ahk | 10 ++++++++-- test/RemoteControl.ahk | 4 ++++ 5 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 test/RemoteControl.ahk diff --git a/doc/CHANGES.md b/doc/CHANGES.md index 0cac258..5e50cd4 100644 --- a/doc/CHANGES.md +++ b/doc/CHANGES.md @@ -21,6 +21,7 @@ not implement the functionality: `Monitor_toggleWindowTag`, `View_activateWindow 7. `~` Revised the rule layout. The third parameter is not compared to the window style anymore, but is a function name, which is called with the window ID as a paramater, when applying the rule. 8. `~` Revised the default rule set. +9. `+` Added the possibility for sending commands to bug.n from another AutoHotkey script. | # | Configuration variables | `-` Hotkey functions | `+` Hotkey functions | | --:| ------------------------- | --------------------------------------- | ----------------------------------------------------- | diff --git a/doc/CREDITS.md b/doc/CREDITS.md index 3a1a4e6..fe3ba2a 100644 --- a/doc/CREDITS.md +++ b/doc/CREDITS.md @@ -25,7 +25,9 @@ summarizes these sources (of ideas or code): #### Code snippets -* [franckspike](https://github.com/franckspike): [More general loop function](https://github.com/franckspike/bug.n/commit/e4e615512b363e8c342bf02cf9067cfeb4cc5d57#diff-e42236c27dedd9350fa8c9b9654fd485) +* [franckspike](https://github.com/franckspike): + + [More general loop function](https://github.com/franckspike/bug.n/commit/e4e615512b363e8c342bf02cf9067cfeb4cc5d57#diff-e42236c27dedd9350fa8c9b9654fd485) + + [Remote control](https://github.com/franckspike/bug.n/commit/2beacc71aef4d4c46021f97b52ab857efabc871c) * fures: System + Network monitor - with net history graph (AutoHotkey forum) * maestrith: Script Writer (github.com/maestrith/Script_Writer) * PhiLho: [AC/Battery status](http://www.autohotkey.com/forum/topic7633.html) diff --git a/doc/Usage.md b/doc/Usage.md index e0518c0..8bb9c10 100644 --- a/doc/Usage.md +++ b/doc/Usage.md @@ -22,6 +22,15 @@ the list. * A function can be selected from a list or entered in the command GUI, which is accessible by cklickig on `#!` on the right end of the bug.n bar. +You may also send commands to bug.n from another AutoHotkey script. The sent +string is interpreted and executed by bug.n either as a bug.n-function (as used +in the hotkey configuration), the `Run` or `Send` command of AutoHotkey. For +example, you may use the following lines in an AutoHotkey script: + + DetectHiddenWindows, On + ;; ControlSetText, Edit2, % "()", bug.n_BAR_0 + ControlSetText, Edit2, % "Monitor_activateView(4)", bug.n_BAR_0 + ### Concepts #### Layouts diff --git a/src/Bar.ahk b/src/Bar.ahk index 305cdf9..101dc3c 100644 --- a/src/Bar.ahk +++ b/src/Bar.ahk @@ -164,7 +164,7 @@ Bar_init(m) { Bar_initCmdGui() { - Global Bar_#0_#0, Bar_#0_#0H, Bar_#0_#0W, Bar_cmdGuiIsVisible, Config_backColor_#1_#3, Config_barCommands, Config_fontName, Config_fontSize, Config_foreColor_#1_#3 + Global Bar_#0_#0, Bar_#0_#0H, Bar_#0_#0W, Bar_#0_#1, Bar_cmdGuiIsVisible, Config_backColor_#1_#3, Config_barCommands, Config_fontName, Config_fontSize, Config_foreColor_#1_#3 Bar_cmdGuiIsVisible := False wndTitle := "bug.n_BAR_0" @@ -176,9 +176,11 @@ Bar_initCmdGui() Gui, Color, Default Gui, Font, s%Config_fontSize%, %Config_fontName% StringSplit, cmd, Config_barCommands, `; - Gui, Add, ComboBox, x10 y0 r%cmd0% w300 Background%Config_backColor_#1_#3% c%Config_fontColor_#1_#3% Simple vBar_#0_#0 gBar_cmdGuiEnter, % Config_barCommands + Gui, Add, ComboBox, x10 y10 r%cmd0% w300 Background%Config_backColor_#1_#3% c%Config_fontColor_#1_#3% Simple vBar_#0_#0 gBar_cmdGuiEnter, % Config_barCommands + Gui, Add, Edit, Y0 w300 Hidden vBar_#0_#1 gBar_cmdGuiEnter Gui, Add, Button, Y0 Hidden Default gBar_cmdGuiEnter, OK GuiControlGet, Bar_#0_#0, Pos + Bar_#0_#0H += 20 Bar_#0_#0W += 20 Gui, Show, Hide w%Bar_#0_#0W% h%Bar_#0_#0H%, %wndTitle% } @@ -202,6 +204,10 @@ Bar_cmdGuiEnter: WinActivate, ahk_id %Bar_aWndId% Main_evalCommand(Bar_#0_#0) Bar_#0_#0 := "" + } Else If (A_GuiControl = "Bar_#0_#1") { + Gui, Submit, NoHide + Debug_logMessage("DEBUG[6] Bar_cmdGuiEnter; command: " . Bar_#0_#1, 6) + Main_evalCommand(Bar_#0_#1) } Return diff --git a/test/RemoteControl.ahk b/test/RemoteControl.ahk new file mode 100644 index 0000000..1bbbe40 --- /dev/null +++ b/test/RemoteControl.ahk @@ -0,0 +1,4 @@ +;; Just use this to send commands +DetectHiddenWindows, On +;; ControlSetText, Edit2, % "()", bug.n_BAR_0 +ControlSetText, Edit2, % "Monitor_activateView(4)", bug.n_BAR_0