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).
This commit is contained in:
joten 2015-02-08 17:40:19 +01:00
parent dacbaf634d
commit c12a266044
5 changed files with 25 additions and 3 deletions

View File

@ -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 |
| --:| ------------------------- | --------------------------------------- | ----------------------------------------------------- |

View File

@ -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)

View File

@ -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, % "<function name>(<comma separated list of arguments>)", bug.n_BAR_0
ControlSetText, Edit2, % "Monitor_activateView(4)", bug.n_BAR_0
### Concepts
#### Layouts

View File

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

4
test/RemoteControl.ahk Normal file
View File

@ -0,0 +1,4 @@
;; Just use this to send commands
DetectHiddenWindows, On
;; ControlSetText, Edit2, % "<function name>(<arguments>)", bug.n_BAR_0
ControlSetText, Edit2, % "Monitor_activateView(4)", bug.n_BAR_0