 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
erictheturtle
Joined: 27 Jun 2007 Posts: 101 Location: California
|
Posted: Fri Sep 12, 2008 7:48 am Post subject: |
|
|
Adding the ErrorLevel check for the WS_Eval() is good, and sharing a script to test with is effective. Just add one more ErrorLevel check after the WS_Exec() as well and you will get the error "Object Required: 'Wscript". The WS_Eval() calls are getting empty values because WS_Exec() failed before those variables were initialized.
Once you replace the use of Wscript, I think your script will probably work fine. _________________ -m35 |
|
| Back to top |
|
 |
Ferry
Joined: 18 May 2008 Posts: 23
|
Posted: Fri Sep 12, 2008 8:41 am Post subject: |
|
|
Thanks erictheturtle! Removing the wscript part did the trick.  |
|
| Back to top |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 7299 Location: Australia
|
Posted: Fri Sep 12, 2008 10:15 am Post subject: |
|
|
| erictheturtle wrote: | | It would be possible for the scripting environment to call AHK functions using some of Sean's work. | DispatchObj can create a COM object from a list of specially-written script functions. This object could be passed to ws4ahk. |
|
| Back to top |
|
 |
erictheturtle
Joined: 27 Jun 2007 Posts: 101 Location: California
|
Posted: Fri Sep 12, 2008 4:00 pm Post subject: |
|
|
Thanks Lexikos, that would be it. You should be able to use DispatchObj and ws4ahk together without any problems.
I gotta hand it to Lexikos, I wouldn't have had the patience to manually construct IDispatch objects in memory via AHK's somewhat clunky memory tweaking routines. Props to you for that.
Edit: OOPS. I need to actually read once in awhile. Sorry Lexikos, mad props go to you for writing that module. _________________ -m35 |
|
| Back to top |
|
 |
n-l-i-d Guest
|
Posted: Tue Sep 16, 2008 1:36 pm Post subject: |
|
|
I'm trying to adapt the WS_DEControl2.ahk library to the "latest" version of WS4AHK. You made a couple of changes in the meantime, including the WS_Exec() calls are now one parameter instead of multiple. I'm having a hard time translating the calls in the original to a one-parameter call.
Could you explain a bit how I'm supposed to adapt them? I keep on getting errors...
Example:
| Code: | If (!WS_Exec("DHtmlControl.ExecCommand %v, %v, %s"
, DECMD_SETBACKCOLOR
, OLECMDEXECOPT_DODEFAULT
, sColor)) |
Thanks. |
|
| Back to top |
|
 |
erictheturtle
Joined: 27 Jun 2007 Posts: 101 Location: California
|
Posted: Tue Sep 16, 2008 2:54 pm Post subject: |
|
|
I don't suppose you're familiar with the C style printf commands, or the Python '%' operator for strings? Basically just replace each %v with the value of the corresponding variable and %s with the VBStr of the corresponding variable. Your example becomes:
| Code: | | If (!WS_Exec("DHtmlControl.ExecCommand " . DECMD_SETBACKCOLOR . ", " . OLECMDEXECOPT_DODEFAULT . ", " . VBStr(sColor))) |
_________________ -m35 |
|
| Back to top |
|
 |
n-l-i-d Guest
|
Posted: Tue Sep 16, 2008 4:01 pm Post subject: |
|
|
Ok, thanks, I almost have it converted, apart from this:
| Code: | DE_InsertTable(numrows, numcols)
{
If (!WS_Exec("Set tParam = CreateObject(%s)", "DEInsertTableParam.DEInsertTableParam"))
Msgbox % A_LineFile ":" ErrorLevel
; create a table object
If (!WS_Exec("tParam.NumRows = " numrows)) ; -> set the table property.
Msgbox % A_LineFile ":" ErrorLevel
If (!WS_Exec("tParam.NumCols = " numcols))
Msgbox % A_LineFile ":" ErrorLevel
global DECMD_INSERTTABLE, OLECMDEXECOPT_DODEFAULT
If (!WS_Exec("DHtmlControl.ExecCommand %v, %v, tParam"
, DECMD_INSERTTABLE
, OLECMDEXECOPT_DODEFAULT))
Msgbox % A_LineFile ":" ErrorLevel
} |
Could you rewrite? |
|
| Back to top |
|
 |
