473,396 Members | 1,998 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

python tool for ultraedit

dear c.l.p,

I'm posting a Py script to change the wordfile
from inside the UE editor. Define this into
the adv. tool menu.

I found 100 posts in groups.google discussing
Python and UltraEdit.

Since UltraEdit is only happy with 10 parts in
a Wordfile, it is convenient to have multiple
wordfiles, with no more than 10 styles per wf.

To keep a wf associated to a script, add a tag
in the comment header:

"""
wordfile: e:/path/mywordfile.txt
"""
http://mysite.verizon.net/res1ur2j/SwitchWF.zip

------ begin SwitchWF.py ------------
#!e:/Python22/python
"""
script: SwitchWF.py
keywords: enum window win32api handle callback
author: tl***********@CHENEYyahoo.com
relatedDoc=Selkey.png
wordfile: "C:/Progra~1/UltraEdit/WORDFILE.TXT" 3

UE macro to highlight the wf tag
------- start macro ------
InsertMode
ColumnModeOff
HexOff
UnixReOn
GotoLine 1
Find RegExp "\swordfile:"
IfFound
Find RegExp "\S"
StartSelect
Key END
EndSelect
EndIf
------ end macro ---------

synopsis: (2 arguments)
python SwitchWF.py "path to new wf" Ind-of-Ext-SynHighlight

"""
import os, sys
import win32api as ap
import win32gui as wi
import win32ui as ui
import win32con as wc
import win32clipboard

myhwnd = 0
myti = ''
mycl = ''

# function callback
####################
def Callback(hwnd, skip):
global myhwnd
global myti
ti = wi.GetWindowText(hwnd)
if ti.find(skip) >=0:
myhwnd = hwnd
myti = ti
print myhwnd, "uedit32 found",skip
return 0
else:
#print myhwnd, ti
return 1

# function pysendkey
#######################
"""
pysendkey is a pure-python replacement for the
WSHShell SendKeys method!
"""
def pysendkey( keycode ):
dwFlags= wc.KEYEVENTF_EXTENDEDKEY
bVk = keycode
ap.keybd_event( bVk, bScan, dwFlags, 0)
dwFlags= wc.KEYEVENTF_EXTENDEDKEY | wc.KEYEVENTF_KEYUP
ap.keybd_event( bVk, bScan, dwFlags, 0)

# function menu_activate
########################
"""
use below for activating sub menu items of the
UE main menu.
mid = main menu id
iid = sub item id

"""
def menu_activate(myhwnd, mymenu, mid, iid ):
pya = mymenu.GetSubMenu(mid)
print pya.GetHandle()
#vid = mymenu.GetMenuItemID(mid)
#res = wi.SendMessageTimeout( myhwnd,wc.WM_COMMAND, vid, 0, 2, 75 )

# configuration menu item id
cid = pya.GetMenuItemID(iid)
print "cid=", cid

#check for OS, and pack the ID if necessary
env = os.environ
if env['WINDIR'].find('WINNT'):
print "Got NT"
else:
print "Win98 pack the ID"
res=wi.SetForegroundWindow(myhwnd)
try:
res = wi.SendMessageTimeout( myhwnd,wc.WM_COMMAND, cid, 0, 2, 75 )
print "res=", res
except:
print "done - error "
# ok
ap.Sleep(50)
# Main
########################
try:
wi.EnumWindows(Callback, "UltraEdit-32")
except:
print "error", myhwnd
print myti, myhwnd

# get a Python handle object
# enumwindows was needed above since FindWindowEx is broken in Python 2.2-
# must use the --exact-- title or fail (not the case in VB)
pyhw = ui.FindWindowEx( None, None, None, myti )

pymenu = pyhw.GetMenu()

# when called from the UE tool menu, we need a valid selection
if sys.argv[1] == '%sel%':
sys.exit(0)

menu_activate(myhwnd, pymenu, 9, 0)

# get the hwnd of the UltraEdit Configuration dialog
#hwuc = cM.FindWindowLike( cl, "UltraEdit Configuration" )
hwuc = wi.FindWindowEx(0, 0, "#32770", "UltraEdit Configuration" )
print "ue config=", hwuc

# get handle to the child systabcontrol32 class
hwtab = wi.FindWindowEx( hwuc , 0, "SysTabControl32", None )
print hwtab

