简体   繁体   English

有没有办法通过 android 应用程序创建键盘宏?

[英]Is there a way to create keyboard macros through an android app?

First of all, I am extremely new to coding and I just learned the basics of java.首先,我对编码非常陌生,我刚刚学习了 java 的基础知识。 I want to do an android app as my first project.我想做一个 android 应用程序作为我的第一个项目。 The idea of the app would be to have buttons on your phone which would work as keyboard macros.该应用程序的想法是在您的手机上安装可以用作键盘宏的按钮。 I was wondering if I also needed to create specific windows drivers for it or if I could just make it run on the default windows keyboard drivers?我想知道我是否还需要为其创建特定的 windows 驱动程序,或者我是否可以让它在默认的 windows 键盘驱动程序上运行? As I said I am super new to all of this (about 10hrs of programming experience), so feel free to correct me and educate me as much as you want, I won't take it personally: I'm looking to learn :)正如我所说,我对所有这些都是超级新手(大约 10 小时的编程经验),所以请随时纠正我并尽可能多地教育我,我不会把它当作个人:我正在寻找学习 :)

You would need to set up some sort of communication between the app and your PC.您需要在应用程序和您的 PC 之间建立某种通信。 You wouldn't need to do anything with the keyboard drivers.你不需要对键盘驱动程序做任何事情。 Java has something called the "Robot class" which allows you to simulate a keypress. Java 有一个叫做“机器人类”的东西,它允许你模拟按键。

Here is the documentation on the robot class: https://docs.oracle.com/javase/7/docs/api/java/awt/Robot.html Here is the documentation on the robot class: https://docs.oracle.com/javase/7/docs/api/java/awt/Robot.html

As for the communications, you will need to create a server/client connection.至于通信,您将需要创建一个服务器/客户端连接。 One of your devices will act as the client (probably your phone) and one will act as the server (probably your PC).您的其中一台设备将充当客户端(可能是您的手机),另一台设备将充当服务器(可能是您的 PC)。

This is just a rough idea of how it would work but:这只是它如何工作的粗略想法,但是:

When you tap the button on your phone, it would send some specified data to your server that is running on your PC.当您点击手机上的按钮时,它会向您的 PC 上运行的服务器发送一些指定的数据。 You should set the data that gets sent from the client to the server as the key(s) keycode that you would like it to simulate so it will be easier to implement.您应该将从客户端发送到服务器的数据设置为您希望它模拟的键码,以便更容易实现。 When the server gets data from the client, it should send that data to the robot.keypress(data) function.当服务器从客户端获取数据时,它应该将该数据发送到robot.keypress(data) function。

This honestly sounds like it will be a big project for your skill level but I wish you the best of luck on this.老实说,这听起来对你的技能水平来说将是一个大项目,但我祝你在这方面好运。 This will probably be a frustrating experience but don't let it get the better of you.这可能是一个令人沮丧的经历,但不要让它变得更好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM