This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Left's profile picture

Keystrokes and Shell

Started by Left, 25 March 2013 - 03:41 PM
Left #1
Posted 25 March 2013 - 04:41 PM
Hi guys. Have to be on mobile again. Stupid internet company. Any way I am make a side program for cunix and it sends keystrokes across rednet but I can't get it to work. What I have coded is two functions, one to run shell and the other to detect and send the keys. I used parallel API to run them at the same time. Could you maybe give me a snippet of this. Thanks. Btw cunix has maybe a few more weeks of dev. I have finished the wireless network and security of it.
theoriginalbit #2
Posted 25 March 2013 - 04:45 PM

function runCunix()
  -- do your stuff here
end

function runKeylogger()
  local keysPressed = {}
  while true do
	local e, k = os.pullEventRaw('key')
	table.insert(keysPressed, k)
	if #keysPressed > 10 then
	  local stringToSend = textutils.serialize( keysPressed )
	  -- send it here via what ever method you choose
	  keysPressed = {}
	end
  end
end

parallel.waitForAll( runCunix, runKeylogger )

now you might ask why I'm using a table and only sending after 10 key presses… the answer is simple, to reduce message spamming from causing lag on the client and server.
Left #3
Posted 25 March 2013 - 04:59 PM
Thanks. I am making this because my os will be a backtrack like os