<p>I'm currently watching a stream of an NFL wildcard game, and the streamer unfortunately adds their own incredibly annoying sound effects at random times during the stream. Because my computer is plugged into an HDMI adapter into the tv away from me, I thought it might be a fun little project to figure out how to use Go to write a program that I can build on my iPhone to send keyboard commands to my laptop.</p>
<p>I've looked into some of the mobile packages for Go but I'm not sure exactly where to start. Is the mobile package suitable for this kind of thing? If not, what would be? For now, in the simplest way possible I'd like to be able to type "M" on the keyboard on my iPhone, and have that M get sent to my laptop as if I entered it on the laptop's keyboard.</p>
<p>Thanks in advance for any advice.</p>
<p>Quick edit: just thinking about this a little more, would it maybe be easier to install an SSH app on my iPhone, SSH onto my Macbook and access a simple command line program written in Go that way? </p>
<hr/>**评论:**<br/><br/>gogroob: <pre><p>On the mac side, you can use applescript to send a keystroke from your mac. </p>
<p><a href="http://apple.stackexchange.com/questions/36943/how-do-i-automate-a-key-press-in-applescript" rel="nofollow">http://apple.stackexchange.com/questions/36943/how-do-i-automate-a-key-press-in-applescript</a></p>
<p>Figure out the keystore script, then wrap that in an <code>os/exec</code> command.
Once that works, you can create a <code>net/http</code> handler which calls the exec code. </p>
<p>Then you can communicate with the server by building a simple web interface for your handler or by writing a little iOS app. </p>
<p>To make your little daemon on the mac work all the time, you can create a launchd script to run it in the background. They usually look like this <a href="https://github.com/groob/yo-yo/blob/master/pkg/pkgroot/Library/LaunchAgents/com.github.groob.yo-yo.plist" rel="nofollow">https://github.com/groob/yo-yo/blob/master/pkg/pkgroot/Library/LaunchAgents/com.github.groob.yo-yo.plist</a></p></pre>sairamk: <pre><p>for the keystroke part, I recently found a Golang project for desktop automation which controls both mouse and keyboard - <a href="https://github.com/go-vgo/robotgo" rel="nofollow">https://github.com/go-vgo/robotgo</a></p></pre>ConfuciusBateman: <pre><p>Thanks for the response! Okay so I understand wrapping they applescript responsible for tapping the key in an os/exec call, but I'm not quite following with the net/http part in terms of having it communicate with the phone component. In this solution, can I write the little iOS app in Go? That's what I'd like to do, even if it's not the most efficient/smart solution, it'd be nice to get my feet wet with mobile stuff in Go. </p>
<p>This might sound like a dumb question, but if I were able to write the iOS part in Go, what would be the best way to open up a "channel" of sorts to communicate between that application and my laptop, running the applescript (or the Go code that wraps it)? Thanks again in advance! </p></pre>NikkoTheGreeko: <pre><p>What does the NFL game and the sound effects in it have to do with your question?</p></pre>ConfuciusBateman: <pre><p>Context for why I want to make this, so that I can mute the stream from the couch. Probably wasn't clear about that.</p></pre>NikkoTheGreeko: <pre><p>Ahh ok now I understand. I was kinda getting that being the premise but then you lost me lol.</p></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传