[Help] c# snippet to get and set a project variable

fudge

Client
Регистрация
23.04.2022
Сообщения
14
Благодарностей
1
Баллы
3
Hi,

I am very new to c#. I am having a hard time with a c# snippet that I need to make my project work.

I am trying to emulate mouse movement. I have two random number blocks generating random numbers between 000 and 9999.

In c# block I have the following code for mouse scroll:

instance.ActiveTab.FullEmulationMouseWheel(000,000);

I need to replace the two coordinates of 000,000 for the mouse pointer with the two random numbers that are generated from two project variables. How can I do this?

Thanks
 

BAZAg

Client
Регистрация
08.11.2015
Сообщения
1 760
Благодарностей
2 399
Баллы
113
Hi,

I am very new to c#. I am having a hard time with a c# snippet that I need to make my project work.

I am trying to emulate mouse movement. I have two random number blocks generating random numbers between 000 and 9999.

In c# block I have the following code for mouse scroll:

instance.ActiveTab.FullEmulationMouseWheel(000,000);

I need to replace the two coordinates of 000,000 for the mouse pointer with the two random numbers that are generated from two project variables. How can I do this?

Thanks
C#:
instance.ActiveTab.FullEmulationMouseWheel(int.Parse(project.Variables["var_x"].Value), int.Parse(project.Variables["var_y"].Value));
 
  • Спасибо
Реакции: fudge и Nick

fudge

Client
Регистрация
23.04.2022
Сообщения
14
Благодарностей
1
Баллы
3

fudge

Client
Регистрация
23.04.2022
Сообщения
14
Благодарностей
1
Баллы
3
Perhaps I was too hasty to think I could come up with working code myself just yet...

I am now trying to do the same as before with the mouse move method. Only this time I am using 4 variables. 2 random numbers and top, left coordinates of a single html element. I have used the following code, but it breaks my project. Please have a look and tell me what I have done wrong:
C#:
instance.ActiveTab.MouseMove(int.Parse(project.Variables["rndCoord1"].Value), int.Parse(project.Variables["rndCoord2"].Value), int.Parse(project.Variables["left"].Value), int.Parse(project.Variables["top"].Value), true, false));
This is the code from zennolab documentation:
C#:
// preforms the mouse moving from [500, 250] to [500, 125]
// and rise left mouse click in the last location
instance.ActiveTab.MouseMove(500, 250, 500, 125, true, false);
Thank you for looking!
 
Последнее редактирование:

BAZAg

Client
Регистрация
08.11.2015
Сообщения
1 760
Благодарностей
2 399
Баллы
113
C#:
// demo data
project.Variables["rndCoord1"].Value = "500";
project.Variables["rndCoord2"].Value = "250";
project.Variables["left"].Value = "500";
project.Variables["top"].Value = "125";

instance.ActiveTab.MouseMove(
    int.Parse(project.Variables["rndCoord1"].Value),
    int.Parse(project.Variables["rndCoord2"].Value),
    int.Parse(project.Variables["left"].Value),
    int.Parse(project.Variables["top"].Value),
    true, false); // )) There was an extra closing bracket in your code. I removed.
You must make sure that your variables contain values that can be cast to a number.
If it doesn't work - send a screenshot of the error (it's not clear what exactly is happening to you).
 
  • Спасибо
Реакции: morpheus93 и fudge

fudge

Client
Регистрация
23.04.2022
Сообщения
14
Благодарностей
1
Баллы
3
C#:
// demo data
project.Variables["rndCoord1"].Value = "500";
project.Variables["rndCoord2"].Value = "250";
project.Variables["left"].Value = "500";
project.Variables["top"].Value = "125";

instance.ActiveTab.MouseMove(
    int.Parse(project.Variables["rndCoord1"].Value),
    int.Parse(project.Variables["rndCoord2"].Value),
    int.Parse(project.Variables["left"].Value),
    int.Parse(project.Variables["top"].Value),
    true, false); // )) There was an extra closing bracket in your code. I removed.
You must make sure that your variables contain values that can be cast to a number.
If it doesn't work - send a screenshot of the error (it's not clear what exactly is happening to you).
This code is working. You have helped me to understand. Thank You!
 
  • Спасибо
Реакции: BAZAg

Кто просматривает тему: (Всего: 1, Пользователи: 0, Гости: 1)