erictheturtle
Joined: 27 Jun 2007 Posts: 101 Location: California
|
Posted: Tue Sep 16, 2008 4:11 pm Post subject: |
|
|
This code isn't that difficult to understand, is it?
| Code: | DE_InsertTable(numrows, numcols)
{
If (!WS_Exec("Set tParam = CreateObject(""DEInsertTableParam.DEInsertTableParam"")"))
Msgbox % A_LineFile ":" ErrorLevel
; create a table object
If (!WS_Exec("tParam.NumRows = " numrows)) ; -> set the table property.
Msgbox % A_LineFile ":" ErrorLevel
If (!WS_Exec("tParam.NumCols = " numcols))
Msgbox % A_LineFile ":" ErrorLevel
global DECMD_INSERTTABLE, OLECMDEXECOPT_DODEFAULT
If (!WS_Exec("DHtmlControl.ExecCommand " DECMD_INSERTTABLE ", " OLECMDEXECOPT_DODEFAULT ", tParam"))
Msgbox % A_LineFile ":" ErrorLevel
} |
_________________ -m35 |
|
| Back to top |
|
 |
n-l-i-d Guest
|
Posted: Wed Sep 17, 2008 12:28 pm Post subject: |
|
|
| Quote: | | This code isn't that difficult to understand, is it? |
Well, fortunately not for you, I couldn't manage to get it working. Thanks!
Here are the adapted scripts:
WS_DEControl3.ahk
| Code: | #Include ws4ahk.ahk ; originally designed for ws4ahk.ahk v0.01 or v0.02, adapted to work with ws4ahk.ahk v0.21 beta
; Command IDs
DECMD_BOLD = 5000
DECMD_COPY = 5002
DECMD_CUT = 5003
DECMD_DELETE = 5004
DECMD_DELETECELLS = 5005
DECMD_DELETECOLS = 5006
DECMD_DELETEROWS = 5007
DECMD_FINDTEXT = 5008
DECMD_FONT = 5009
DECMD_GETBACKCOLOR = 5010
DECMD_GETBLOCKFMT = 5011
DECMD_GETBLOCKFMTNAMES = 5012
DECMD_GETFONTNAME = 5013
DECMD_GETFONTSIZE = 5014
DECMD_GETFORECOLOR = 5015
DECMD_HYPERLINK = 5016
DECMD_IMAGE = 5017
DECMD_INDENT = 5018
DECMD_INSERTCELL = 5019
DECMD_INSERTCOL = 5020
DECMD_INSERTROW = 5021
DECMD_INSERTTABLE = 5022
DECMD_ITALIC = 5023
DECMD_JUSTIFYCENTER = 5024
DECMD_JUSTIFYLEFT = 5025
DECMD_JUSTIFYRIGHT = 5026
DECMD_LOCK_ELEMENT = 5027
DECMD_MAKE_ABSOLUTE = 5028
DECMD_MERGECELLS = 5029
DECMD_ORDERLIST = 5030
DECMD_OUTDENT = 5031
DECMD_PASTE = 5032
DECMD_REDO = 5033
DECMD_REMOVEFORMAT = 5034
DECMD_SELECTALL = 5035
DECMD_SEND_BACKWARD = 5036
DECMD_BRING_FORWARD = 5037
DECMD_SEND_BELOW_TEXT = 5038
DECMD_BRING_ABOVE_TEXT = 5039
DECMD_SEND_TO_BACK = 5040
DECMD_BRING_TO_FRONT = 5041
DECMD_SETBACKCOLOR = 5042
DECMD_SETBLOCKFMT = 5043
DECMD_SETFONTNAME = 5044
DECMD_SETFONTSIZE = 5045
DECMD_SETFORECOLOR = 5046
DECMD_SPLITCELL = 5047
DECMD_UNDERLINE = 5048
DECMD_UNDO = 5049
DECMD_UNLINK = 5050
DECMD_UNORDERLIST = 5051
DECMD_PROPERTIES = 5052
; Enums
;OLECMDEXECOPT
OLECMDEXECOPT_DODEFAULT = 0
OLECMDEXECOPT_PROMPTUSER = 1
OLECMDEXECOPT_DONTPROMPTUSER = 2
; DHTMLEDITCMDF
DECMDF_NOTSUPPORTED = 0
DECMDF_DISABLED = 1
DECMDF_ENABLED = 3
DECMDF_LATCHED = 7
DECMDF_NINCHED = 11
; DHTMLEDITAPPEARANCE
DEAPPEARANCE_FLAT = 0
DEAPPEARANCE_3D = 1
; OLE_TRISTATE
OLE_TRISTATE_UNCHECKED = 0
OLE_TRISTATE_CHECKED = 1
OLE_TRISTATE_GRAY = 2
; Error Return Values
;
DE_E_INVALIDARG = 0x5
DE_E_ACCESS_DENIED = 0x46
DE_E_PATH_NOT_FOUND = 0x80070003
DE_E_FILE_NOT_FOUND = 0x80070002
DE_E_UNEXPECTED = 0x8000ffff
DE_E_DISK_FULL = 0x80070027
DE_E_NOTSUPPORTED = 0x80040100
DE_E_FILTER_FRAMESET = 0x80100001
DE_E_FILTER_SERVERSCRIPT = 0x80100002
DE_E_FILTER_MULTIPLETAGS = 0x80100004
DE_E_FILTER_SCRIPTLISTING = 0x80100008
DE_E_FILTER_SCRIPTLABEL = 0x80100010
DE_E_FILTER_SCRIPTTEXTAREA = 0x80100020
DE_E_FILTER_SCRIPTSELECT = 0x80100040
DE_E_URL_SYNTAX = 0x800401E4
DE_E_INVALID_URL = 0x800C0002
DE_E_NO_SESSION = 0x800C0003
DE_E_CANNOT_CONNECT = 0x800C0004
DE_E_RESOURCE_NOT_FOUND = 0x800C0005
DE_E_OBJECT_NOT_FOUND = 0x800C0006
DE_E_DATA_NOT_AVAILABLE = 0x800C0007
DE_E_DOWNLOAD_FAILURE = 0x800C0008
DE_E_AUTHENTICATION_REQUIRED = 0x800C0009
DE_E_NO_VALID_MEDIA = 0x800C000A
DE_E_CONNECTION_TIMEOUT = 0x800C000B
DE_E_INVALID_REQUEST = 0x800C000C
DE_E_UNKNOWN_PROTOCOL = 0x800C000D
DE_E_SECURITY_PROBLEM = 0x800C000E
DE_E_CANNOT_LOAD_DATA = 0x800C000F
DE_E_CANNOT_INSTANTIATE_OBJECT = 0x800C0010
DE_E_REDIRECT_FAILED = 0x800C0014
DE_E_REDIRECT_TO_DIR = 0x800C0015
DE_E_CANNOT_LOCK_REQUEST = 0x800C0016
; ------------------------- General functions ---------------------------------------------------------------
DE_Add(hWnd, x, y, w, h)
{
ppvDEdit := WS_GetComControlInHWND( WS_CreateComControlContainer(hWnd, x, y, w, h, "DhtmlEdit.DhtmlEdit") )
; Add the COM control to the scripting environment
; with the name "DHtmlControl"
; Note that this means only one DHtmlEdit control can exist at a time
WS_AddObject(ppvDEdit, "DHtmlControl")
Return ppvDEdit
}
DE_Move(pwb, x, y, w, h)
{
WinMove, % "ahk_id " . WS_GetHWNDofComControl(pwb), , x, y, w, h
}
DE_BrowseMode() ; toggle between Edit mode and View mode.
{
sCode =
(
If DHtmlControl.Browsemode = 0 Then
DHtmlControl.Browsemode = 1
Else
DHtmlControl.Browsemode = 0
End If
)
If (!WS_Exec(sCode))
Msgbox % A_LineFile ":" ErrorLevel
}
DE_LoadUrl(url) ;Load url(e.g. "http://www.autohotkey.com") and ready to edit in a WYSIWIG way
{
If (!WS_Exec(VBStr("DHtmlControl.LoadUrl " . VBStr(url))))
Msgbox % A_LineFile ":" ErrorLevel
}
DE_NewDocument() ;clear current document and open blank html document
{
If (!WS_Exec("DHtmlControl.NewDocument"))
Msgbox % A_LineFile ":" ErrorLevel
}
DE_LoadDocument(FileDir) ;open file dialog and last parameter is prompt string.
{
If (!WS_Exec("DHtmlControl.LoadDocument " . VBStr(FileDir) . ", " prompt))
Msgbox % A_LineFile ":" ErrorLevel
}
DE_SaveDocument(Filedir) ;save contents in html.
{
If (!WS_Exec("DHtmlControl.SaveDocument " . VBStr(FileDir)))
Msgbox % A_LineFile ":" ErrorLevel
}
DE_GetDocumentHtml() ;get and return DOCUMENT'S htmlcode
{
If (!WS_Eval(sRet, "DHtmlControl.DocumentHtml"))
Msgbox % A_LineFile ":" ErrorLevel
Return sRet
}
DE_SetDocumentHtml(sHtml) ;set document's htmlcode
{
If (!WS_Exec("DHtmlControl.DocumentHtml = " . VBStr(sHtml)))
Msgbox % A_LineFile ":" ErrorLevel
}
DE_Refresh() ;open file dialog and last parameter is prompt string.
{
If (!WS_Exec("DHtmlControl.Refresh"))
Msgbox % A_LineFile ":" ErrorLevel
}
; --- WYSIWYG Edit functions ----------------------------------------------------------------------------------------------
; Set property --> use ExecCommand(), Command ID
; Get Propery --> use QueryStatus(), command ID
DE_SetBOLD() ; toggle selections bold/normal
{
global
If (!WS_Exec("DHtmlControl.ExecCommand " . DECMD_BOLD))
Msgbox % A_LineFile ":" ErrorLevel
}
DE_SetUnderline() ; toggle selections underline
{
global
If (!WS_Exec("DHtmlControl.ExecCommand " . DECMD_UNDERLINE))
Msgbox % A_LineFile ":" ErrorLevel
}
DE_SetItalic() ; toggle selections italic
{
global
If (!WS_Exec("DHtmlControl.ExecCommand " . DECMD_ITALIC))
Msgbox % A_LineFile ":" ErrorLevel
}
DE_SetForeColor(sColor) ; set font color string, e.g. "#55A0FF", "55A0FF", "Blue", "Red"
{
global
If (!WS_Exec("DHtmlControl.ExecCommand " . DECMD_SETFORECOLOR . ", " . OLECMDEXECOPT_DODEFAULT . ", " . VBStr(sColor)))
Msgbox % A_LineFile ":" ErrorLevel
}
DE_SetBackColor(sColor) ;
{
global
If (!WS_Exec("DHtmlControl.ExecCommand " . DECMD_SETBACKCOLOR . ", " . OLECMDEXECOPT_DODEFAULT . ", " . VBStr(sColor)))
Msgbox % A_LineFile ":" ErrorLevel
}
DE_Font() ;
{
global
If (!WS_Exec("DHtmlControl.ExecCommand " . DECMD_FONT))
Msgbox % A_LineFile ":" ErrorLevel
}
DE_SetFontName(sFont) ;
{
global
If (!WS_Exec("DHtmlControl.ExecCommand " . DECMD_SETFONTNAME . ", " . OLECMDEXECOPT_DODEFAULT . ", " . VBStr(sFont)))
Msgbox % A_LineFile ":" ErrorLevel
}
DE_SetFontSize(iFontSize) ;
{
global
If (!WS_Exec("DHtmlControl.ExecCommand " . DECMD_SETFONTSIZE . ", " . OLECMDEXECOPT_DODEFAULT . ", " . VBStr(iFontSize)))
Msgbox % A_LineFile ":" ErrorLevel
}
DE_JustifyLeft() ;
{
global
If (!WS_Exec("DHtmlControl.ExecCommand " . DECMD_JUSTIFYLEFT))
Msgbox % A_LineFile ":" ErrorLevel
}
DE_JustifyCenter() ;
{
global
If (!WS_Exec("DHtmlControl.ExecCommand " . DECMD_JUSTIFYCENTER))
Msgbox % A_LineFile ":" ErrorLevel
}
DE_JustifyRight() ;
{
global
If (!WS_Exec("DHtmlControl.ExecCommand " . DECMD_JUSTIFYRIGHT))
Msgbox % A_LineFile ":" ErrorLevel
}
DE_SetHyperLink() ; insert hyperlink property in selection
{
global
If (!WS_Exec("DHtmlControl.ExecCommand " . DECMD_HYPERLINK . ", " . OLECMDEXECOPT_DODEFAULT . ", " . VBStr("")))
Msgbox % A_LineFile ":" ErrorLevel
}
DE_SetImage() ; insert image in selection
{
global
If (!WS_Exec("DHtmlControl.ExecCommand " . DECMD_IMAGE . ", " . OLECMDEXECOPT_DODEFAULT . ", " . VBStr("")))
Msgbox % A_LineFile ":" ErrorLevel
}
DE_UnLink() ; insert image in selection
{
global
If (!WS_Exec("DHtmlControl.ExecCommand " . DECMD_UNLINK . ", " . OLECMDEXECOPT_DODEFAULT . ", " . VBStr("")))
Msgbox % A_LineFile ":" ErrorLevel
}
DE_SelectAll() ;
{
global
If (!WS_Exec("DHtmlControl.ExecCommand " . DECMD_SELECTALL))
Msgbox % A_LineFile ":" ErrorLevel
}
DE_Paste(pDHtmlEdit) ;
{
global
If (!WS_Exec("DHtmlControl.ExecCommand " . DECMD_HYPERLINK . ", " . OLECMDEXECOPT_DODEFAULT))
Msgbox % A_LineFile ":" ErrorLevel
}
DE_Properties() ;
{
global
If (!WS_Exec("DHtmlControl.ExecCommand " . DECMD_PROPERTIES))
Msgbox % A_LineFile ":" ErrorLevel
}
DE_UnDo() ;
{
global
If (!WS_Exec("DHtmlControl.ExecCommand " . DECMD_UNDO))
Msgbox % A_LineFile ":" ErrorLevel
}
DE_ReDo() ;
{
global
If (!WS_Exec("DHtmlControl.ExecCommand " . DECMD_REDO))
Msgbox % A_LineFile ":" ErrorLevel
}
DE_FindText() ;
{
global
If (!WS_Exec("DHtmlControl.ExecCommand " . DECMD_FINDTEXT))
Msgbox % A_LineFile ":" ErrorLevel
}
DE_Delete() ;
{
global
If (!WS_Exec("DHtmlControl.ExecCommand " . DECMD_DELETE))
Msgbox % A_LineFile ":" ErrorLevel
}
DE_Cut() ;
{
global
If (!WS_Exec("DHtmlControl.ExecCommand " . DECMD_CUT))
Msgbox % A_LineFile ":" ErrorLevel
}
DE_COPY() ;
{
global
If (!WS_Exec("DHtmlControl.ExecCommand " . DECMD_COPY))
Msgbox % A_LineFile ":" ErrorLevel
}
; ------- LIST AND TABLE FUNCTIONS
DE_OrderList() ; NUMBERED LIST
{
global
If (!WS_Exec("DHtmlControl.ExecCommand " . DECMD_ORDERLIST))
Msgbox % A_LineFile ":" ErrorLevel
}
DE_UnorderList() ; BULLET LIST
{
global
If (!WS_Exec("DHtmlControl.ExecCommand " . DECMD_UNORDERLIST))
Msgbox % A_LineFile ":" ErrorLevel
}
DE_InsertTable(numrows, numcols)
{
If (!WS_Exec("Set tParam = CreateObject(""DEInsertTableParam.DEInsertTableParam"")"))
Msgbox % A_LineFile ":" ErrorLevel
; create a table object
If (!WS_Exec("tParam.NumRows = " numrows)) ; -> set the table property.
Msgbox % A_LineFile ":" ErrorLevel
If (!WS_Exec("tParam.NumCols = " numcols))
Msgbox % A_LineFile ":" ErrorLevel
global DECMD_INSERTTABLE, OLECMDEXECOPT_DODEFAULT
If (!WS_Exec("DHtmlControl.ExecCommand " DECMD_INSERTTABLE ", " OLECMDEXECOPT_DODEFAULT ", tParam"))
Msgbox % A_LineFile ":" ErrorLevel
}
; --------- USING DOM ----------------------------------------------------------
GetSelection()
{
sVBCode =
(
SelType = DHtmlControl.DOM.Selection.Type
If SelType = "Text" Then
SelectedText = DHtmlControl.DOM.Selection.CreateRange().HtmlText
Else
SelectedText = ""
End If
)
; Execute the VB code
If (!WS_Exec(sVBCode))
Msgbox % A_LineFile ":" ErrorLevel
; The variable "SelectedText" in the scripting environment holds the
; selected text. This gets the value out of the scripting environment.
If (!WS_Eval(SelectedText, "SelectedText"))
Msgbox % A_LineFile ":" ErrorLevel
Return SelectedText
}
|
Example (WS_DEDemo3.ahk)
| Code: | #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#include %A_ScriptDir%\WS4AHK.ahk
#include %A_ScriptDir%\WS_DEControl3.ahk
If (!WS_Initialize("VBScript"))
{
Msgbox % "Error initializing EasyScript"
ExitApp
}
WS_InitComControls()
Gui, +Resize +LastFound +theme
Gui, Add, Button, x0 y0 gSetBold, Bold
Gui, Add, Button, xp+40 gSetItalic,italic
Gui, Add, Button, xp+50 gSetUnderLine, underline
gui, Add, Button, xp+75 gSetBlue, Blue
Gui, Add, Button, xp+40 gSetImageLink, Image
Gui, Add, Button, xp+50 gSetHyperLink, Link
Gui, Add, Button, xp+50 gLoadUrl, LoadURL
Gui, Add, Button, xp+70 gGetDocument, GetHtml
gui, add, button, xp+70 gSetDocument, SetHtml
Gui, Add, button, xp+70 gSaveDocument, SaveHtml
Gui, Add, button, xp+80 gBrowseMode, BrowseMode Toggle
Gui, add, button, x0 yp+25 gSetFontName, SetFontName
Gui, add, button, xp+90 gSetFontSize, SetFontSize
Gui, add, button, xp+90 gSetFont, SetFont
Gui, add, button, xp+50 gList1, List1
Gui, add, button, xp+50 gList2, List2
gui, Add, Button, xp+50 gInsertTable, InsertTable
Gui, add, button, xp+140 gNewDocument, New
Gui, add, button, xp+40 gFindText, FindText
Gui, add, button, xp+70 gSetBackColor, SetBackColor
Gui, Show, w800 h600 Center, DhtmlEdit_Test
hWnd := WinExist()
; Create the COM control
ppvDEdit := DE_Add(hWnd, 0, 50, 800, 550)
Gosub, SetDocument
Return ; end of auto-run
1::
msgbox, % GetSelection()
return
SetBold:
DE_SetBold()
Return
SetItalic:
DE_SetItalic()
Return
SetBlue:
;DE_SetForeColor(DEdit, "0000FF")
DE_SetForeColor("Blue") ; possible way
;DE_SetForeColor(pDHtmlEdit, "#0000FF") ; also possible
Return
SetUnderline:
DE_SetUnderline()
Return
SetImageLink:
DE_SetImage()
Return
SetHyperLink:
DE_SetHyperLink()
Return
LoadUrl:
url := "http://www.autohotkey.com"
DE_LoadUrl(url)
Return
NewDocument:
DE_NewDocument()
Return
SaveDocument:
Filedir = %A_ScriptDir%\DhtmlEdit_%A_Now%.htm
DE_SaveDocument(FileDir)
Return
GetDocument:
msgbox, % DE_GetDocumentHtml()
Return
SetDocument:
htmlcode =
(
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="content-type">
<title></title>
</head>
<body
style="COLOR: rgb(0,0,0); BACKGROUND-COLOR: rgb(255,204,51)" alink
="#ee0000" link="#0000ee" vlink="#551a8b">
<P>
<big style="FONT-FAMILY: Verdana"><big><EM><STRONG>Forgive</STRONG></EM> my <span
style="FONT-WEIGHT: bold; COLOR: rgb(51,51,255)" >poor</span> coding style! Yes?
</big></big></P>
<P><BIG style="FONT-FAMILY: Verdana"><BIG>This File is Edited with
<STRONG>DhtmlEdit_Demo</STRONG>
.<br>
<br></P></BIG></BIG>
<ul style="FONT-FAMILY: Verdana">
<li><STRONG><U>First List</U></STRONG>
<li><FONT color=blue>second List</FONT>
<li><A href="http://www.autohotkey.com">what
now?(</A>click then go to AutohotKey)</li>
</ul>
<br style="FONT-FAMILY: Verdana">
<table
style="WIDTH: 440px; FONT-FAMILY: Verdana; HEIGHT: 52px; TEXT-ALIGN: left"
border="1" cellpadding="2" cellspacing="2">
<tbody>
<tr>
<td>This is a table<br>
and the right image is directly from AutoHotKey Forum.</td>
<td><A href="http://www.autohotkey.com"><img style="WIDTH: 228px; HEIGHT: 133px"
alt="image cannot be loaed for some reason"
src="http://www.autohotkey.com/docs/images/AutoHotkey_logo.gif"></A></td>
</tr>
</tbody>
</table>
</body>
</html>
)
DE_SetDocumentHtml(htmlcode)
htmlcode =
Return
BrowseMode:
DE_BrowseMode()
Return
FindText:
DE_FindText()
Return
SetBackColor:
DE_SetBackColor("Yellow")
Return
SetFontName:
DE_SetFontName("Arial Black")
Return
SetFontSize:
DE_SetFontSize("4")
Return
SetFont:
DE_Font()
Return
List1:
DE_OrderList()
Return
List2:
DE_UnOrderList()
Return
InsertTable:
DE_InsertTable(2,2)
return
GuiSize:
DE_Move(ppvDEdit, 0, 50, A_GuiWidth, A_GuiHeight-50)
Return
GuiClose:
Gui, %A_Gui%:Destroy
WS_ReleaseObject(ppvDEdit)
WS_UninitComControls()
WS_Uninitialize()
ExitApp
|
|
|
| Back to top |
|
 |
