第 1 卷第 1 章:1–9 年
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
--@ module = true
|
||||
-- 在窗口坐标 (x, y) 模拟一次左键点击。用法:dfhack-run "dfannals/click 160 40"
|
||||
-- 方式与 DFHack 自带测试工具一致:设置鼠标位置后 simulateInput('_MOUSE_L')。
|
||||
local gui = require('gui')
|
||||
|
||||
local args = {...}
|
||||
local x, y = tonumber(args[1]), tonumber(args[2])
|
||||
if not x or not y then
|
||||
print('用法: dfannals/click <x> <y>')
|
||||
return
|
||||
end
|
||||
|
||||
df.global.gps.mouse_x = math.floor(x)
|
||||
df.global.gps.precise_mouse_x = math.floor(x) * df.global.gps.tile_pixel_x
|
||||
df.global.gps.mouse_y = math.floor(y)
|
||||
df.global.gps.precise_mouse_y = math.floor(y) * df.global.gps.tile_pixel_y
|
||||
|
||||
local scr = dfhack.gui.getCurViewscreen()
|
||||
gui.simulateInput(scr, '_MOUSE_L')
|
||||
|
||||
local f = io.open('dfannals-act.log', 'a')
|
||||
if f then
|
||||
f:write(string.format('%s\tclick %d,%d\tfocus=%s\n', os.date('%H:%M:%S'), x, y,
|
||||
table.concat(dfhack.gui.getCurFocus(), '/')))
|
||||
f:close()
|
||||
end
|
||||
|
||||
print(string.format('clicked %d,%d', x, y))
|
||||
Reference in New Issue
Block a user