Re: Application focus ?
thanks a lot guys! I'll probably use Jon's code. 2014-07-22 18:11 GMT-03:00 Jon Swindells jon_swinde...@fastmail.fm: if si's built in events arent' cutting the proverbial mustard i'd go with simple win32 funcs. simplest possible ones i could think of: import win32gui # callback def enum_handler(hwnd, lParam): wt = win32gui.GetWindowText(hwnd) # if soft is minimized to task bar if win32gui.IsIconic(hwnd) and 'Autodesk Softimage' in wt: #if your timing is tight, probably better to use this callback # to store the pid, hwnd for future access #- _, pid = win32process.GetWindowThreadProcessId(hwnd) # although you'd still need to enum the pid-hwnd. dunno without testing print 'soft is minimized, abandon all hope!' win32gui.EnumWindows(enum_handler, None) # OR - def softimage_has_focus(): ## script editor will count as focused. probably no need to call # GetParent if running in a plug # - par_hwnd = win32gui.GetForegroundWindow() par_hwnd = win32gui.GetParent(win32gui.GetForegroundWindow()) if 'Autodesk Softimage' in win32gui.GetWindowText(par_hwnd): return True return False if softimage_has_focus(): print 'hullo Soft' -- -- Jon Swindells jon_swinde...@fastmail.fm On Tue, Jul 22, 2014, at 11:58 PM, Matt Lind wrote: The View object has an siViewState that can be checked if you can find a way to tuck your event into a PPG of some sort. Otherwise, you’re probably looking at something in the WSH (Windows Script Host) API which should be accessible from inside any scripted code. Matt *From:* softimage-boun...@listproc.autodesk.com [mailto: softimage-boun...@listproc.autodesk.com] *On Behalf Of *Fabricio Chamon *Sent:* Tuesday, July 22, 2014 5:53 AM *To:* softimage@listproc.autodesk.com *Subject:* Application focus ? Hey experts, is it possible to know wether xsi app has focus ? I have a timer script that fires up some alerts, but want to run only if softimage is not minimized. I took a look at Application object and didn't find anything related.. thanks
Application focus ?
Hey experts, is it possible to know wether xsi app has focus ? I have a timer script that fires up some alerts, but want to run only if softimage is not minimized. I took a look at Application object and didn't find anything related.. thanks
Re: Application focus ?
There are some events: siOnActivate, siOnMinimize, and siOnMaximize On Tue, Jul 22, 2014 at 8:53 AM, Fabricio Chamon xsiml...@gmail.com wrote: Hey experts, is it possible to know wether xsi app has focus ? I have a timer script that fires up some alerts, but want to run only if softimage is not minimized. I took a look at Application object and didn't find anything related.. thanks
Re: Application focus ?
Hi, would it (ideally) need to also recognize if it's inactive under other windows? or just when minimized ? On 07/22/14 9:29, Stephen Blair wrote: There are some events: siOnActivate, siOnMinimize, and siOnMaximize On Tue, Jul 22, 2014 at 8:53 AM, Fabricio Chamon xsiml...@gmail.com wrote: Hey experts, is it possible to know wether xsi app has focus ? I have a timer script that fires up some alerts, but want to run only if softimage is not minimized. I took a look at Application object and didn't find anything related.. thanks
RE: Application focus ?
The View object has an siViewState that can be checked if you can find a way to tuck your event into a PPG of some sort. Otherwise, you’re probably looking at something in the WSH (Windows Script Host) API which should be accessible from inside any scripted code. Matt From: softimage-boun...@listproc.autodesk.com [mailto:softimage-boun...@listproc.autodesk.com] On Behalf Of Fabricio Chamon Sent: Tuesday, July 22, 2014 5:53 AM To: softimage@listproc.autodesk.com Subject: Application focus ? Hey experts, is it possible to know wether xsi app has focus ? I have a timer script that fires up some alerts, but want to run only if softimage is not minimized. I took a look at Application object and didn't find anything related.. thanks
Re: Application focus ?
if si's built in events arent' cutting the proverbial mustard i'd go with simple win32 funcs. simplest possible ones i could think of: import win32gui # callback def enum_handler(hwnd, lParam): wt = win32gui.GetWindowText(hwnd) # if soft is minimized to task bar if win32gui.IsIconic(hwnd) and 'Autodesk Softimage' in wt: #if your timing is tight, probably better to use this callback # to store the pid, hwnd for future access #- _, pid = win32process.GetWindowThreadProcessId(hwnd) # although you'd still need to enum the pid-hwnd. dunno without testing print 'soft is minimized, abandon all hope!' win32gui.EnumWindows(enum_handler, None) # OR - def softimage_has_focus(): ## script editor will count as focused. probably no need to call # GetParent if running in a plug # - par_hwnd = win32gui.GetForegroundWindow() par_hwnd = win32gui.GetParent(win32gui.GetForegroundWindow()) if 'Autodesk Softimage' in win32gui.GetWindowText(par_hwnd): return True return False if softimage_has_focus(): print 'hullo Soft' --- --- -- Jon Swindells jon_swinde...@fastmail.fm On Tue, Jul 22, 2014, at 11:58 PM, Matt Lind wrote: The View object has an siViewState that can be checked if you can find a way to tuck your event into a PPG of some sort. Otherwise, you’re probably looking at something in the WSH (Windows Script Host) API which should be accessible from inside any scripted code. Matt From: softimage-boun...@listproc.autodesk.com [mailto:softimage-boun...@listproc.autodesk.com] On Behalf Of Fabricio Chamon Sent: Tuesday, July 22, 2014 5:53 AM To: softimage@listproc.autodesk.com Subject: Application focus ? Hey experts, is it possible to know wether xsi app has focus ? I have a timer script that fires up some alerts, but want to run only if softimage is not minimized. I took a look at Application object and didn't find anything related.. thanks