n-l-i-d Guest
|
Posted: Wed Sep 17, 2008 5:21 pm Post subject: |
|
|
Oh, and can anyone confirm/deny that this still works on Vista? I understood it might not.
And thanks again  |
|
| Back to top |
|
 |
erictheturtle
Joined: 27 Jun 2007 Posts: 101 Location: California
|
Posted: Fri Sep 19, 2008 2:15 pm Post subject: |
|
|
Very nice n-l-i-d, and thank you. This will be a helpful example for others.
| n-l-i-d wrote: | | Quote: | | This code isn't that difficult to understand, is it? |
:) Well, fortunately not for you, I couldn't manage to get it working. Thanks! 8) |
No problem. I'm just trying to see if the whole ws4ahk API makes sense to people. I guess if the codef() stuff wasn't very clear, then I'm glad I got rid of it. _________________ -m35 |
|
| Back to top |
|
 |
free2code
Joined: 19 Oct 2008 Posts: 12
|
Posted: Fri Nov 21, 2008 10:09 am Post subject: Endless troubles parsing strings to function with ws4ahk.ahk |
|
|
I've had endless troubles trying to get strings through into the
Code
(
'Section
)
At first, I was trying to parse the strings into a function, but had no luck whatsoever. The only way I could get my code to work was to use %variable% within the code section which I thought was a no-no.
Can any tell me the correct method for parsing variables into this section of code? |
|
| Back to top |
|
 |
