Code= ( sh=new ActiveXObject("WScript.Shell"); sh.Popup('Hello, world!', 2); ) WS_Initialize("JScript") WS_Exec(Code) WS_Uninitialize()I found only a few exceptions: 1, 1.1, 1.2, 1.3, 1.4 . With these values, the dialog closes.
Embedded Windows Scripting (VBScript & JScript) and COM
Started by
erictheturtle
, Jul 11 2007 12:08 PM
68 replies to this topic
I'm not sure about the source of this little bug, but thought it would be worth mentioning. The timeout parameter in the Popup method doesn't work properly. The dialog will apparently stay forever.
#31
-
Posted 19 August 2007 - 03:16 AM
Wow YMP, thanks for reporting this. What a very odd bug. Here are some of the things I've tried:[*:r3w09be2]The bug seems to occur when the timeout value is >=1.5 seconds (the timeout works correctly at 1.49999).I'm not sure about the source of this little bug, but thought it would be worth mentioning. The timeout parameter in the Popup method doesn't work properly. The dialog will apparently stay forever.
Code= ( sh=new ActiveXObject("WScript.Shell"); sh.Popup('Hello, world!', 2); ) WS_Initialize("JScript") WS_Exec(Code) WS_Uninitialize()I found only a few exceptions: 1, 1.1, 1.2, 1.3, 1.4 . With these values, the dialog closes.
[*:r3w09be2]Using WS_Initialize("VBScript") and changing the code to VBScript still produces the bug.
[*:r3w09be2] Putting that JScript or VBScript code directly into a .js or .vbs file directly does not produce the bug.
[*:r3w09be2] Putting that VBScript code in Excel VBA does not produce the bug.
[*:r3w09be2] Using Microsoft Scripting Control in a .vbs script to run this code does not produce this bug.
[*:r3w09be2] Using the Microsoft Scripting Control in Excel VBA to run the code does produce this bug.Since I can produce the bug in Microsoft Excel's VBA, it is likely ws4ahk is not to blame. I tried searching for this, and any other bugs associated with the Microsoft Scripting Control. Unfortunately it doesn't appear to be a known problem.
So congratulations on finding a bug no one has ever seen before ...it's too bad we'll probably never see a fix for it in our lifetimes.
Of course if you need a message box with a timeout, the simple work-around is to use our actively maintained and open source Autohotkey's Msgbox function instead. I hope that will meet your needs well enough.
Thanks again for reporting this. Sorry that there doesn't seem to be any fix for it.
#33
-
Posted 19 August 2007 - 02:38 PM
-m35
Thanks for the improvement BoBo¨. I know the buttons were running off the window. Style wise, I admit I liked how ABCyourway was arranging them. I've adjusted the buttons a bit so they all fit on the form now (but of course the design of the window isn't really the focus of the demo).@ erictheturtle
I thought about to (slightly) improve the GUI of WS_DEDemo2.ahk.
Well, desperately waiting for your sign off :)Gui, +Resize +LastFound +theme Gui, Add, Button, x0 y2 w110 h22 gSetBold, Bold Gui, Add, Button, xp+111 yp wp hp gSetItalic,italic Gui, Add, Button, xp+111 yp wp hp gSetUnderLine, underline gui, Add, Button, xp+111 yp wp hp gSetBlue, Blue Gui, Add, Button, xp+111 yp wp hp gSetImageLink, Image Gui, Add, Button, xp+111 yp wp hp gSetHyperLink, Link Gui, Add, Button, xp+111 yp wp hp gLoadUrl, LoadURL Gui, Add, Button, x0 yp+23 wp hp gGetDocument, GetHtml gui, add, button, xp+111 yp wp hp gSetDocument, SetHtml Gui, Add, button, xp+111 yp wp hp gSaveDocument, SaveHtml Gui, Add, button, xp+111 yp wp hp gBrowseMode, BrowseMode Toggle Gui, add, button, xp+111 yp wp hp gNewDocument, New Gui, add, button, xp+111 yp wp hp gFindText, FindText Gui, add, button, xp+111 yp wp hp gSetBackColor, SetBackColor Gui, add, button, x0 yp+23 wp hp gSetFontName, SetFontName Gui, add, button, xp+111 yp wp hp gSetFontSize, SetFontSize Gui, add, button, xp+111 yp wp hp gSetFont, SetFont Gui, add, button, xp+111 yp wp hp gList1, List1 Gui, add, button, xp+111 yp wp hp gList2, List2 gui, Add, Button, xp+111 yp wp hp gInsertTable, InsertTable ShowW = 776 ShowH = 600 Gui, Show, % "w" ShowW " h" ShowH Center, DhtmlEdit_Test hWnd := WinExist() ; Create the COM control ppvDEdit := DE_Add(hWnd, 0, 72, ShowW-1, ShowH-72) . . . GuiSize: DE_Move(ppvDEdit, 0, 72, A_GuiWidth, A_GuiHeight-72) Return
I'm somewhat ashamed, because I just realized it was a little rude of me to use ABCyourway's code as a ws4ahk demo without actually asking. ABCyourway, if you happen to read this post, I just wanted to get your OK to use your DEdit script as a ws4ahk demo. Please PM me, or post a reply when you get a chance.
#34
-
Posted 19 August 2007 - 03:29 PM
-m35
Oh, great indeed! It's an honour to me.So congratulations on finding a bug no one has ever seen before
No doubt. AHK forever! Besides, with 1, the Popup dialog actually stays about 2 seconds. Enough time to read a short message, I believe.Of course if you need a message box with a timeout, the simple work-around is to use our actively maintained and open source Autohotkey's Msgbox function instead. I hope that will meet your needs well enough.
Thanks for the detailed reply (and for ws4ahk, of course!!).
#35
-
Posted 20 August 2007 - 03:59 AM
Eric,
I finally added a link to Windows Scripting for AutoHotkey to the DllCall page. Hopefully this will bring more attention to the great work you've done.
I finally added a link to Windows Scripting for AutoHotkey to the DllCall page. Hopefully this will bring more attention to the great work you've done.
#36
-
Posted 28 August 2007 - 12:56 PM
I'm trying to read and write to an excel file without opening it in excel. I'm shure that this would be possible, but unfortunately I'm not very handy in using vba. :?
I found here a description how to do this with ado http://support.micro...b/257819/EN-US/
Is there someone who has a working example for me, how to realize this with ws4ahk.ahk?
I found here a description how to do this with ado http://support.micro...b/257819/EN-US/
Is there someone who has a working example for me, how to realize this with ws4ahk.ahk?
#37
-
Posted 14 October 2007 - 02:09 PM
Hmm, I can't say I know much about using ADO. You might find more help with ADO on a VB specific board. Once you are able to get some working VB code, then I would be happy to help you modify it for ws4ahk.
#38
-
Posted 15 October 2007 - 08:45 PM
-m35
indeed, Andi, please report back once you've figured it out! ADO looks really cool. as for ws4ahk .. it lets you run VB scripts from AHK.. but unfortunately... it doesn't yet code up the VB scripts for you... :roll:
#39
-
Posted 16 October 2007 - 12:54 AM
Joyce Jamce
Hi, erictheturtle
Can you explain me how to call correctly the XL_OpenDile function correctly.
I can't succeed, I don't know why.
Can you explain me how to call correctly the XL_OpenDile function correctly.
I can't succeed, I don't know why.
WS_Initialize() XL_VBCode = ( Const adOpenStatic = 3 Const adLockOptimistic = 3 Const adCmdText = &H0001 Dim objConnection, objRecordSet, XL_ADO_SheetRange, XL_ADO_SQLStat, XL_ADO_StatHDR, XL_ADO_TargetFile, i Sub XL_OpenConnexion Set objConnection = CreateObject("ADODB.Connection") Set objRecordSet = CreateObject("ADODB.Recordset") End Sub Sub XL_OpenFile(XL_ADO_TargetFile, XL_ADO_StatHDR) ' objConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & XL_ADO_TargetFile & ";Extended Properties=""Excel 8.0;HDR=" . XL_ADO_StatHDR . ";"";" End Sub ) WS_Exec(XL_VBCode) WS_Exec("XL_OpenConnexion") XL_ADO_File := "Try.xls" XL_ADO_TargetFile := A_ScriptDir . "\" . XL_ADO_File XL_ADO_StatHDR := "YES" WS_Exec("XL_OpenFile " . VBStr(XL_ADO_TargetFile) . "," . VBStr(XL_ADO_StatHDR)) msgbox %ErrorLevel%Thanks by advance
#41
-
Posted 17 November 2007 - 04:19 PM
Sub XL_OpenFile(XL_ADO_TargetFile, XL_ADO_StatHDR) objConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & XL_ADO_TargetFile & ";Extended Properties=""Excel 8.0;HDR=" [color=red]&[/color] XL_ADO_StatHDR [color=red]&[/color] ";"";" EndYour code looks very good. The only problem I see is the use of periods in the VB code for concatenating. If you change these periods to ampersands, does that get it working?
#42
-
Posted 17 November 2007 - 05:16 PM
-m35
Thanks erictheturtle,
It seems to work. It was an error of inattention.
If the prog work, I'll publish it, of course...
It seems to work. It was an error of inattention.
If the prog work, I'll publish it, of course...
#43
-
Posted 17 November 2007 - 05:52 PM
Ahhhhh.... This is awesome!
My head hurts trying to understand how you got to this point and that includes Sean's raw COM. However, the functionality of this is what I always wanted to see in AutoHotkey.
I think raw com (thanks Sean) or this method to embed jscript and vbscript are the best ways.
I've always voted for embedding jscript or vbscript into AutoHotkey for dealing with COM, versus AutoHotkey making up its on syntax. This is because there is a HUGE amount of information and scripts already for jscript and vbscript. Why re-invent the wheel? Why do over something that has already been done, just to have your "flavor" of it.
I like sean's raw com too, because you can or at least try to see how COM works. Its a good study in addition as a way to shorten COM related code. However, it can make your head hurt. So the embedded method is their to help you relax.
AutoHotkey, to me, is about doing things the easy way or quickly. When an AutoHotkey user, that is not an experienced or professional programmer, comes across problems in which COM is the solution than he can now (thanks to this script) see what's out there in vbscript and jscript. Often finding a solution that has already been thought of. He can integrate that into his AutoHotkey script and keep moving.
If he wants to know more about COM than there is just this huge load of information and examples in vbscript and jscript to teach him. It allows you to take all the expertise, debating on the best way, and history of vbscript and jscript and make use of it.
Even looking at the AutoIt implementation of COM, they often do a lot of converting or copying from vbscript to AutoIt's version of it. You are then jumping back and forth between different flavors of doing COM. How do I re-create this vbscript the AutoIt way?
The only way I could see having AutoHotkey syntax for doing COM being an advantage is that it was easier to use or understand. Another argument on how to do it would be to create a syntax so close to vbscript, that you would be hard pressed to know the difference.
The other advantage of embedding, is you can look to this method to include other script and programming languages to work in a more integrated manner with AutoHotkey. When you can't do something in AutoHotkey, than you can reach out and grab something "off the shelf" so to speak to do what you want done. I also think that was part of Microsoft's point, to use their scripting language with your programming language, when they created the Windows Scripting Control.
Related COM topics-
<!-- m -->https://ahknet.autoh...y.com/~easycom/<!-- m -->
<!-- m -->http://www.autohotke... ... sc&start=0<!-- m --> ( Easycom.dll )
<!-- m -->http://www.autohotke... ... sc&start=0<!-- m --> ( COM standard library )
<!-- m -->http://www.autohotke... ... 65&start=0<!-- m --> ( ADO COM )
<!-- m -->http://www.autohotke... ... 31&start=0<!-- m --> ( COM Helper )
<!-- m -->http://www.microsoft... ... laylang=en<!-- m -->
<!-- m -->http://www.codeguru.... ... e.php/c15/<!-- m -->
<!-- m -->http://en.wikipedia....ows_Script_Host<!-- m -->
<!-- m -->http://en.wikipedia....eX_Data_Objects<!-- m -->
My head hurts trying to understand how you got to this point and that includes Sean's raw COM. However, the functionality of this is what I always wanted to see in AutoHotkey.
I think raw com (thanks Sean) or this method to embed jscript and vbscript are the best ways.
I've always voted for embedding jscript or vbscript into AutoHotkey for dealing with COM, versus AutoHotkey making up its on syntax. This is because there is a HUGE amount of information and scripts already for jscript and vbscript. Why re-invent the wheel? Why do over something that has already been done, just to have your "flavor" of it.
I like sean's raw com too, because you can or at least try to see how COM works. Its a good study in addition as a way to shorten COM related code. However, it can make your head hurt. So the embedded method is their to help you relax.
AutoHotkey, to me, is about doing things the easy way or quickly. When an AutoHotkey user, that is not an experienced or professional programmer, comes across problems in which COM is the solution than he can now (thanks to this script) see what's out there in vbscript and jscript. Often finding a solution that has already been thought of. He can integrate that into his AutoHotkey script and keep moving.
If he wants to know more about COM than there is just this huge load of information and examples in vbscript and jscript to teach him. It allows you to take all the expertise, debating on the best way, and history of vbscript and jscript and make use of it.
Even looking at the AutoIt implementation of COM, they often do a lot of converting or copying from vbscript to AutoIt's version of it. You are then jumping back and forth between different flavors of doing COM. How do I re-create this vbscript the AutoIt way?
The only way I could see having AutoHotkey syntax for doing COM being an advantage is that it was easier to use or understand. Another argument on how to do it would be to create a syntax so close to vbscript, that you would be hard pressed to know the difference.
The other advantage of embedding, is you can look to this method to include other script and programming languages to work in a more integrated manner with AutoHotkey. When you can't do something in AutoHotkey, than you can reach out and grab something "off the shelf" so to speak to do what you want done. I also think that was part of Microsoft's point, to use their scripting language with your programming language, when they created the Windows Scripting Control.
Related COM topics-
<!-- m -->https://ahknet.autoh...y.com/~easycom/<!-- m -->
<!-- m -->http://www.autohotke... ... sc&start=0<!-- m --> ( Easycom.dll )
<!-- m -->http://www.autohotke... ... sc&start=0<!-- m --> ( COM standard library )
<!-- m -->http://www.autohotke... ... 65&start=0<!-- m --> ( ADO COM )
<!-- m -->http://www.autohotke... ... 31&start=0<!-- m --> ( COM Helper )
<!-- m -->http://www.microsoft... ... laylang=en<!-- m -->
<!-- m -->http://www.codeguru.... ... e.php/c15/<!-- m -->
<!-- m -->http://en.wikipedia....ows_Script_Host<!-- m -->
<!-- m -->http://en.wikipedia....eX_Data_Objects<!-- m -->
#44
-
Posted 30 November 2007 - 10:15 AM