NameError when running Python code in shell -


i looking run function get_cords() in shell current mouse position, however, error saying

traceback (most recent call last):   file "<input>", line 1, in <module> nameerror: name 'get_cords' not defined 

here code

import imagegrab import os import time import win32api, win32con  x_pad = 464 y_pad = 366   def screengrab():     box = (x_pad + 1, y_pad + 1, x_pad + 640, y_pad + 481)     im = imagegrab.grab(box)     im.save(os.getcwd() + '\\full_snap__' + str(int(time.time())) + '.png', 'png')   def main():     pass   if __name__ == '__main__':     main()   def leftclick():     win32api.mouse_event(win32con.mouseeventf_leftdown, 0, 0)     time.sleep(.1)     win32api.mouse_event(win32con.mouseeventf_leftup, 0, 0)     print "click."   def leftdown():     win32api.mouse_event(win32con.mouseeventf_leftdown, 0, 0)     time.sleep(.1)     print "left down"   def leftup():     win32api.mouse_event(win32con.mouseeventf_leftup, 0, 0)     time.sleep(.1)     print "left release"   def mousepos(cord):     win32api.setcursorpos(x_pad + cord[0], y_pad + cord[1])   def get_cords():     x, y = win32api.getcursorpos()     x = x - x_pad     y = y - y_pad     print x, y 

yes, running shell within project folder. running python 2.7.13 , use pycharm.

not sure if answer ever relevant else, worked me following:

>>> import file_name >>> file_name.function_name() 

and voila!


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -