AutoHotkey Community

It is currently May 26th, 2012, 12:27 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 232 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6, 7 ... 16  Next
Author Message
 Post subject:
PostPosted: November 30th, 2007, 7:17 pm 
Offline

Joined: June 27th, 2007, 9:07 pm
Posts: 101
Location: California
Thanks AHKnow for the very thorough review. Much of what you have expressed is exactly what I've thought myself. Those are some good links you've gathered as well.

I wish I could offer help with ADO, but I've never used it before. I know a simple google search brings up many examples.

This weekend I think I'll pull myself away from my other projects and update ws4ahk to a stdlib-ready version.

_________________
-m35


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 8th, 2007, 5:51 am 
Offline

Joined: June 27th, 2007, 9:07 pm
Posts: 101
Location: California
Major update of ws4ahk.

Now finally in the tenths digit: v0.11 :)

Full documentation also included.

Check out the home page for brief list of changes.
http://www.autohotkey.net/~easycom/

_________________
-m35


Last edited by erictheturtle on December 8th, 2007, 8:28 pm, edited 2 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 8th, 2007, 8:41 am 
That is awesome. AutoHotkey does come well, thanks to scripts like this and the author.

Great work!


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: December 8th, 2007, 11:50 pm 
Offline

Joined: December 4th, 2006, 10:35 am
Posts: 561
Location: Galil, Israel
two tiny suggest:

your library is "WS",

*everything* GLOBAL in that library should be "WS_"


so.. "__IUnknown_Release(ppv)" won't conflict with another "__IUnknown_Release()" function in someone's script, keep it within your library... ie. "WS__IUnknown_Release(ppv)"


this way,

there will NEVER BE A CONFLICT WITH ANY OTHER LIBRARY/FUNCTION..


include your webpage address in the function notes...


hope is helpful.

_________________
Joyce Jamce


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 9th, 2007, 4:25 pm 
Hi, erictheturtle
I tried
Code:
WS_Initialize()
pWord := WS_GetObject("Word.Application")
clipboard := ErrorLevel . ";" . pWord
WS_UnInitialize()
and it works perfecly. But I think you know is it possible, in VBScript, to specify a file name to know if the file is loaded in Word (in this case). The syntax of GetObject is : GetObject([pathname] [, class])
So, if pWord := WS_GetObject("Word.Application") works great,
pWord := WS_GetObject("Z:\Try.doc") should work,
and pWord := WS_GetObject("Z:\Try.doc,Word.Application") too, but no one of the two last forms works.
The error code in ErrorLevel is "-2147221005 (800401F3) incorrect class string"
Please where is the problem ? Is it a problem with the Microsoft Scripting Control ?
Is there a solution ? If it is, which one please ?
Thanks by advance


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: December 9th, 2007, 8:03 pm 
Offline

Joined: June 27th, 2007, 9:07 pm
Posts: 101
Location: California
Sorry WashBoard, ws4ahk's WS_GetObject() function doesn't provide a way to create an object from a file.

ws4ahk syntax:
Code:
WS_GetObject(sProgIDorClassID [, sInterfaceID = IDispatch ] ) ; the sInterfaceID parameter can usually be ignored
VB syntax:
Code:
GetObject([pathname] [, class])


The work around would be to use VBScript to get the object.

Code:
WS_Eval(pWord, "GetObject(""Try.doc"")")


; could also be written other ways:

; * put the code in a variable before evaluating it (no need to escape quotes)
sCreateObjCode =
(
    GetObject("Try.doc")
)
WS_Eval(pWord, sCreateObjCode)

