You must declare a body because it is not marked as Abstract, extern or partial

Asked

Viewed 530 times

-1

I’m new to programming and I’m trying to use the Class Sendkeys following this link, but when placing the:

public static void Send(string keys);

the compiler returns me the following error: *Error CS0501 "Send(string)" keys must declare a body because it is not marked as Abstract, extern or partial.*

1 answer

1


You’re trying to implement the class SendKeys? Don’t do this!

SendKeys is a class that provides methods to send a keystroke to the application.

When you need to use the functionality of this class in your code just do:

SendKeys.Send(/*Aqui vai a tecla que deseja enviar*/);

Each key is represented by one or more characters. To specify a unique keyboard character, use the character itself. For example, to represent the letter A, pass the string "A" to the method. To represent more than one character, add each additional character to the one above. To represent the letters A, B and C, specify the parameter as "ABC".

The addition sign (+), circumflex ( ), percentage sign (%), tilde (~) and parentheses () have special meanings for Sendkeys. To specify one of these characters, put it between keys ({}). For example, to specify the plus sign, use "{+}". To specify key characters, use "{{}" and"{}}". Brackets ([]) have no special meaning for Sendkeys, but you should include them between keys. In other applications, brackets have a special meaning that can be significant when dynamic data exchange occurs (DDE).

  • I tried to do so earlier but was not giving "Sendkeys does not exist in the current context". Follows error screenshot: https://imgur.com/a/2f0My0H

  • It has this clause using System.Windows.Forms; in your program?

  • 1

    That’s right, I didn’t even notice. Thank you very much. :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.