The point is that I create the program "AutoClicker" - this is the program that simulates clicks after a certain number of Minutes, seconds (miles-seconds and less ...), thus the program should include the function itself including the script. There is such a function, it works on F1 - enable the script. F2 - turn off the script. But there must also be a hot key change, I have problems with that. Created a text box in which when you press a key - the text of the text box will change to the pressed key. But I need the "C" button to erase, and the OK button to accept. It is necessary that when you click on the "OK" button, the hot key is changed to the selected key. Here are the pictures: How to write a default key variable that will still be replaced? The code itself that starts the script and turns off the script. On the first image I want to ask you - what type of variable is needed for the default value - which will change with pressing the "OK" key. On the second image, nothing is required, just a script showing how it is pressed.

  • 2
    Code samples are best sent in text format. - Silento

1 answer 1

If I understand you correctly, then you need to do the following:

public Key keystart = Key.F1; public Key keystop = Key.F2; 

It's not entirely clear why you use GetAsyncKeyState when there is a standard KeyDown and it is used like this:

after InitializeComponent(); Subscribe to the button press event this.KeyDown += MainWindow_KeyDown; Inside the method and implement your validation logic

 private void MainWindow_KeyDown(object sender, KeyEventArgs e) { if(e.Key==keystart) { //Тут запуск скрипта } if(e.Key==keystop ) { //Тут остановка скрипта } } 

Now, in order to change the hot key, you only need to change the value of keystart or keystop

  • I use GetAsyncKeyState because the click action must be performed not only in the program itself, but also in the game. - Quebec