Thursday, January 31, 2008

PitHole: softgrid - WORKINGDIR

Never put the directory under Quotations as it will always return an error message "Invalid directory".

Softgrid FAQs : When it is safe to remove the WORKINGDIR Tag

It might be safe to remove the workingdir tag only if


  1. When launching the app you are getting Invalid dir error.


Wednesday, January 30, 2008

Softgrid FAQs : Blank Icons on published Applicataions.

I have seen this due to two reasons.


  1. While capture the icons were not captured properly:



    1. Resolution: Extract the icons from the executable and then use it.





  2. The icons does not have proper icons size 16x16




    1. Resolution: Extract the icons from the executable and then use it






Note: One can use iconsucker, IconSnatcher or similar tool. Always remember to save the icon in 16x16 size and do not forget to update the OSD files to point to the new icons.

Sunday, January 27, 2008

Get Processes along with parameters

Click Start, Run and type CMD

Type the command given below:

WMIC /OUTPUT:C:\ProcessList.txt PROCESS get Caption,Commandline,Processid


or


WMIC /OUTPUT:C:\ProcessList.txt path win32_process get Caption,Processid,Commandline

Saturday, January 19, 2008

Adding TextNode in XML using python

OSElements = document.getElementsByTagName("ABSTRACT")
for element in OSElements:
print element.nodeValue
new = doc.createTextNode("TESTING")
element.appendChild(new)

Saturday, January 12, 2008

Setting ColumnWidth of wx.ListView control in python

# Get the size of listView Control
w = self.lvMountPoint.GetSize()
# Set the ColumnWidth
self.lvMountPoint.SetColumnWidth(0,w[0] * 0.81)
self.lvMountPoint.SetColumnWidth(1,w[0] * 0.19)

Thursday, December 27, 2007

Get Text from multi column ListBox in Python


y = self.listCtrl.GetItem(a,n)
txt = y.GetText()


where  a =  Row Number n = Column Number

Tuesday, December 25, 2007

Few TK form tricks in Python.

1. Disable max button:
root.overrideredirect(0)

2. Remove all the decorations :
root.overrideredirect(1)

3. Disable Resize:
root.resizable(0,0)

Sunday, December 23, 2007

Adding file type association using vbScript