; * use the printf style (if you're comfortable with it)
; woops! a ws4ahk bug prevents this from working.
; Edit: this is now fixed in v0.12!
WS_Eval(pWord, "GetObject(%s)", "Try.doc")

; * using the VBStr function (not helpful in this case)
WS_Eval(pWord, "GetObject(" . VBStr("Try.doc") . ")")



I spent about an hour searching for what VB's GetObject() function does internally, but couldn't find anything except this little snippit
http://www.cgoakley.demon.co.uk/prog/oleaut.html wrote:
GetObject will not be explored here. Suffice it to say that it uses non-automation OLE interfaces to read an object from a file, or other persistent storage.

It also seems that Python's COM libraries don't provide the VB style GetObject function either. Could this functionality be so complicated that even Python doesn't mess with it?

So I have no idea how VB's can get an object from a file. If anyone knows, maybe this feature can be added to ws4ahk.

_________________
-m35


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 9th, 2007, 10:09 pm 
Thanks, erictheturtle, for your works.
The first one, of course, Ws4Ahk.
The second one, your work on my question. Your aswer is very instructive.

I made, too, some trys.
After a certain number of trys, the syntax
Code:
GetObject([pathname] [, class])
is effectively not supported by Ws4Ahk, but this one
Code:
GetObject([pathname])
yes (I made many trys...).

My results :
With the syntax :
Code:
myDoc := "D:\Try.doc"
ppWord := WS_Eval(pWord, "GetObject(%s)", myDoc)
or
ppWord := WS_Eval(pWord, "GetObject(%s)", VBStr(myDoc))
I had no success.

With the syntax :
Code:
myDoc := "D:\Try.doc"
ppWord := WS_Eval(pWord, "GetObject(" . VBStr(myDoc) . ")")
, if Word is launched and it has the file loaded in it, success...
But, surprise, if Word is launched but empty or when Word is not launched at all, the result is ... success !!! If Word is empty, the file isn't loaded in it...
So GetObject seems to try to launch the file in Word but seems to not do it... Strange...
If I try with a doc file with macros in it, I have the window to choose to activate them or not. When I go to Word to see if the file is loaded, I don't see anything... Is it loaded in invisibly mode ? I don't know... I can make any choice (activate the macros or not, cancel), the file is not displayed in Word if it is launched... But the same window (choice to activate macros or not) appears even if there isn't any Word instance launched...

With the syntax
Code:
myDoc := "D:\Try.doc"
sCreateObjCode =
(
    GetObject("%myDoc%")
)
ppWord := WS_Eval(pWord, sCreateObjCode)
the results are the same.

So for me the solution is probably to verify with AHK commands if there is a Word window which exists with the file name I want to use, and after to use one of these syntaxes to act on the file if it is already loaded in Word.

Thanks again, erictheturtle, for your beautifull work and your nice help.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: December 10th, 2007, 8:17 pm 
Offline

Joined: June 27th, 2007, 9:07 pm
Posts: 101
Location: California
Thank you Washboard, I'm glad you're finding some use in ws4ahk.

Washboard wrote:
With the syntax :
Code:
myDoc := "D:\Try.doc"
ppWord := WS_Eval(pWord, "GetObject(%s)", myDoc) ; correct
or
ppWord := WS_Eval(pWord, "GetObject(%s)", VBStr(myDoc)) ; xx incorrect
I had no success.

The first syntax is the correct one. Did you try this with the new v0.12? It should work the same as your other examples now.

Washboard wrote:
With the syntax :
Code:
myDoc := "D:\Try.doc"
ppWord := WS_Eval(pWord, "GetObject(" . VBStr(myDoc) . ")")
...
With the syntax
Code:
myDoc := "D:\Try.doc"
sCreateObjCode =
(
    GetObject("%myDoc%")
)
ppWord := WS_Eval(pWord, sCreateObjCode)
the results are the same.

I didn't specifically mention it in my previous post, but all 3 of those bits of Autohotkey code will execute the exact same VBScript code. I just provided the 3 different AHK syntaxes to give you (and others) options. Use whichever one you are most comfortable with.

While all of your examples will work, I see you use "ppWord := WS_Eval(...)". The syntax of WS_Eval is
Code:
blnSuccess := WS_Eval(ByRef ReturnValue, sScriptCode [, values for %v or %s])
so after the call, ppWord will hold True or False. Is this what you were intending?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 10th, 2007, 9:28 pm 
erictheturtle wrote:
Did you try this with the new v0.12? It should work the same as your other examples now.
I see it now. I will try.
erictheturtle wrote:
I just provided the 3 different AHK syntaxes to give you (and others) options. Use whichever one you are most comfortable with.
I understood. Thanks for giving us the choice. IMO, I prefer the second syntax...
erictheturtle wrote:
so after the call, ppWord will hold True or False. Is this what you were intending?
Yes absolutely, for try purpose. I put pWord, ppWord and ErrorLevel in the clipboard to test them and see what are the return values.

Concerning the strange behavior I spoke about (when you test if the file is loaded in Word and there isn't any active Word instance or an instance without the file loaded in it, it seems that there are trys to load the file and the result of the function is positive), it seems that it's a VBScript itself behavior.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: December 21st, 2007, 2:19 am 
@erictheturtle

Im absolutely enthralled
one very important question
Code:
#Include ws4ahk.ahk
WS_Initialize()
Code =
(
Dim foo1
foo1 = "bar"
)
WS_Exec(Code)

         

this will of course create a visual basic variable called foo1
i would like to retreive the value "bar" and use it in ahk script
conceptually to set a edit feild with the value arrived at from vb
unfortuanately this is part of something larger im working and vb is the only language i can interact with another application with
(local pc policy) if that even sounds reasonable


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: December 21st, 2007, 6:56 am 
Offline

Joined: June 27th, 2007, 9:07 pm
Posts: 101
Location: California
If I understand what you are saying, then the WS_Eval() function is what you need.

Code:
#Include ws4ahk.ahk
WS_Initialize()
Code =
(
Dim foo1
foo1 = "bar"
)
WS_Exec(Code)

WS_Eval(getval, "foo1")

Msgbox % getval ; displays a message box with 'bar'

Hope this provides what you are looking for.

Note: I'm out of town for winter vacation starting tomorrow, so I can't say when I may be able to post additional replies. If I'm not back before new years, happy holidays everyone!

_________________
-m35


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 21st, 2007, 7:45 pm 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
erictheturtle, you are definitely a man that knows his business
You did accurately interpret my question
FYI
I have VB code almost 2000 lines for interacting with a very archaic system and only respond well to VB
Some of the functions scrape data off a terminal application and store those values in a variable.
Without this answer i was going to have to abandon my current project all together, as some of these values were for error checking within the app. Others were to post results to a GUI form I’m creating with AHK
The app in question will be used in a call center of a bank.
:D :P

_________________
No matter what your oppinion Please join this discussion
Formal request to Polyethene
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 23rd, 2007, 9:41 am 
Offline

Joined: June 27th, 2007, 9:07 pm
Posts: 101
Location: California
Glad you've making progress with your program tank.

ws4ahk has been updated v0.13, which adds some missing error handling, and a few comments improvements/corrections.

Don't forget, ws4ahk is still considered beta software. While I try my best to ensure quality, it can't be guaranteed to be wholly reliable.

_________________
-m35


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 24th, 2007, 3:00 pm 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
well understood however i test every script I write to fault. actually given the extent that I plan to utilize it ill follow up with you if I find anything in the way of consistent unusually behavior. Some of my vb code will be moved to ahk script.

_________________
No matter what your oppinion Please join this discussion
Formal request to Polyethene
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 24th, 2008, 7:04 am 
Offline

Joined: June 27th, 2007, 9:07 pm
Posts: 101
Location: California
ws4ahk 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.

Note that if you are using the printf style in WS_Exec or WS_Eval (I doubt anyone is), you will need to slightly modify your code to use the new codef() function.

_________________
-m35


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 232 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6, 7 ... 16  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Klark92 and 35 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group