How to write Variables element in C#

yozoo

Client
Регистрация
08.11.2012
Сообщения
36
Благодарностей
0
Баллы
6
Hi guys,

The Code:
Emulator.MouseClick(instance.ActiveTab.Handle, MouseButton.Left, MouseButtonEvent.Click, 105, 335);

if i use Variables element to replace 105, and 335, like {-Variable.Variableleft-} and {-Variable.Variabletop-}

how can i write the code again. Thanks

i have tried to write:
1.
Emulator.MouseClick(instance.ActiveTab.Handle, MouseButton.Left, MouseButtonEvent.Click, project.Variables["Variableleft"].Value, project.Variables["Variableleft"].Value);

2.
int inta = project.Variables["Variableleft"].Value;
int intb = project.Variables["Variabletop"].Value;
Emulator.MouseClick(instance.ActiveTab.Handle, MouseButton.Left, MouseButtonEvent.Click, inta, intb);

3.
string inta = project.Variables["Variableleft"].Value;
string intb = project.Variables["Variabletop"].Value;
Emulator.MouseClick(instance.ActiveTab.Handle, MouseButton.Left, MouseButtonEvent.Click, inta, intb);

but all of them not work for me.
 

shade

Client
Регистрация
19.11.2010
Сообщения
580
Благодарностей
346
Баллы
63
Hi guys,

The Code:
Emulator.MouseClick(instance.ActiveTab.Handle, MouseButton.Left, MouseButtonEvent.Click, 105, 335);

if i use Variables element to replace 105, and 335, like {-Variable.Variableleft-} and {-Variable.Variabletop-}

how can i write the code again. Thanks

i have tried to write:
1.
Emulator.MouseClick(instance.ActiveTab.Handle, MouseButton.Left, MouseButtonEvent.Click, project.Variables["Variableleft"].Value, project.Variables["Variableleft"].Value);

2.
int inta = project.Variables["Variableleft"].Value;
int intb = project.Variables["Variabletop"].Value;
Emulator.MouseClick(instance.ActiveTab.Handle, MouseButton.Left, MouseButtonEvent.Click, inta, intb);

3.
string inta = project.Variables["Variableleft"].Value;
string intb = project.Variables["Variabletop"].Value;
Emulator.MouseClick(instance.ActiveTab.Handle, MouseButton.Left, MouseButtonEvent.Click, inta, intb);

but all of them not work for me.
The variables of your project are string value, but the coordinates for method are integer value. You must convert your variable to the integer value. For this in C# exist the static class - Convert. It can convert all simple types, to the another type.
Here code:
C#:
int inta = Convert.ToInt32(project.Variables["Variableleft"].Value);
int intb = Convert.ToInt32(project.Variables["Variabletop"].Value);
Emulator.MouseClick(instance.ActiveTab.Handle, MouseButton.Left, MouseButtonEvent.Click, inta, intb);
 
  • Спасибо
Реакции: pyk и yozoo

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