Показать сообщение отдельно

  #2  
Старый 17.03.2023, 12:03
LorianS1
Новичок
Регистрация: 17.03.2023
Сообщений: 8
С нами: 1665045

Репутация: 3
По умолчанию

Цитата:
Сообщение от !Sam#0235  

Can someone help me rewrite these .lua snippets in C++? I tried it on my own but it didn't work

Lua:





Код:
if
move
==
true
then
cursor
(
)
repeat
wait
(
0
)
cursorx
,
cursory
=
getCursorPos
(
)
sampToggleCursor
(
1
)
Ini
.
cfg
.
x
=
cursorx
   Ini
.
cfg
.
y
=
cursory
if
isKeyDown
(
27
)
then
move
=
0
end
until
isKeyDown
(
32
)
sampToggleCursor
(
0
)
sampSetCursorMode
(
0
)
move
=
false
Ini
.
cfg
.
x
=
cursorx
   Ini
.
cfg
.
y
=
cursory
   inicfg
.
save
(
Ini
,
MyIni
)
end


Lua:





Код:
function
cursor
(
)
local
x
,
y
=
getScreenResolution
(
)
local
x
=
x
/
2
local
y
=
x
/
2
--  local x = x - 100
local
y
=
y
-
-
70
local
result
,
lib
=
loadDynamicLibrary
(
"user32.dll"
)
if
result
then
local
result
,
proc
=
getDynamicLibraryProcedure
(
"SetCursorPos"
,
lib
)
local
a
=
callFunction
(
proc
,
2
,
0
,
x
,
y
)
freeDynamicLibrary
(
lib
)
end
end

sure.

1.


C++:





Код:
#include "inicfg.h"
ImVec4
color
(
mainIni
.
color
.
R
/
255.0f
,
mainIni
.
color
.
G
/
255.0f
,
mainIni
.
color
.
B
/
255.0f
,
1.0f
)
;
if
(
ImGui
::
ColorEdit4
(
"Color"
,
&
color
.
x
)
)
{
int
clr
=
join_argb
(
0
,
color
.
x
*
255
,
color
.
y
*
255
,
color
.
z
*
255
,
color
.
w
*
255
)
;
int
r
=
color
.
x
*
255
,
g
=
color
.
y
*
255
,
b
=
color
.
z
*
255
,
a
=
color
.
w
*
255
;
mainIni
.
config
.
hex
=
(
"%06X"
)
.
format
(
clr
)
;
mainIni
.
color
.
R
=
r
;
mainIni
.
color
.
G
=
g
;
mainIni
.
color
.
B
=
b
;
inicfg
::
save
(
mainIni
,
directIni
)
;
}


2.

C++:





Код:
#include 
void
cursor
(
)
{
int
x
=
GetSystemMetrics
(
SM_CXSCREEN
)
/
2
;
int
y
=
GetSystemMetrics
(
SM_CYSCREEN
)
/
2
;
// x = x - 100; // uncomment this line if you want to move the cursor to the left by 100px
y
=
y
+
70
;
// moves the cursor 70 pixels down
SetCursorPos
(
x
,
y
)
;
// set the cursor to a new position
}


p.s

In this code, we use the GetSystemMetrics WinAPI function to get the screen resolution, and then use the SetCursorPos function to move the cursor to the specified location. By default, the cursor will be shifted 70 pixels down. If you want to move the cursor to the left by 100 pixels, then uncomment the line x = x - 100;.
 
Ответить с цитированием