erictheturtle
Joined: 27 Jun 2007 Posts: 101 Location: California
|
Posted: Fri Nov 21, 2008 4:04 pm Post subject: Re: Endless troubles parsing strings to function with ws4ahk |
|
|
| free2code wrote: | I've had endless troubles trying to get strings through into the
Code
(
'Section
)
At first, I was trying to parse the strings into a function, but had no luck whatsoever. The only way I could get my code to work was to use %variable% within the code section which I thought was a no-no.
Can any tell me the correct method for parsing variables into this section of code? |
I'm not sure exactly what you are having problems with, but I'll see if I can answer.
It sounds like you want to pass the string contents of an AHK variable to some VB code. You are correct that you concatenate the AHK variable in with some VB code.
You can do it with a multi-line string like you seem to be doing.
| Code: | #include ws4ahk.ahk
WS_Initialize()
ahkVariable := "hello AHK string"
SomeVBCode =
(
value = "%ahkVariable%"
Msgbox value
)
WS_Exec(SomeVBCode) |
But it seems most people create a VB function and then call it with the AHK value. | Code: | #include ws4ahk.ahk
WS_Initialize()
SomeVBCode =
(
Sub DisplayValue(value)
Msgbox value
End Sub
)
WS_Exec(SomeVBCode) ; add the VB function to the script environment
ahkVariable := "hello AHK string"
WS_Exec("DisplayValue """ . ahkVariable . """") |
As you can see, both methods use concatenation to pass AHK values into VB code. The second method can be faster if you call the same VB code repeatedly with different values.
You can also use the VBStr() or JStr() functions to wrap the string in quotes. | Code: | | WS_Exec("DisplayValue " . VBStr(ahkVariable) ) | This will also escape any double-quotes and line-feeds within the string value itself. The documentation has some examples about that. _________________ -m35 |
|
| Back to top |
|
 |
free2code
Joined: 19 Oct 2008 Posts: 12
|
Posted: Sat Nov 22, 2008 11:41 pm Post subject: |
|
|
Thanks erictheturtle, that's been a huge help  |
|
| Back to top |
|
 |
free2code
Joined: 19 Oct 2008 Posts: 12
|
Posted: Mon Nov 24, 2008 12:24 am Post subject: |
|
|
One more quick question, how do you send multiple parameters to a function? I haven't been able to get this to work:
WS_Eval(Success, "CSUpdate VBStr(Var1), VBStr(Var2), VBStr(Var3), VBStr(Var4), VBStr(Var5), VBStr(Var6), VBStr(Var7)") |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|