def reenable_close_window():
    if pywin32_installed:
        try: # reenable console windows close button (useful if called command line or batch file)
            hwnd = win32console.GetConsoleWindow()
            hMenu = win32gui.GetSystemMenu(hwnd, False)
            win32gui.EnableMenuItem(hMenu, win32con.SC_CLOSE, win32con.MF_ENABLED)        
        except: pass #silent
Beispiel #2
0
def lock_window(windowlock):
    if Pywin and not autotest and not windowlock:
       windowlock=True
       hwnd = win32console.GetConsoleWindow()                
       if hwnd:
           hMenu = win32gui.GetSystemMenu(hwnd, 0)
           if hMenu:
               win32gui.DeleteMenu(hMenu, win32con.SC_CLOSE, win32con.MF_BYCOMMAND)
    return windowlock
Beispiel #3
0
    def AddSystemReloadMenu(wnd):
        hSysMenu = win32gui.GetSystemMenu(wnd.GetHandle(), False)
        if not hSysMenu:
            return False
        win32gui.InsertMenu(hSysMenu, 0, win32con.MF_BYPOSITION | win32con.MF_SEPARATOR, 0, '');
        win32gui.InsertMenu(hSysMenu, 0, win32con.MF_BYPOSITION, SYS_MENU_RELOAD_MODULES, 'Reload Modules')

        def HandleSystemMenu(wnd, msg, wparam, lparam):
            wnd.__class__._reload_modules()
            return False

        AddCallback(HandleSystemMenu, wnd, win32con.WM_SYSCOMMAND, SYS_MENU_RELOAD_MODULES, None)
        return True
Beispiel #4
0
def exit(code):
    # cleanup
    try:
        shutil.rmtree(tempdir)
    except:
        pass  # silent
    if pywin32_installed:
        try:  # reenable console windows close button (useful if called command line or batch file)
            hwnd = win32console.GetConsoleWindow()
            hMenu = win32gui.GetSystemMenu(hwnd, False)
            win32gui.EnableMenuItem(hMenu, win32con.SC_CLOSE,
                                    win32con.MF_ENABLED)
        except:
            pass  #silent
    sys.exit(code)
def EnableTitlebarIcon(hWnd, icon=0, enable=True):
    """
	Greys out titlebar icons
	
	icon - is:
		0 - close icon
		1 - maximize icon
		2 - minimize icon
	
	NOTE: Only works with windows
	NOTE: Only works while mainloop() is running 
		therefore immediately before mainloop() you may want to:
			root.after(50,EnableTitlebarIcon,root.winfo_id(),enable)
	"""
    import win32gui
    SC_MINIMIZE = 0xF020
    SC_MAXIMIZE = 0xF030
    SC_CLOSE = 0xF060
    MF_ENABLED = 0x00000000
    MF_GRAYED = 0x00000001
    MF_DISABLED = 0x00000002
    control = [SC_CLOSE, SC_MAXIMIZE, SC_MINIMIZE][icon]
    while True:
        hMenu = win32gui.GetSystemMenu(hWnd, 0)
        if hMenu != 0:
            break
        parent = win32gui.GetParent(hWnd)
        if parent == 0:
            msg = [
                'ERR: Top-level parent has no system menu.', '',
                'NOTE: Only works while mainloop() is running',
                '	therefore immediately before mainloop() you may want to:',
                '		root.after(50,EnableTitlebarCloseIcon,root.winfo_id(),enable)'
            ]
            raise Exception('\n'.join(msg))
        hWnd = parent
    if enable:
        #print 'enabling',hWnd,hMenu
        win32gui.EnableMenuItem(hMenu, control, MF_ENABLED)
    else:
        #print 'disabling',hWnd,hMenu
        win32gui.EnableMenuItem(hMenu, control, MF_GRAYED)
Beispiel #6
0
python_version = str(sys.version_info[0]) + '.' + str(
    sys.version_info[1]) + '.' + str(sys.version_info[2])
# sys.platform = [linux2, win32, cygwin, darwin, os2, os2emx, riscos, atheos, freebsd7, freebsd8]
if sys.platform == "win32":
    os.system("title " + Program_name)
    try:
        resourcedir = sys._MEIPASS + slash  # when on PyInstaller
    except:  # in plain python this is where the script was run from
        resourcedir = os.path.abspath(os.path.dirname(sys.argv[0])) + slash
    command = 'attrib'
    parameters = ' +H "' + tempdir[:len(tempdir) - 1] + '"'
    run(command, parameters)  # hide tempdir
    if pywin32_installed:
        try:  # disable console windows close button (substitutes catch shell exit under linux)
            hwnd = win32console.GetConsoleWindow()
            hMenu = win32gui.GetSystemMenu(hwnd, False)
            win32gui.EnableMenuItem(hMenu, win32con.SC_CLOSE,
                                    win32con.MF_GRAYED)
        except:
            pass  #silent
else:
    resourcedir = os.path.abspath(os.path.dirname(sys.argv[0])) + slash
if TK_installed:
    TKwindows = tk.Tk()
    TKwindows.withdraw()  #hiding tkinter window
    TKwindows.update()
    # the following tries to disable showing hidden files/folders under linux
    try:
        TKwindows.tk.call('tk_getOpenFile', '-foobarz')
    except:
        pass
Beispiel #7
0
def throwError(msg,exitFlag = True):
  print(msg)
  print("Press any key to terminate ...")
  msvcrt.getch()
  
  if(exitFlag):
    quit()

###########################################################################
# DISABLE WINDOW CLOSE OPTION                                             #
###########################################################################
try:
  hwnd = win32console.GetConsoleWindow()
  if hwnd:
    hMenu = win32gui.GetSystemMenu(hwnd, 0)
    if hMenu:
        win32gui.DeleteMenu(hMenu, win32con.SC_CLOSE, win32con.MF_BYCOMMAND)
except Exception:
  pass
###########################################################################       

if(len(sys.argv) < 2):
    throwError(msg="Script ID is not passed",exitFlag=True)
    

script_id = sys.argv[1]

query = DB_Query('config\db_py_config.json')

myresult = query.getScriptInDetails(script_id)
    parent = win32gui.GetParent( hwnd )
    active = win32gui.GetActiveWindow()
    print("window placement: ", win32gui.GetWindowPlacement(hwnd))
    childwindow = win32gui.ChildWindowFromPoint(hwnd, win32gui.GetCursorPos())
    print( "capture : ", win32gui.GetCapture())
    window = win32gui.GetWindow(hwnd, 1)
    win32gui.SendMessage( hwnd, 1, None, None)
    desktop = win32gui.GetDesktopWindow()
    menu = win32gui.GetMenu(hwnd)
    cursorinfo = win32gui.GetCursorInfo()
    foreground = win32gui.GetForegroundWindow()
    hdc = win32gui.GetDC(hwnd)
    #win32gui.PolylineTo(hdc, ((w0, h0), (w1, h0), (w1, h1), (w0, h1), (w0,h0)))
    obj = win32gui.GetCurrentObject(hdc, win32con.OBJ_BITMAP)
    stockobj = win32gui.GetStockObject(obj)
    sysmenu  = win32gui.GetSystemMenu(hwnd, 1)





    print("1. desktop     : ", desktop)
    print("2. window      : ", window)
    print("3. hwnd        : ", hwnd )
    print("4. parent      : ", parent)
    print("5. child       : ", childwindow)
    print("6. active      : ", active)
    print("7. focus       : ", focus)
    print("8. getMenu     : ", menu)
    print("9. CursorInfo  : ", cursorinfo)
    print("10. Foreground : ", foreground)