Ok I have an interesting thing I have noticed with the virtual mouse.
I will post all the code I am using at the moment but the thing I have noticed is that 1 virtual mouse press works fine but another seems to move the physical mouse which I can't explain. So one of them the mouse is actually moved to that position and stays there, even if another window has focus it moves the physical mouse to that location.
This part the virtual works fine
Code: Select all
mouse.setVirtualPosition(win, clickw, clickh)
mouse.virtualPress(win, key.VK_LMOUSE,true)
This part seems to move the physical mouse, the only real difference I see between the 2 is the keyboard hold in the one that seems to move the physical mouse.
Code: Select all
if walkhold > 0 then
keyboard.virtualHold(win, key.VK_W)
else
keyboard.virtualRelease(win, key.VK_W)
walk = false
mouse.setVirtualPosition(win, ww/2, wh/2)
mouse.virtualPress(win, key.VK_LMOUSE,true)
end
Code: Select all
local proc, timeLeft, repairtime, walktime, gaptime, step, walkhold, wintable
local go = false
local mine = false
local wx, wy, ww, wh = 0,0,0,0
local win
local waittime = 5
local repairwait = 36000
local walkwait = 60
local logouttime = (60*60*4)
local targetWindowClass = "LWJGL"
local targetWindowName = "*"
local clickw, clickh = 50,50
local procid
function searchForWindow()
--win = window.find(targetWindowName, targetWindowClass)
wintable = window.findList(targetWindowName, targetWindowClass)
for i = 1, #wintable do
if string.find(wintable[i].name, "dle") then
win = wintable[i].hwnd
printf(i.."\n")
end
end
procid = process.findByWindow(win)
proc = process.open(procid)
table.print(wintable)
if( win ) then
printf("window found: 0x%X\n", win)
printf("You can now walk away from the computer!\n")
--printf("0x%x", process.getModuleAddress(procid, "OpenAL64.dll"))
end
end
function getStam()
return process.read(proc, "float", 0x2FDD0464) or 0
end
function macro.init()
repairtime = repairwait
timeLeft = 0
repairtime = 0
walktime = 0
gaptime = 0
walkhold = 0
logtime = 0
win = window.find(targetWindowName, targetWindowClass)
window.setTitle(window.getAppHwnd(),"anti idle")
searchForWindow()
if( not win ) then
printf("You need to have the game running. Start it, focus the window, and press the END key on your keyboard.\n");
end
end
function macro.main(dt)
timeLeft = timeLeft - dt
repairtime = repairtime - dt
walktime = walktime - dt
gaptime = gaptime - dt
walkhold = walkhold - dt
logouttime = logouttime - dt
if go then
if win then
if 0 > logouttime then
--os.execute("TASKKILL /PID " .. procid .. " /F");
--os.execute("\"%windir%\\system32\\shutdown.exe -s -t 30\" ")
--error("Exiting: Auto-logout", 0)
end
if walk then
if walkhold > 0 then
keyboard.virtualHold(win, key.VK_W)
else
keyboard.virtualRelease(win, key.VK_W)
walk = false
mouse.setVirtualPosition(win, ww/2, wh/2)
mouse.virtualPress(win, key.VK_LMOUSE,true)
end
else
if gaptime < 0 and mine and walktime < 0 then
-- move forward
printf("moving forward\n")
walktime = walkwait
gaptime = 2
walkhold = 1
walk = true
end
if gaptime < 0 and timeLeft < 0 then
if 130 > getStam() then
timeLeft = 4
else
mouse.setVirtualPosition(win, clickw, clickh)
mouse.virtualPress(win, key.VK_LMOUSE,true)
timeLeft = waittime
end
gaptime = 1
end
end
end
end
return true;
end
function macro.event(e, data1, data2, data3)
if( e == "keypressed" ) and win == window.getFocusHwnd() then
if( data1 == key.VK_END ) then
window.setTitle(window.getAppHwnd(),"Paused G")
printf("stopping\n")
go = false
end
if( data1 == key.VK_DELETE ) then
window.setTitle(window.getAppHwnd(),"Going G")
printf("going\n")
timeLeft = 0
go = true
end
if( data1 == key.VK_NUMPAD1 ) then
wx, wy, ww, wh = window.getClientRect(win)
local x,y = mouse.getPosition()
clickw=x-wx
clickh=y-wy
end
if( data1 == key.VK_NUMPAD2 ) then
wx, wy, ww, wh = window.getClientRect(win)
local x,y = mouse.getPosition()
repairw=x-wx
repairh=y-wy
end
if( data1 == key.VK_NUMPAD3 ) then
walktime = walkwait
mine = not mine
if mine then printf("mining\n") else printf("not mining\n") end
end
end
end