fext = "fcz"
prgid = "FCZ File"
des = "FCZ File"
extanm = "c:\Program files\TestApps\AppStart.exe"
Set o = CreateObject("wscript.shell")
o.regwrite "HKCR\." + fext + "\" , prgid ', "REG_SZ"
o.regwrite "HKCR\" + prgid + "\", des ', "REG_SZ"
'o.regwrite "HKCR\" + prgid + "\DefaultIcon\", extico, "REG_SZ"
o.regwrite "HKCR\" + prgid + "\Shell\","Open"
o.regwrite "HKCR\" + prgid + "\Shell\Open\Command\", """" + extanm + """ ""%1""", "REG_SZ"

Playing with Registry using Python.,

def regReadValue( regKey, subKey, name ):
#print regKey
aReg = ConnectRegistry(None,regKey)
aKey = OpenKey(aReg, subKey)
index = 0
data = []
while 1:
try:
regName = EnumValue(aKey, index)
if name == regName[0]:
data = regName[1:]
print data
return data
except:
break
index = index + 1
return data

def regRead( regKey, subKey):
#print regKey
aReg = ConnectRegistry(None,regKey)
aKey = OpenKey(aReg, subKey) # r'SOFTWARE\Microsoft\Windows\CurrentVersion\Run')
index = 0
data = []
while 1:
try:
print("Enumkey =" + subKey + "\\" + EnumKey(aKey, index))
data.append( subKey + "\\" + EnumKey(aKey, index))
except:
break
index = index + 1
return data

def regWrite(regKey, subKey, regValue, regData, regType):
aReg = ConnectRegistry(None,regKey)
print subKey
aKey = CreateKey(aReg, subKey) #, 0, KE)
try:
SetValueEx(aKey,regValue,0, regType, regData)
except EnvironmentError:
print "Encountered problems writing into the Registry..."
CloseKey(aKey)
CloseKey(aReg)

def regDelete(regKey, subKey):
#aReg = ConnectRegistry(none,regKey)
reg = regRead(regKey, subKey)
for a in reg:
regDelete(regKey,a)
print a
DeleteKey(regKey, subKey)

Monday, December 17, 2007

Populating Two column in Pascal

Following code can populate them:

with listview1.Items.Add do
begin
caption := 'first Column' ;
SubItems.Add('Second Column');
end ;

Thursday, December 13, 2007

Read and Set CheckBoxes in PythonWin using win32...

# A demo of the win32rcparser module and using win32gui

import win32gui
import win32api
import win32con
import win32rcparser
import commctrl
import sys, os
import win32ui

# We use the .rc file in our 'test' directory.
try:
__file__
except NameError: # pre 2.3
__file__ = sys.argv[0]

this_dir = os.path.abspath(os.path.dirname(__file__))
g_rcname = os.path.abspath(
os.path.join( this_dir, "prefEditing.RC"))

if not os.path.isfile(g_rcname):
raise RuntimeError, "Can't locate resource file (should be at '%s')" % (g_rcname,)

class DemoWindow:
def __init__(self, dlg_template):
self.dlg_template = dlg_template

def CreateWindow(self):
self._DoCreate(win32gui.CreateDialogIndirect)

def DoModal(self):
return self._DoCreate(win32gui.DialogBoxIndirect)

def _DoCreate(self, fn):
message_map = {
win32con.WM_INITDIALOG: self.OnInitDialog,
win32con.WM_CLOSE: self.OnClose,
win32con.WM_DESTROY: self.OnDestroy,
win32con.WM_COMMAND: self.OnCommand,
}
return fn(0, self.dlg_template, 0, message_map)

def OnInitDialog(self, hwnd, msg, wparam, lparam):
self.hwnd = hwnd
# centre the dialog
desktop = win32gui.GetDesktopWindow()
l,t,r,b = win32gui.GetWindowRect(self.hwnd)
dt_l, dt_t, dt_r, dt_b = win32gui.GetWindowRect(desktop)
centre_x, centre_y = win32gui.ClientToScreen( desktop, ( (dt_r-dt_l)/2, (dt_b-dt_t)/2) )
win32gui.MoveWindow(hwnd, centre_x-(r/2), centre_y-(b/2), r-l, b-t, 0)

def getCheckBoxValue(self, hwnd, cbid):
## Gets the Value of the CheckBox #
b = win32gui.GetDlgItem(hwnd, cbid)
val = win32gui.SendMessage(hwnd, win32con.BM_GETCHECK, 0, 0) & win32con.BST_CHECKED
return val

def setCheckBoxValue(self, hwnd, cbid, val):
## Gets the Value of the CheckBox #
b = win32gui.GetDlgItem(hwnd, cbid)
win32gui.SendMessage(b,win32con.BM_SETCHECK,val,0)

def OnCommand(self, hwnd, msg, wparam, lparam):
# Needed to make OK/Cancel work - no other controls are handled.
id = win32api.LOWORD(wparam)
if id in [win32con.IDOK, win32con.IDCANCEL]:
win32gui.EndDialog(hwnd, id)
print id
a = win32gui.GetDesktopWindow()
# This returns the hwnd for the control
b = win32gui.GetDlgItem(hwnd, id)
# ("Hello")
# Changes the Text of control
# # win32gui.SetWindowText(b,"Test")
#yt = win32gui.DialogBoxParam(hwnd, id)
#print b, yt
#yt = win32gui.GetIconInfo( b)
print "Message :" + str(msg)
#win32gui.GetDlgItem(yt)
#print yt
#win32gui.SendMessage(b, commctrl.CDIS_SELECTED,0,0)
##win32gui.DialogBoxParam()
self.setCheckBoxValue(hwnd, id, 0)
#cb1=a.GetDlgItem(win32ui.IDC_PROMPT1)

def OnClose(self, hwnd, msg, wparam, lparam):
win32gui.EndDialog(hwnd, 0)

def OnDestroy(self, hwnd, msg, wparam, lparam):
pass

def DemoModal():
# Load the .rc file.
resources = win32rcparser.Parse(g_rcname)
for id, ddef in resources.dialogs.items():
print "Displaying dialog", id
w=DemoWindow(ddef)
w.DoModal()

if __name__=='__main__':
flags = 0
for flag in """ICC_DATE_CLASSES ICC_ANIMATE_CLASS ICC_ANIMATE_CLASS
ICC_BAR_CLASSES ICC_COOL_CLASSES ICC_DATE_CLASSES
ICC_HOTKEY_CLASS ICC_INTERNET_CLASSES ICC_LISTVIEW_CLASSES
ICC_PAGESCROLLER_CLASS ICC_PROGRESS_CLASS ICC_TAB_CLASSES
ICC_TREEVIEW_CLASSES ICC_UPDOWN_CLASS ICC_USEREX_CLASSES
ICC_WIN95_CLASSES """.split():
flags |= getattr(commctrl, flag)
win32gui.InitCommonControlsEx(flags)
# Need to do this go get rich-edit working.
##win32api.LoadLibrary("riched20.dll")
DemoModal()