 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
YMP
Joined: 23 Dec 2006 Posts: 266 Location: Russia
|
Posted: Sun Aug 19, 2007 4:16 am Post subject: |
|
|
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: |
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. |
|
| Back to top |
|
 |
user
Joined: 05 Oct 2006 Posts: 423
|
Posted: Sun Aug 19, 2007 1:51 pm Post subject: |
|
|
| it looks very nice |
|
| Back to top |
|
 |
erictheturtle
Joined: 27 Jun 2007 Posts: 58 Location: California
|
Posted: Sun Aug 19, 2007 3:38 pm Post subject: |
|
|
| YMP wrote: | 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: |
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. |
Wow YMP, thanks for reporting this. What a very odd bug. Here are some of the things I've tried:- The bug seems to occur when the timeout value is >=1.5 seconds (the timeout works correctly at 1.49999).
- Using WS_Initialize("VBScript") and changing the code to VBScript still produces the bug.
- Putting that JScript or VBScript code directly into a .js or .vbs file directly does not produce the bug.
- Putting that VBScript code in Excel VBA does not produce the bug.
- Using Microsoft Scripting Control in a .vbs script to run this code does not produce this bug.
- 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. _________________ -m35 |
|
| Back to top |
|
 |
erictheturtle
Joined: 27 Jun 2007 Posts: 58 Location: California
|
Posted: Sun Aug 19, 2007 4:29 pm Post subject: |
|
|
| BoBoĻ wrote: | @ erictheturtle
I thought about to (slightly) improve the GUI of WS_DEDemo2.ahk.
Well, desperately waiting for your sign off :)
| Code: | 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 |
|
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).
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. _________________ -m35 |
|
| Back to top |
|
 |
YMP
Joined: 23 Dec 2006 Posts: 266 Location: Russia
|
Posted: Mon Aug 20, 2007 4:59 am Post subject: |
|
|
| erictheturtle wrote: |
So congratulations on finding a bug no one has ever seen before |
Oh, great indeed! It's an honour to me.
| Quote: |
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. |
No doubt. AHK forever! Besides, with 1, the Popup dialog actually stays about 2 seconds. Enough time to read a short message, I believe.
Thanks for the detailed reply (and for ws4ahk, of course!!). |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10467
|
|
| Back to top |
|
 |
Andi
Joined: 11 Feb 2005 Posts: 153 Location: Germany, Niestetal
|
Posted: Sun Oct 14, 2007 3:09 pm Post subject: |
|
|
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.microsoft.com/kb/257819/EN-US/
Is there someone who has a working example for me, how to realize this with ws4ahk.ahk?  |
|
| Back to top |
|
 |
erictheturtle
Joined: 27 Jun 2007 Posts: 58 Location: California
|
Posted: Mon Oct 15, 2007 9:45 pm Post subject: |
|
|
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. _________________ -m35 |
|
| Back to top |
|
 |
Joy2DWorld
Joined: 04 Dec 2006 Posts: 422 Location: Galil, Israel
|
Posted: Tue Oct 16, 2007 1:54 am Post subject: |
|
|
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...  _________________ Joyce Jamce |
|
| Back to top |
|
 |
Guest
|
Posted: Wed Oct 17, 2007 2:51 pm Post subject: |
|
|
ADO COM  |
|
| Back to top |
|
 |
Zoulou Guest
|
Posted: Sat Nov 17, 2007 5:19 pm Post subject: |
|
|
Hi, erictheturtle
Can you explain me how to call correctly the XL_OpenDile function correctly.
I can't succeed, I don't know why.
| Code: | 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 |
|
| Back to top |
|
 |
erictheturtle
Joined: 27 Jun 2007 Posts: 58 Location: California
|
Posted: Sat Nov 17, 2007 6:16 pm Post subject: |
|
|
| Code: | 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 |
Your 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? _________________ -m35 |
|
| Back to top |
|
 |
Zoulou Guest
|
Posted: Sat Nov 17, 2007 6:52 pm Post subject: |
|
|
Thanks erictheturtle,
It seems to work. It was an error of inattention.
If the prog work, I'll publish it, of course... |
|
| Back to top |
|
 |
AHKnow
Joined: 03 Jul 2004 Posts: 118
|
Posted: Fri Nov 30, 2007 11:15 am Post subject: |
|
|
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-
http://www.autohotkey.net/~easycom/
http://www.autohotkey.com/forum/viewtopic.php?t=20765&postdays=0&postorder=asc&start=0 ( Easycom.dll )
http://www.autohotkey.com/forum/viewtopic.php?t=22923&postdays=0&postorder=asc&start=0 ( COM standard library )
http://www.autohotkey.com/forum/viewtopic.php?t=16565&start=0 ( ADO COM )
http://www.autohotkey.com/forum/viewtopic.php?t=16631&start=0 ( COM Helper )
http://www.microsoft.com/downloads/details.aspx?FamilyId=D7E31492-2595-49E6-8C02-1426FEC693AC&displaylang=en
http://www.codeguru.com/cpp/com-tech/atl/scripting/article.php/c15/
http://en.wikipedia.org/wiki/Windows_Script_Host
http://en.wikipedia.org/wiki/ActiveX_Data_Objects |
|
| Back to top |
|
 |
AHKnow
Joined: 03 Jul 2004 Posts: 118
|
Posted: Fri Nov 30, 2007 1:02 pm Post subject: |
|
|
Would like to see examples of ws4ahk.ahk working with Microsoft Access databases. Definitely have to play with that. |
|
| 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
|