Keyboard.write in word particle photon

Hey all! I am an extreme newbie to the particle photon, so I this is not a good question. However, I could not find the answer, so sorry to bother you!

I want to upload code to my article which makes it type a sentence in Windows Word. I have uploaded the following really simple test code:

STARTUP(Keyboard.begin());

        void setup() {
          Keyboard.begin();
        }

        void loop() {
          Keyboard.print("Hello");

          delay(1000);
        }

However, nothing visible is happening, there is no typing anywhere. Does anyone know how to make the photon type something in Word?

Thanks in advance and kind regards,
RNewbie.

Found the answer! In case anyone stumbles upon the same problem, I found this thread:

and I needed to install this driver:

Everything works like a treat.

1 Like

That’s odd, IIRC there rather was a problem with the drivers when you had the old ones installed since they got in the way of Windows’ own USB HID drivers.
Additionally it doesn’t matter what program you want the text to by typed into - just the same as it doesn’t matter what program is running when you type on a physical keyboard.

But for your original code, I’d do away with the Keyboard.begin() inside setup() and for the sake of testing on a vanilla Windows without any Particle drivers installed it used this and it worked as expected (target system version 0.6.3)

STARTUP(Keyboard.begin());

char txt[64] = "Hello!";

void setup() {
  Particle.function("type", typeIt);
}

void loop() {
  Keyboard.print(txt);
  delay(5000);  
}

int typeIt(String cmd) {
  strncpy(txt, (const char*)cmd, sizeof(txt));
  Keyboard.print(txt);
  return strlen(txt);
}
1 Like