|
调用 API 移动鼠标以及输出按键信息
本帖最后由 AndroidOL 于 2014-10-12 15:30 编辑
- flag = 0
- --ClearLog()
- --[[
- function getScanCode()
- OutputLogMessage("Call Function.\n")
- PressAndReleaseMouseButton(1)
- end
- ]]--
- function OnEvent(event, arg)
- --getScanCode()
- if (flag > 10) then
- ClearLog()
- flag = 0
- else
- flag = flag + 1
- end
- flag_MKey = GetMKeyState()
- if (event == "M_PRESSED") then
- OutputLogMessage("M%d-Key was pressed. Event time: %s!\n", arg, GetDate())
- flag_MKey = arg
- elseif (event == "M_RELEASED") then
- OutputLogMessage("M%d-Key was released. Event time: %s!\n", arg, GetDate())
- flag_MKey = arg
- elseif (flag_MKey == 1) then
- if (event == "G_PRESSED") then
- OutputLogMessage("G%d-Key was pressed. Event time: %s!\n", arg, GetDate())
- PressKey(1 + arg)
- end
- if (event == "G_RELEASED") then
- OutputLogMessage("G%d-Key was released. Event time: %s!\n", arg, GetDate())
- ReleaseKey(1 + arg)
- end
- elseif (flag_MKey == 2) then
- if (arg < 4) then
- if (event == "G_PRESSED") then
- OutputLogMessage("G%d-Key was pressed. Event time: %s!\n", arg, GetDate())
- PressKey(7 + arg)
- end
- if (event == "G_RELEASED") then
- OutputLogMessage("G%d-Key was released. Event time: %s!\n", arg, GetDate())
- ReleaseKey(7 + arg)
- end
- elseif (arg == 4) then
- if (event == "G_PRESSED") then
- OutputLogMessage("G%d-Key was pressed. Event time: %s!\n", arg, GetDate())
- PressKey(2)
- PressKey(11)
- end
- if (event == "G_RELEASED") then
- OutputLogMessage("G%d-Key was released. Event time: %s!\n", arg, GetDate())
- ReleaseKey(2)
- ReleaseKey(11)
- end
- elseif (arg == 5) then
- if (event == "G_PRESSED") then
- OutputLogMessage("G%d-Key was pressed. Event time: %s!\n", arg, GetDate())
- PressKey(2)
- ReleaseKey(2)
- PressKey(1 + arg - 4)
- end
- if (event == "G_RELEASED") then
- OutputLogMessage("G%d-Key was released. Event time: %s!\n", arg, GetDate())
- --ReleaseKey(2)
- ReleaseKey(1 + arg - 4)
- end
- else
- if (event == "G_PRESSED") then
- OutputLogMessage("G%d-Key was pressed. Event time: %s!\n", arg, GetDate())
- PressKey(2)
- PressKey(1 + arg - 4)
- end
- if (event == "G_RELEASED") then
- OutputLogMessage("G%d-Key was released. Event time: %s!\n", arg, GetDate())
- ReleaseKey(2)
- ReleaseKey(1 + arg - 4)
- end
- end
- elseif (flag_MKey == 3) then
- if (event == "G_PRESSED") then
- OutputLogMessage("G%d-Key was pressed. Event time: %s!\n", arg, GetDate())
- PressKey(2)
- PressKey(3 + arg)
- end
- if (event == "G_RELEASED") then
- OutputLogMessage("G%d-Key was released. Event time: %s!\n", arg, GetDate())
- ReleaseKey(2)
- ReleaseKey(3 + arg)
- end
- else
- OutputLogMessage("Bad Input!")
- end
- --[[
- if (arg == 1) then
- MoveMouseToVirtual(0, 0)
- elseif (arg == 2) then
- MoveMouseToVirtual(65535, 0)
- elseif (arg == 3) then
- MoveMouseToVirtual(0, 65535)
- elseif (arg == 4) then
- MoveMouseToVirtual(65535, 65535)
- else
- MoveMouseToVirtual(65535 / 2, 65535 / 2)
- end
- ]]--
- end
复制代码 |
|