vazzzzz
У меня функция копирования в Буфер обмена выглядит так: [more=ClipBoard.SetData]
Код: CF_TEXT = 1;
CF_UNICODETEXT = 13;
CF_OEMTEXT = 7;
if not ClipBoard then ClipBoard = {}; end
ClipBoard.SetData = function (vData, nFormat)
nFormat = nFormat or CF_TEXT;
local hWnd = Application.GetWndHandle();
local tData, hLock, hMemory, nSize, hStruct
if (type(vData) == "number") and (vData == 0) then
hMemory = vData;
else
if (type(vData) == "string") then
nSize = #vData;
else
return -1;
end
nSize = nSize + 1;
if (nFormat == CF_UNICODETEXT) then
hMemory = tonumber(DLL.CallFunction("kernel32.dll", "GlobalAlloc", "66,"..(nSize * 2), DLL_RETURN_TYPE_INTEGER, DLL_CALL_STDCALL));
else
hMemory = tonumber(DLL.CallFunction("kernel32.dll", "GlobalAlloc", "66,"..nSize, DLL_RETURN_TYPE_INTEGER, DLL_CALL_STDCALL));
end
local STR1 = MemoryEx.DefineStruct{STRING("char", nSize)};
local STR2 = MemoryEx.DefineStruct{STRING("wchar", nSize, 1, MEMEX_UNICODE)};
local STR3 = MemoryEx.DefineStruct{BYTE("byte")};
if (hMemory == 0) then return -1; end
hLock = tonumber(DLL.CallFunction("kernel32.dll", "GlobalLock", hMemory, DLL_RETURN_TYPE_INTEGER, DLL_CALL_STDCALL));
if (hLock == 0) then return -1; end
if (nFormat == CF_TEXT) or (nFormat == CF_OEMTEXT) then
hStruct = MemoryEx.AssignStruct(hLock, STR1);
hStruct.char = vData;
elseif (nFormat == CF_UNICODETEXT) then
hStruct = MemoryEx.AssignStruct(hLock, STR2);
hStruct.wchar = vData;
else
hStruct = MemoryEx.AssignStruct(hLock, STR3);
hStruct.byte = vData;
end
DLL.CallFunction("kernel32.dll", "GlobalUnlock", hMemory, DLL_RETURN_TYPE_INTEGER, DLL_CALL_STDCALL);
end
if (DLL.CallFunction("user32.dll", "OpenClipboard", hWnd, DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL) == "0") then
hStruct:Close();
return -1;
end
if (DLL.CallFunction("user32.dll", "EmptyClipboard", "", DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL) == "0") then
hStruct:Close();
return -1;
end
if (DLL.CallFunction("user32.dll", "SetClipboardData", nFormat..","..hMemory, DLL_RETURN_TYPE_INTEGER, DLL_CALL_STDCALL) == "0") then
hStruct:Close();
DLL.CallFunction("user32.dll", "CloseClipboard", "", DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL);
return -1;
end
hStruct:Close();
DLL.CallFunction("user32.dll", "CloseClipboard", "", DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL);
return hMemory;
end
--ClipBoard.SetData("Ru-Board");
ClipBoard.SetData("Это Спарта!", CF_UNICODETEXT);
У меня функция копирования в Буфер обмена выглядит так: [more=ClipBoard.SetData]
Код: CF_TEXT = 1;
CF_UNICODETEXT = 13;
CF_OEMTEXT = 7;
if not ClipBoard then ClipBoard = {}; end
ClipBoard.SetData = function (vData, nFormat)
nFormat = nFormat or CF_TEXT;
local hWnd = Application.GetWndHandle();
local tData, hLock, hMemory, nSize, hStruct
if (type(vData) == "number") and (vData == 0) then
hMemory = vData;
else
if (type(vData) == "string") then
nSize = #vData;
else
return -1;
end
nSize = nSize + 1;
if (nFormat == CF_UNICODETEXT) then
hMemory = tonumber(DLL.CallFunction("kernel32.dll", "GlobalAlloc", "66,"..(nSize * 2), DLL_RETURN_TYPE_INTEGER, DLL_CALL_STDCALL));
else
hMemory = tonumber(DLL.CallFunction("kernel32.dll", "GlobalAlloc", "66,"..nSize, DLL_RETURN_TYPE_INTEGER, DLL_CALL_STDCALL));
end
local STR1 = MemoryEx.DefineStruct{STRING("char", nSize)};
local STR2 = MemoryEx.DefineStruct{STRING("wchar", nSize, 1, MEMEX_UNICODE)};
local STR3 = MemoryEx.DefineStruct{BYTE("byte")};
if (hMemory == 0) then return -1; end
hLock = tonumber(DLL.CallFunction("kernel32.dll", "GlobalLock", hMemory, DLL_RETURN_TYPE_INTEGER, DLL_CALL_STDCALL));
if (hLock == 0) then return -1; end
if (nFormat == CF_TEXT) or (nFormat == CF_OEMTEXT) then
hStruct = MemoryEx.AssignStruct(hLock, STR1);
hStruct.char = vData;
elseif (nFormat == CF_UNICODETEXT) then
hStruct = MemoryEx.AssignStruct(hLock, STR2);
hStruct.wchar = vData;
else
hStruct = MemoryEx.AssignStruct(hLock, STR3);
hStruct.byte = vData;
end
DLL.CallFunction("kernel32.dll", "GlobalUnlock", hMemory, DLL_RETURN_TYPE_INTEGER, DLL_CALL_STDCALL);
end
if (DLL.CallFunction("user32.dll", "OpenClipboard", hWnd, DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL) == "0") then
hStruct:Close();
return -1;
end
if (DLL.CallFunction("user32.dll", "EmptyClipboard", "", DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL) == "0") then
hStruct:Close();
return -1;
end
if (DLL.CallFunction("user32.dll", "SetClipboardData", nFormat..","..hMemory, DLL_RETURN_TYPE_INTEGER, DLL_CALL_STDCALL) == "0") then
hStruct:Close();
DLL.CallFunction("user32.dll", "CloseClipboard", "", DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL);
return -1;
end
hStruct:Close();
DLL.CallFunction("user32.dll", "CloseClipboard", "", DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL);
return hMemory;
end
--ClipBoard.SetData("Ru-Board");
ClipBoard.SetData("Это Спарта!", CF_UNICODETEXT);