Пробовал код для нажатия клавишь в таймауте
--lua
local button = {
{"f1",1}, -- таймаут в секундах
{"f2",2},
{"f3",0.5},
}
for i = 1, #button do
button[i][3] = os.clock() + button[i][2]
end
local main = function(button)
for i = 1, #button do
if button[i][3] < os.clock() then
send217(button[i][1])
button[i][3] = os.clock() + button[i][2]
end
end
end
while 1 do
main(button)
end
Таймаут - это пауза после клика?
Опиши полностью задачу, что должен делать скрипт.
--lua
do
local back = package.path
package.path = "luaPlugins\\winapi\\?.lua;"..package.path
setfenv(1, require'winapi')
require[[winapi.keyboard]]
package.path = back
end
-- Поолучаем состояние клавиши:
-- state - нажата/отжата
-- toggle - для лампочек горит/не горит.
while 1 do
wait (1)
local state, toggle = GetKeyState(0x91)
local stateC = GetKeyState(0x43)
local state5 = GetKeyState(0x35)
local stateV = GetKeyState(0x56)
log(tostring(toggle),tostring(state))
log(tostring(toggle1),tostring(state1))
if toggle and state1 then
wait (1)
send217 ("1")
else
if toggle and stateC then
wait (1)
send217 ("c")
else
if toggle and state5 then
wait (1)
send217 ("5")
else
if toggle and stateV then
wait (1)
send217 ("v")
else
end
end
end
end
--lua
local button = {
{"f1",1}, -- таймаут в секундах
{"f2",2},
{"f3",0.5}
}
for i = 1, #button do
button[i][3] = os.clock() + button[i][2]
end
local main = function(button)
for i = 1, #button do
if button[i][3] < os.clock() then
send217(button[i][1])
button[i][3] = os.clock() + button[i][2]
end
end
end
while 1 do
main(button)
end
--lua
do
local back = package.path
package.path = "luaPlugins\\winapi\\?.lua;"..package.path
setfenv(1, require'winapi')
require[[winapi.keyboard]]
package.path = back
end
-- Поолучаем состояние клавиши:
-- state - нажата/отжата
-- toggle - для лампочек горит/не горит.
while 1 do
wait (1)
local state, toggle = GetKeyState(0x91)
local stateC = GetKeyState(0x43)
local state5 = GetKeyState(0x35)
local stateV = GetKeyState(0x56)
log(tostring(toggle),tostring(state))
log(tostring(toggle1),tostring(state1))
if toggle and state1 then
wait (1)
send217 ("1")
else
if toggle and stateC then
wait (1)
send217 ("c")
else
if toggle and state5 then
wait (1)
send217 ("5")
else
if toggle and stateV then
wait (1)
send217 ("v")
else
end
end
end
end
local button = {
{"f1",1}, -- таймаут в секундах
{"f2",2},
{"f3",0.5}
}
local button = {
{"f1",1}, -- таймаут в секундах
{"f2",2},
{"f3",0.5}
}
Итак
что в данном скрипте означает 2?
Если button[3]это количество кнопок
то +button[i][2]?
--lua
local button = {
{"f1",1}, -- таймаут в секундах
{"f2",2},
{"f3",0.5},
}
for i = 1, #button do
button[i][3] = os.clock() + button[i][2]
end
local main = function(button)
for i = 1, #button do
if button[i][3] < os.clock() then
send217(button[i][1])
button[i][3] = os.clock() + button[i][2]
end
end
end
while 1 do
main(button)
end
--lua
local button = {
{"f1",0.06}, --Интервал в секундах
{"f2",0.07},
{"f3",0.08},
{"{f4}",0.05},
{"{f5}",1.1},
{"{f6}",0.9}
}
for i = 1, #button do
button[i][6] = os.clock() + button[i][2]
end
local main = function(button)
for i = 1, #button do
if button[i][6] < os.clock() then
send217(button[i][1])
button[i][6] = os.clock() + button[i][2]
end
end
end
while 1 do
main(button)
end
--fix
--lua
local button = {
{"f1",0.06},
{"f2",0.07},
{"f3",0.08},
{"{f4}",0.05},
{"{f5}",1.1},
{"{f6}",0.9}
}
log "clear" log "mode compact"
for i = 1, #button do
button[i][3] = os.clock() + button[i][2]
end
for i = 1, #button do
log(button[i][1] .. " " .. button[i][2] .. " " .. button[i][3])
end
--lua
do
local back = package.path
package.path = "luaPlugins\\winapi\\?.lua;"..package.path
setfenv(1, require'winapi')
require[[winapi.keyboard]]
package.path = back
end
local button = {
{"f1",0.06}, --Интервал в секундах
{"f2",0.07},
{"f3",0.08},
{"f4",0.05},
{"f5",1.1},
{"f6",0.9}
}
for i = 1, #button do
button[i][3] = os.clock() + button[i][2]
end
local main = function(button)
for i = 1, #button do
if button[i][3] < os.clock() then
send217(button[i][1])
button[i][3] = os.clock() + button[i][2]
-- 111
end
end
end
while 1 do
main(button)
end
local stateC = GetKeyState(0x43)
if toggle and stateC then
wait (1)
send217 ("c")
else
Примерно так, если я правильно понял что нужно:
--lua
do
local back = package.path
package.path = "luaPlugins\\winapi\\?.lua;"..package.path
setfenv(1, require'winapi')
require[[winapi.keyboard]]
package.path = back
end
local button = {
{"f1",0.06}, --Интервал в секундах
{"f2",0.07},
{"f3",0.08},
{"f4",0.05},
{"f5",1.1},
{"f6",0.9}
}
local button2 = {0x31, 0x32, 0x33} -- 1 2 3, клаивиши, которые прерывают отправку клавиш из таблицы button
for i = 1, #button do
button[i][3] = os.clock() + button[i][2]
end
local pause = function()
for i = 1, #button2 do -- проверяем не нажата ли клавиша
local state=GetKeyState(button2[i])
while state do -- ждать пока клавиша нажата
log("Нажата клавиша с кодом: " .. button2[i])
wait (10)
state=GetKeyState(button2[i])
end
end
end
local main = function(button)
for i = 1, #button do
pause() -- вызов функции, которая проверяет нажатие клавиш
if button[i][3] < os.clock() then
send217(button[i][1])
button[i][3] = os.clock() + button[i][2]
end
end
end
while 1 do
main(button)
wait (1)
end
--lua
do
local back = package.path
package.path = "luaPlugins\\winapi\\?.lua;"..package.path
setfenv(1, require'winapi')
require[[winapi.keyboard]]
package.path = back
end
local button = {
{"f1",0.06}, --Интервал в секундах
{"f2",0.07},
{"f3",0.08},
{"f4",0.05},
{"f5",1.1},
{"f6",0.9}
}
local button2 = {0x31, 0x32, 0x33} -- 1 2 3, клаивиши, которые прерывают отправку клавиш из таблицы button
for i = 1, #button do
button[i][3] = os.clock() + button[i][2]
end
local pause = function()
for i = 1, #button2 do -- проверяем не нажата ли клавиша
local state=GetKeyState(button2[i])
while state do -- ждать пока клавиша нажата
log("Нажата клавиша с кодом: " .. button2[i])
wait (10)
state=GetKeyState(button2[i])
end
end
end
local main = function(button)
for i = 1, #button do
pause() -- вызов функции, которая проверяет нажатие клавиш
if button[i][3] < os.clock() then
send217(button[i][1])
button[i][3] = os.clock() + button[i][2]
end
end
end
while 1 do
main(button)
wait (1)
end
local pause = function()
for i = 1, #button2 do -- проверяем не нажата ли клавиша
local state=GetKeyState(button2[i])
while state do -- ждать пока клавиша нажата
log("Нажата клавиша с кодом: " .. button2[i])
wait (10)
state=GetKeyState(button2[i])
if state={0x32} then
wait (1)
send217 ("r")
else
end
end
end
end
--lua
do
local back = package.path
package.path = "luaPlugins\\winapi\\?.lua;"..package.path
setfenv(1, require'winapi')
require[[winapi.keyboard]]
package.path = back
end
local button = {
{"a",0.1},
{"b",0.2},
{"c",0.3},
{"d",0.4},
{"e",0.5},
{"f",0.6}
}
local button2 = {0x31, 0x32, 0x33} -- 1 2 3, клавиши, которые прерывают отправку клавиш из таблицы button
for i = 1, #button do
button[i][3] = os.clock() + button[i][2]
end
local pause = function()
for i = 1, #button2 do -- проверяем не нажата ли клавиша
local state=GetKeyState(button2[i])
while state do -- ждать пока клавиша нажата
log("Нажата клавиша с кодом: " .. string.format("%x", button2[i]))
send('{' .. button2[i] .. '}')
wait (10)
state=GetKeyState(button2[i])
end
end
end
local main = function(button)
for i = 1, #button do
pause() -- вызов функции, которая проверяет нажатие клавиш
if button[i][3] < os.clock() then
send217(button[i][1])
button[i][3] = os.clock() + button[i][2]
end
end
end
while 1 do
main(button)
wait (1)
end
--lua
do
local back = package.path
package.path = "luaPlugins\\winapi\\?.lua;"..package.path
setfenv(1, require'winapi')
require[[winapi.keyboard]]
package.path = back
end
local button = {
{"a",0.1},
{"b",0.2},
{"c",0.3},
{"d",0.4},
{"e",0.5},
{"f",0.6}
}
local button2 = {0x31, 0x32, 0x33} -- 1 2 3, клавиши, которые прерывают отправку клавиш из таблицы button
for i = 1, #button do
button[i][3] = os.clock() + button[i][2]
end
local pause = function()
for i = 1, #button2 do -- проверяем не нажата ли клавиша
local state=GetKeyState(button2[i])
while state do -- ждать пока клавиша нажата
log("Нажата клавиша с кодом: " .. string.format("%x", button2[i]))
send('{' .. button2[i] .. '}')
wait (10)
state=GetKeyState(button2[i])
end
end
end
local main = function(button)
for i = 1, #button do
pause() -- вызов функции, которая проверяет нажатие клавиш
if button[i][3] < os.clock() then
send217(button[i][1])
button[i][3] = os.clock() + button[i][2]
end
end
end
while 1 do
main(button)
wait (1)
end
local pause = function()
for i = 1, #button2 do -- проверяем не нажата ли клавиша
local state=GetKeyState(button2[i])
local toggle = GetKeyState(0x91) -- (Scroll_Lock)
while state and toggle do -- ждать пока клавиша нажата
local toggle = GetKeyState(0x91) -- (Scroll_Lock)
log("Нажата клавиша с кодом: " .. button2[i])
send217('{' .. button2[i] .. '}')
wait (10)
state=GetKeyState(button2[i])
end
end
end
local button2 = {0x31, 0x52, 0x33, 0x43, 0x56, 0x35, 0x35, 0x35, 0x5A, 0x42, 0x32, 0x46, 0x58, 0x48, 0x47, 0xC0, 0x34, 0x04, 0x54}
local mouse1 = {0x01}
local mouse2 = {0x02}
for i = 1, #button do
button[i][3] = os.clock() + button[i][2]
end
local pause = function()
for i = 1, #button2 or #mouse1 or #mouse2 do -- проверяем не нажата ли клавиша
local state=GetKeyState(button2[i])
local mouse1=GetKeyState(mouse1[i])
local mouse2=GetKeyState(mouse2[i])
local toggle = GetKeyState(0x91) -- (Scroll_Lock)
while (state or mouse1 or mouse2) and toggle do -- ждать пока клавиша нажата
local toggle = GetKeyState(0x91) -- (Scroll_Lock)
log("Нажата клавиша с кодом: " .. button2[i])
if state then
send217('{' .. button2[i] .. '}')
wait(0)
else
if mouse1 then
left(mouse_pos() --Нажатия левой
wait(0)
else
if mouse2 then
right(mouse_pos()
wait(1)
else
end
end
end
wait (10)
state=GetKeyState(button2[i])
mouse1=GetKeyState(mouse1[i])
mouse2=GetKeyState(mouse2[i])
end
end
end
local button = {
{"f1",0.3},
{"f2",0.4}
}
--lua
do
local back = package.path
package.path = "luaPlugins\\winapi\\?.lua;"..package.path
setfenv(1, require'winapi')
require[[winapi.keyboard]]
package.path = back
end
local button = {
{"f1",0.3}, --Интервал в секундах
{"f2",0.4},
{"f3",0.5}
}
local button2 = {0x31, 0x52, 0x33, 0x43, 0x56, 0x35, 0x35, 0x35, 0x5A, 0x42, 0x32, 0x46, 0x58, 0x48, 0x47, 0xC0, 0x34}
for i = 1, #button do
button[i][3] = os.clock() + button[i][2]
end
local pause = function()
for i = 1, #button2 do -- проверяем не нажата ли клавиша
local state=GetKeyState(button2[i])
while state do -- ждать пока клавиша нажата
log("Нажата клавиша с кодом: " .. button2[i])
send217('{' .. button2[i] .. '}')
wait (10)
state=GetKeyState(button2[i])
end
end
end
local main = function(button)
for i = 1, #button do
pause() -- вызов функции, которая проверяет нажатие клавиш
if button[i][3] < os.clock() then
send217(button[i][1])
button[i][3] = os.clock() + button[i][2]
end
end
end
while 1 do
main(button)
wait (1)
end
--lua
do
local back = package.path
package.path = "luaPlugins\\winapi\\?.lua;"..package.path
setfenv(1, require'winapi')
require[[winapi.keyboard]]
package.path = back
end
local button = {
{"f1",0.06}, --Интервал в секундах
{"f2",0.09}
}
local button2 = {0x31, 0x52, 0x33, 0x43, 0x56, 0x35, 0x35, 0x35, 0x5A, 0x42, 0x32, 0x46, 0x58, 0x48, 0x47, 0xC0, 0x34, 0x04, 0x54} -- клаивиши, которые прерывают отправку клавиш из таблицы button
local mouse1 = {0x01}
--local mouse2 = {0x02}
for i = 1, #button do
button[i][3] = os.clock() + button[i][2]
end
local pause = function()
--local pause3 = function()
for i = 1, #button do -- проверяем не нажата ли клавиша
local state=GetKeyState(button2[i])
--local mouse1=GetKeyState(mouse1[i])
--local mouse2=GetKeyState(mouse2[i])
--local toggle = GetKeyState(0x91) -- (Scroll_Lock)
while state do -- ждать пока клавиша нажата
--local toggle = GetKeyState(0x91) -- (Scroll_Lock)
log("Нажата клавиша: " .. button2[i])
send217('{' .. button2[i] .. '}')
wait(1)
-- right(mouse_pos(('{' .. button2[i] .. '}')))
wait (10)
state=GetKeyState(button2[i])
--mouse1=GetKeyState(mouse1[i]) -- тут статус мыши не определяем?
--mouse2=GetKeyState(mouse2[i])
end
end
end
local main = function(button) --Вот тут интересно, если я еще одну паузу сюда воткну, наверняка не будет работать? У нас была функция майн для button. Теперь нужно вторую для mouse? Или эта потянет?
local pause2 = function()
for i = 1, #mouse1 do -- проверяем не нажата ли мышь
local mouse1=GetKeyState(mouse1[i]) -- наверно i нужно другую присваивать? чет я всё в одну кучу слепил...
--local toggle = GetKeyState(0x91) -- (Scroll_Lock)
while mouse1 do -- ждать пока мышь1 нажата
--local toggle = GetKeyState(0x91) -- (Scroll_Lock)
log("Нажата клавиша: " .. mouse1[i])
left(mouse_pos(('{' .. mouse1[i] .. '}')))
wait(1)
-- right(mouse_pos(('{' .. button2[i] .. '}')))
wait (10)
state1=GetKeyState(mouse1[i]) -- ну тут мы типо статус мыши получаем
--mouse1=GetKeyState(mouse1[i])
--mouse2=GetKeyState(mouse2[i])
end
end
end
local main2 = function(mouse1) -- допустим я main2 создал, но её ведь не существует? она же базовая функция?
for i = 1, #button do
pause() -- вызов функции, которая проверяет нажатие клавиш
pause2() -- и еще одну паузу, пусть еще проверяет, так скрипт точно зависнет)))
if button[i][3] < os.clock() then
send217(button[i][1])
button[i][3] = os.clock() + button[i][2]
end
end
end
while 1 do
main(button)
wait (1)
end
Разбирайтесь.
--lua
do
local back = package.path
package.path = "luaPlugins\\winapi\\?.lua;"..package.path
setfenv(1, require'winapi')
require[[winapi.keyboard]]
package.path = back
end
local button = {
{"f1",0.3}, --Интервал в секундах
{"f2",0.4},
{"f3",0.5}
}
local button2 = {0x31, 0x52, 0x33, 0x43, 0x56, 0x35, 0x35, 0x35, 0x5A, 0x42, 0x32, 0x46, 0x58, 0x48, 0x47, 0xC0, 0x34}
local mouse1= {1, 2}
for i = 1, #button do
button[i][3] = os.clock() + button[i][2]
end
local pause = function()
for i = 1, #button2 do -- проверяем не нажата ли клавиша
local state=GetKeyState(button2[i])
while state do -- ждать пока клавиша нажата
log("Нажата клавиша с кодом: " .. button2[i])
send217('{' .. button2[i] .. '}')
wait (10)
state=GetKeyState(button2[i])
end
end
end
local mouse_pause = function()
for i = 1, #mouse1 do -- проверяем не нажата ли клавиша мыши
local state=GetKeyState(mouse1[i])
while state do -- ждать пока клавиша нажата
log("Нажата клавиша с кодом: " .. mouse1[i])
-- тут left или что нужно
wait (10)
state=GetKeyState(mouse1[i])
end
end
end
local main = function(button)
for i = 1, #button do
pause() -- вызов функции, которая проверяет нажатие клавиш клавиатуры
mouse_pause() -- вызов функции, которая проверяет нажатие клавиш мыши
if button[i][3] < os.clock() then
send217(button[i][1])
button[i][3] = os.clock() + button[i][2]
end
end
end
while 1 do
main(button)
wait (1)
end
--lua
do
local back = package.path
package.path = "luaPlugins\\winapi\\?.lua;"..package.path
setfenv(1, require'winapi')
require[[winapi.keyboard]]
package.path = back
end
local button = {
{"f1",0.3}, --Интервал в секундах
{"f2",0.4},
{"f3",0.5}
}
local button2 = {0x31, 0x52, 0x33, 0x43, 0x56, 0x35, 0x35, 0x35, 0x5A, 0x42, 0x32, 0x46, 0x58, 0x48, 0x47, 0xC0, 0x34}
local mouse1= {1, 2}
for i = 1, #button do
button[i][3] = os.clock() + button[i][2]
end
local pause = function()
for i = 1, #button2 do -- проверяем не нажата ли клавиша
local state=GetKeyState(button2[i])
while state do -- ждать пока клавиша нажата
log("Нажата клавиша с кодом: " .. button2[i])
send217('{' .. button2[i] .. '}')
wait (10)
state=GetKeyState(button2[i])
end
end
end
local mouse_pause = function()
for i = 1, #mouse1 do -- проверяем не нажата ли клавиша мыши
local state=GetKeyState(mouse1[i])
while state do -- ждать пока клавиша нажата
log("Нажата клавиша с кодом: " .. mouse1[i])
// тут left или что нужно
wait (10)
state=GetKeyState(mouse1[i])
end
end
end
local main = function(button)
for i = 1, #button do
pause() -- вызов функции, которая проверяет нажатие клавиш клавиатуры
mouse_pause() -- вызов функции, которая проверяет нажатие клавиш мыши
if button[i][3] < os.clock() then
send217(button[i][1])
button[i][3] = os.clock() + button[i][2]
end
end
end
while 1 do
main(button)
wait (1)
end
local mouse_pause = function()
for i = 1, #mouse1 do -- проверяем не нажата ли клавиша мыши
local state=GetKeyState(mouse1[i])
while state do -- ждать пока клавиша нажата
log("Нажата клавиша с кодом: " .. mouse1[i])
if state=1 then
local x, y = mouse_pos ()
left (x, y) // тут left или что нужно
else
if state=2 then
local x, y = mouse_pos ()
right (x, y)
else
end
end
wait (10)
state=GetKeyState(mouse1[i])
end
end
end
local mouse_pause = function()
for i = 1, #mouse1 do -- проверяем не нажата ли клавиша мыши
local state=GetKeyState(mouse1[i])
while state do -- ждать пока клавиша нажата
-- тут left или что нужно
if i == 1 then
log("Нажата левая кнопка мыши")
end
if i == 2 then
log("Нажата правая кнопка мыши")
end
wait (10)
state=GetKeyState(mouse1[i])
end
end
end
if i == 1 then
log("Нажата левая кнопка мыши")
end
--lua
...
..........
--lua
do
local back = package.path
package.path = "luaPlugins\\winapi\\?.lua;"..package.path
setfenv(1, require'winapi')
require[[winapi.keyboard]]
package.path = back
end
local button = {
{"f1",0.3}, --Интервал в секундах
{"f2",0.4},
{"f3",0.5}
}
local button2 = {0x31, 0x52, 0x33, 0x43, 0x56, 0x35, 0x35, 0x35, 0x5A, 0x42, 0x32, 0x46, 0x58, 0x48, 0x47, 0xC0, 0x34}
local mouse1= {1, 2}
for i = 1, #button do
button[i][3] = os.clock() + button[i][2]
end
local pause = function()
for i = 1, #button2 do -- проверяем не нажата ли клавиша
local state=GetKeyState(button2[i])
while state do -- ждать пока клавиша нажата
log("Нажата клавиша с кодом: " .. button2[i])
send217('{' .. button2[i] .. '}')
wait (10)
state=GetKeyState(button2[i])
end
end
end
local mouse_pause = function()
for i = 1, #mouse1 do -- проверяем не нажата ли клавиша мыши
local state=GetKeyState(mouse1[i])
while state do -- ждать пока клавиша нажата
log("Нажата клавиша с кодом: " .. mouse1[i])
// тут left или что нужно
wait (10)
state=GetKeyState(mouse1[i])
end
end
end
local main = function(button)
for i = 1, #button do
pause() -- вызов функции, которая проверяет нажатие клавиш клавиатуры
mouse_pause() -- вызов функции, которая проверяет нажатие клавиш мыши
if button[i][3] < os.clock() then
send217(button[i][1])
button[i][3] = os.clock() + button[i][2]
end
end
end
while 1 do
main(button)
wait (1)
end
local mouse1= {1, 2, 4}
local mouse1= {1, 2, 4}
while 1 do
wait (13)
local state, toggle = GetKeyState(0x14)
local stateLKM = GetKeyState(0x01)
local statePKM = GetKeyState(0x02)
local state4 = GetKeyState(0x04)
if toggle and stateLKM then
wait (1)
local x, y = mouse_pos ()
left (x, y) -- клик
else
if toggle and statePKM then
wait (1)
local x, y = mouse_pos ()
right (x, y) -- клик
else
if toggle and state4 then
wait (1)
local x, y = mouse_pos ()
middle (x, y)
else
end
end
end
end
local mouse1 = {1, 2, 4}
local mouse_pause = function()
local state1, toggle = GetKeyState(0x90)
for i = 1, #mouse1 do
local state2=GetKeyState(mouse1[i])
while state2 do
local state1, toggle = GetKeyState(0x90) -- (Num_Lock)
if toggle then
log("Нажата клавиша с кодом: " .. mouse1[i])
local x, y = mouse_pos ()
if i == 1 then
local x, y = mouse_pos ()
left(mouse_pos(('{' .. mouse1[i] .. '}')))
end
if i == 2 then
local x, y = mouse_pos ()
right(mouse_pos(('{' .. mouse1[i] .. '}')))
end
if i == 4 then
local x, y = mouse_pos ()
middle(mouse_pos(('{' .. mouse1[i] .. '}')))
end
end
wait (10)
state2=GetKeyState(mouse1[i])
end
end
end
local mouse1= {1, 2, 4}
Русская версия Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)