WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 11-01-2011, 10:19 AM
nabrahamson nabrahamson is offline
Member
 
Join Date: Sep 2011
Posts: 36
Detecting Window Focus

Is there a native way in Vizard to detect if a windowed application has focus? I am trying to prevent user input events from being passed through to other windows applications, and I would like to have a method to tell the computer to stop listening to the input device when the Vizard window doesn't have focus.
Reply With Quote
  #2  
Old 11-01-2011, 10:46 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
You can use the win32gui.GetForegroundWindow function to get a handle to the active window. You can check this handle against the Vizard window handle to determine whether Vizard has focus:
Code:
import win32gui

def VizardHasFocus():
	return win32gui.GetForegroundWindow() == viz.window.getHandle()

if VizardHasFocus():
	print 'Vizard has focus'
else:
	print 'Vizard does not have focus'
Reply With Quote
  #3  
Old 11-01-2011, 11:45 AM
nabrahamson nabrahamson is offline
Member
 
Join Date: Sep 2011
Posts: 36
Thank you. I will give that a try.
Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Limit vizinfo message to only one window? hotspur1 Vizard 1 05-07-2010 02:13 PM
tkinter window focus John P Vizard 4 08-31-2009 05:51 AM
Full screen window changes to small window tacbob Vizard 1 04-04-2007 09:30 AM
How to get the window handle Joran Vizard 1 06-16-2006 11:01 AM
The error window that couldn't FlyingWren Vizard 2 12-02-2003 08:23 AM


All times are GMT -7. The time now is 10:26 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC