Embed VBScript or JScript directly in your Autohotkey programs. No temporary files. Full and easy access to COM.
For questions, or to contact me (erictheturtle), see the official thread in the Autohotkey forums.
ws4ahk uses the Microsoft Scripting Control to execute your VBScript or JScript. Nearly all computers will have it installed. In the rare case a computer does not have it installed, it can easily be downloaded directly from Microsoft and installed. If you don't want to make your end-user install it, as an alternative, the core "msscript.ocx" file may be accessed directly when ws4ahk is initialized.
WS_Initialize(scriping language, path to msscript.ocx)
List of Automation errors (KB186063)
Official Autohotkey forum thread
[Reported by YMP] The pop-up message in the following code should timeout after 2 seconds, but it does not.
Code=
(
sh=new ActiveXObject("WScript.Shell");
sh.Popup('Hello, world!', 2);
)
WS_Initialize("JScript")
WS_Exec(Code)
WS_Uninitialize()
Any timeout value >= 1.5 seconds will not timeout. Running the following code in Microsoft Office VBA will produce the same bug
Sub buggy()
Set sc = CreateObject("MSScriptControl.ScriptControl")
sc.Language = "VBScript"
Code = "set sh=CreateObject(""WScript.Shell"")" & vbCrLf & _
"sh.Popup ""Hello, world!"", 1.5"
sc.ExecuteStatement Code
End Sub
There's no explaination for this problem, and appears to be the fault of the Microsoft Scripting Control, or the WScript.Shell object, or both.
The best workaround is to use Autohotkey's Msgbox function instead.
v0.20
- WS_Exec()/WS_Eval(): Better handling of errors.
Removed printf() style functionality, moved to codef() function.
Removed leftover Clipboard debug.
- codef(): New function to handle printf() style formatting of code.
Also fixes the bug if in hex mode.
v0.13
- Added missing error handling.
v0.12 (9 Dec 2007)
- Fixed bug in WS_Eval() when using the printf style.
- Added home page to docs and renamed internal functions
per suggestion of Joy2DWorld
- Updated documentation a bit
v0.11 (8 Dec 2007)
- Fixed spelling errors
v0.10 (7 Dec 2007)
- Fully documented
- Combined functions to reduce namespace usage
- Renamed internal functions
- Fixed a number of bugs
- Simplified and improved error handling
(got rid of alternate no error checking flavor)
- (Note, public interface has basically not changed from 0.04)
v0.04 (2 Dec 2007)
- Renamed all public functions to have a WS_ prefix.
- WS_Uninitialize() - fixed releasing all resources
- WS_Eval(), WS_Exec() - Improved exception handling
- Added error checking to COM control functions and __GetIDispatch()
- Fixed __GetActiveObject()
- Fixed memory leak for BSTR in __UnpackVARIANT()
- Began adding more detailed documentation.
v0.03 (3 Aug 2007)
- Added the very important credits to Sean in AHK forums and Elias on CodeProject
for their work (I'm ashamed these weren't in the initial release)
- Fixed silly little bug in _CoInitialize()
- More and more comments
v0.02 (26 Jul 2007)
- Fixed so script errors are actually returned without an error (missing global declaration)
- Fixed ScriptStr() so language detection is not case sensitive
- Added error checking in GetComControlInHWND()
- LOTS of code cleaning
v0.01
- Initial release
v0.13
v0.12
v0.11
WS_RemoveErrChk.ahk
v0.04
v0.03
v0.02
v0.01
26 Jul 2007: New updated WS_DEControl2.ahk and WS_DEDemo2.ahk to not require passing the scripting object name in every function. Again based on ABCyourway's code. (NOTE: These require v0.03 of the ws4ahk)
WS_DEControl.ahk and WS_DEdemo.ahk, originally written by ABCyourway for EasyCOM. (NOTE: These require v0.01 of the ws4ahk)
This page origionally generated using ABCyourway's DHTML Edit control :)