Creating a window from PyHandle? Possible?
Fadly Tabrani
no at spam.net
Sun Oct 10 04:27:32 EDT 2004
Hi guys,
This is the first time I'm posting to the newsgroup, hope you can help out.
I'm writing a module to interface with the task scheduler in windows
using PyWin32. Everything has been great so far but I'm stuck on
displaying the propertys page of a task. Here's the code:
import pythoncom
import win32api
from win32com.taskscheduler import taskscheduler
import win32ui
task_scheduler = pythoncom.CoCreateInstance\
(taskscheduler.CLSID_CTaskScheduler,
None, pythoncom.CLSCTX_INPROC_SERVER,
taskscheduler.IID_ITaskScheduler)
def show_schedule_page(task_name):
TASKPAGE_TASK = 0,
TASKPAGE_SCHEDULE = 1,
TASKPAGE_SETTINGS = 2
try:
task = task_scheduler.Activate(task_name)
except pythoncom.com_error, e:
print 'Task name not found...'
return
# ** This returns a PyHandle
handle = task.QueryInterface(taskscheduler.IID_IProvideTaskPage).\
GetPage(1, True)
# ** Can't create a window with it using win32ui, returns error
try:
win32ui.CreateWindowFromHandle(handle)
except win32ui.error, e:
print e
# ** Can't add it to a property sheet, return an error
property_sheet = win32ui.CreatePropertySheet('Task Schedule')
try:
property_sheet.AddPage(handle)
except (win32ui.error, TypeError), e:
print e
show_schedule_page('task1')
Any ideas on how to do it? The task schduler api reference is at
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/taskschd/taskschd/task_scheduler_start_page.asp
I'm pretty new at this, is there anything that I've missed out?
Cheers,
Fadly Tabrani
python loves me loves python
More information about the Python-list
mailing list