das Vainstaintisch
das Vainstaintisch
CC#
Created by das Vainstaintisch on 5/10/2024 in #help
✅ problems with executing code from variable
to make code more clean
30 replies
CC#
Created by das Vainstaintisch on 5/10/2024 in #help
✅ problems with executing code from variable
can i all these dll imports
[DllImport(""user32.dll"")]
static extern void mouse_event(int dwFlags, int dx, int dy, int dwData, int dwExtraInfo);
[DllImport(""user32.dll"")]
static extern void keybd_event(byte bGAK, byte bScan, int dwFlags, int dwExtraInfo);
[DllImport(""user32.dll"")]
static extern short GetAsyncKeyState(int GAKey);
[DllImport(""user32.dll"")]
static extern void mouse_event(int dwFlags, int dx, int dy, int dwData, int dwExtraInfo);
[DllImport(""user32.dll"")]
static extern void keybd_event(byte bGAK, byte bScan, int dwFlags, int dwExtraInfo);
[DllImport(""user32.dll"")]
static extern short GetAsyncKeyState(int GAKey);
put into this string?(WithImports)
30 replies
CC#
Created by das Vainstaintisch on 5/10/2024 in #help
✅ problems with executing code from variable
but another one thing
30 replies
CC#
Created by das Vainstaintisch on 5/10/2024 in #help
✅ problems with executing code from variable
oh, now it works, thank you!
30 replies
CC#
Created by das Vainstaintisch on 5/10/2024 in #help
✅ problems with executing code from variable
i don't like this site in total because it always gives me not those im looking for
30 replies
CC#
Created by das Vainstaintisch on 5/10/2024 in #help
✅ problems with executing code from variable
sorry if i'm being stupid, but i may not understand you
30 replies
CC#
Created by das Vainstaintisch on 5/10/2024 in #help
✅ problems with executing code from variable
but i added this into code in the top.. or in variable with code, you mean, right?
30 replies
CC#
Created by das Vainstaintisch on 5/10/2024 in #help
✅ problems with executing code from variable
No description
30 replies
CC#
Created by das Vainstaintisch on 5/10/2024 in #help
✅ problems with executing code from variable
what do you mean
30 replies
CC#
Created by das Vainstaintisch on 5/10/2024 in #help
✅ problems with executing code from variable
or
30 replies
CC#
Created by das Vainstaintisch on 5/10/2024 in #help
✅ problems with executing code from variable
here's error
30 replies
CC#
Created by das Vainstaintisch on 5/10/2024 in #help
✅ problems with executing code from variable
var result = await compiledScript.RunAsync();
30 replies
CC#
Created by das Vainstaintisch on 5/10/2024 in #help
✅ problems with executing code from variable
still this error
30 replies
CC#
Created by das Vainstaintisch on 5/10/2024 in #help
✅ problems with executing code from variable
i added this, and nothing was changed
30 replies
CC#
Created by das Vainstaintisch on 5/10/2024 in #help
✅ problems with executing code from variable
i'll try
30 replies
CC#
Created by das Vainstaintisch on 5/10/2024 in #help
✅ problems with executing code from variable
you mean i should add using DllImportAttribute?'
30 replies
CC#
Created by das Vainstaintisch on 5/10/2024 in #help
✅ problems with executing code from variable
code:
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Scripting;
using Microsoft.CodeAnalysis.Scripting;
using System.Runtime.InteropServices;

namespace Testapp
{
internal class Program
{
static async Task Main(string[] args)
{

var codeToCompile = @"
[DllImport(""user32.dll"")]
static extern void mouse_event(int dwFlags, int dx, int dy, int dwData, int dwExtraInfo);
[DllImport(""user32.dll"")]
static extern void keybd_event(byte bGAK, byte bScan, int dwFlags, int dwExtraInfo);
[DllImport(""user32.dll"")]
static extern short GetAsyncKeyState(int GAKey);
if((GetAsyncKeyState(0x26) & 0x8000) != 0)//проверка на стрелочку вверх
{
mouse_event(0x0001, 0, -10, 0, 0);// курсор вверх на 10 пикселей
}

if ((GetAsyncKeyState(0x28) & 0x8000) != 0)//проверка на стрелочку вниз
{
mouse_event(0x0001, 0, 10, 0, 0);// курсор вниз на 10 пикселей
}

if ((GetAsyncKeyState(0x25) & 0x8000) != 0)//проверка на стрелочку налево
{
mouse_event(0x0001, -10, 0, 0, 0);// курсор влево на 10 пикселей
}

if ((GetAsyncKeyState(0x27) & 0x8000) != 0)//проверка на стрелочку направо
{
mouse_event(0x0001, 10, 0, 0, 0);// курсор вправо на 10 пикселей
}
";

var options = ScriptOptions.Default;
options = options.WithImports("System", "System.Console");
Script compiledScript = CSharpScript.Create(codeToCompile, options);

Console.WriteLine("Executing code...");

while (true) { var result = await compiledScript.RunAsync(); }// зацикливает код, всё что дальше - бессмысленно
//Console.WriteLine(result.ReturnValue);
Console.WriteLine("Code executed...");
Console.ReadKey();
}
}
}
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Scripting;
using Microsoft.CodeAnalysis.Scripting;
using System.Runtime.InteropServices;

namespace Testapp
{
internal class Program
{
static async Task Main(string[] args)
{

var codeToCompile = @"
[DllImport(""user32.dll"")]
static extern void mouse_event(int dwFlags, int dx, int dy, int dwData, int dwExtraInfo);
[DllImport(""user32.dll"")]
static extern void keybd_event(byte bGAK, byte bScan, int dwFlags, int dwExtraInfo);
[DllImport(""user32.dll"")]
static extern short GetAsyncKeyState(int GAKey);
if((GetAsyncKeyState(0x26) & 0x8000) != 0)//проверка на стрелочку вверх
{
mouse_event(0x0001, 0, -10, 0, 0);// курсор вверх на 10 пикселей
}

if ((GetAsyncKeyState(0x28) & 0x8000) != 0)//проверка на стрелочку вниз
{
mouse_event(0x0001, 0, 10, 0, 0);// курсор вниз на 10 пикселей
}

if ((GetAsyncKeyState(0x25) & 0x8000) != 0)//проверка на стрелочку налево
{
mouse_event(0x0001, -10, 0, 0, 0);// курсор влево на 10 пикселей
}

if ((GetAsyncKeyState(0x27) & 0x8000) != 0)//проверка на стрелочку направо
{
mouse_event(0x0001, 10, 0, 0, 0);// курсор вправо на 10 пикселей
}
";

var options = ScriptOptions.Default;
options = options.WithImports("System", "System.Console");
Script compiledScript = CSharpScript.Create(codeToCompile, options);

Console.WriteLine("Executing code...");

while (true) { var result = await compiledScript.RunAsync(); }// зацикливает код, всё что дальше - бессмысленно
//Console.WriteLine(result.ReturnValue);
Console.WriteLine("Code executed...");
Console.ReadKey();
}
}
}
30 replies
CC#
Created by das Vainstaintisch on 2/23/2024 in #help
How can i compile code, that is located in variable string?
No description
62 replies
CC#
Created by das Vainstaintisch on 2/23/2024 in #help
How can i compile code, that is located in variable string?
it didn't work just now
62 replies
CC#
Created by das Vainstaintisch on 2/23/2024 in #help
How can i compile code, that is located in variable string?
why it works??
62 replies