# open the 7 item via message
# TCM_FIRST= &h1300
#Const TCM_SETCURFOCUS As Long = (TCM_FIRST + 48)
# not found in Win32Con
TCM_SETCURFOCUS = 0x1330

SYNTAX_HIGHLIGHT = 7
wi.PostMessage( hwtab, TCM_SETCURFOCUS, SYNTAX_HIGHLIGHT , 0)

# get the myhwnd to the SynHigh dialog
hwsh = wi.FindWindowEx( hwuc, 0, "#32770", "Syntax Highlighting")
print "SynHigh myhwnd=",hwsh

# get the myhwnd to its only edit box
hwedit = wi.FindWindowEx( hwsh, 0, "Edit", None)

res = wi.SetForegroundWindow(hwedit)

# set the focus here
lres = wi.SendMessageTimeout(hwedit, wc.WM_SETFOCUS , None , None , 2 , 50 )

## press <SHIFT-END> down
#########
dwFlags= wc.KEYEVENTF_EXTENDEDKEY
bVk = wc.VK_SHIFT
bScan = 1 # or 0
ap.keybd_event( bVk, bScan, dwFlags, 0)

bVk = wc.VK_END
bScan = 1 # or 0
ap.keybd_event( bVk, bScan, dwFlags, 0)
########### end down keys#################

# up the two keys
################
dwFlags= wc.KEYEVENTF_EXTENDEDKEY | wc.KEYEVENTF_KEYUP
ap.keybd_event( bVk, bScan, dwFlags, 0)

bVk = wc.VK_SHIFT
ap.keybd_event( bVk, bScan, dwFlags, 0)
########### end up keys ##################

# press BACKSPACE up , then down
pysendkey( wc.VK_BACK )

####################################

#print sys.argv[1]

if len(sys.argv)>1:
win32clipboard.OpenClipboard()
win32clipboard.EmptyClipboard()
win32clipboard.SetClipboardText(sys.argv[1])
win32clipboard.CloseClipboard()

# paste the clipboard, then push enter
#
lres = wi.SendMessageTimeout(hwedit, wc.WM_PASTE, 0 , 0 , 2 , 50 )

pysendkey( wc.VK_RETURN )
print "done"
print sys.argv[1]
# if len(sys.argv)>2:
# # get the View menu
# menu_activate( myhwnd, pymenu, 5, int(sys.argv[2]))
# ap.Sleep(50)
------ end script ------------

good luck,
Mark Pryor

Jul 18 '05 #1
0 4704

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Rod | last post by:
Hi, i am looking for a software that will help me to manage my PHP scritps within an application. Like a different color, a way to find and access all my classes and functions, a debugger etc...
8
by: Sridhar R | last post by:
Hi, I am a little experienced python programmer (2 months). I am somewhat experienced in C/C++. I am planning (now in design stage) to write an IDE in python. The IDE will not be a simple...
13
by: Kamilche | last post by:
I love Python, but I'm less than in love with IDLE. It's OK, but it really doesn't have enough capabilities. What I consider critical, are a popdown listing of all my functions, colored syntax...
3
by: serge | last post by:
Is it good enough to use IBM DB2 8.2 SQL Development Center to create and compile procedures? Or a tool like Embarcadero's Rapid SQL is better? If it is better, would you know why exactly? ...
0
by: cn.popeye | last post by:
Use UltraEdit run Python Run UltraEdit Menu :Advanced menu/Tool Configuration command Command Line: python %n%e Working Directory:%p
35
by: John Coleman | last post by:
Greetings, I have a rough classification of languages into 2 classes: Zen languages and tool languages. A tool language is a language that is, well, a *tool* for programming a computer. C is the...
4
by: gregory diaczok | last post by:
How do I sent up Ultra Edit to work w/ Python? How do I get Ultra Edit to run a Python script currently in the edit window and supply results? I can't figure out how to get Ultra Edit to...
14
by: John Salerno | last post by:
Specifically, I'm using UltraEdit and perhaps there's no way perfect way to implement code folding with it, given how it uses its syntax highlighting file to do so (i.e., you have to specify an...
13
by: dmarrese | last post by:
I am a parent volunteer for a swim team website (makoswim.org) and am looking for a recommendation for a new web authoring tool . While I am technically oriented and have somehave some knowledge...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.