AutoHotkey Community

It is currently May 27th, 2012, 3:41 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 232 posts ]  Go to page Previous  1 ... 11, 12, 13, 14, 15, 16  Next
Author Message
 Post subject:
PostPosted: May 12th, 2010, 6:16 pm 
using this as my example, how do I pass a string value out of VBS back to AHK ?

Code:
 #Include ws4ahk.ahk
 WS_Initialize()
 USERNAME := "<something>"
 PASSWORD := "<something>"
 IPADDRESS := "<something>"
    Code =
    (
      Set objSO = CreateObject("SuperOffice.Application")
      Set ado = CreateObject("ADODB.Connection")
      ado.Provider = "ADSDSOObject"
      ado.Properties("User ID") = "%USERNAME%"
      ado.Properties("Password") = "%PASSWORD%"
      serverName = "%IPADDRESS%:386"
      strFileDate = "file_date" + "%A_DD%.%A_MM%.%A_YYYY%"
    )

 WS_Exec(Code)
 WS_ReleaseObject(Code)
 WS_Uninitialize()


How do I get strFileDate back into AHK and then use it ? Thanks :)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: May 12th, 2010, 6:20 pm 
Replying to my own post - bad...

Code:
#Include ws4ahk.ahk
 WS_Initialize()
 USERNAME := "<something>"
 PASSWORD := "<something>"
 IPADDRESS := "<something>"
    Code =
    (
      Set objSO = CreateObject("SuperOffice.Application")
      Set ado = CreateObject("ADODB.Connection")
      ado.Provider = "ADSDSOObject"
      ado.Properties("User ID") = "%USERNAME%"
      ado.Properties("Password") = "%PASSWORD%"
      serverName = "%IPADDRESS%:386"
      strFileDate = "file_date" + "%A_DD%.%A_MM%.%A_YYYY%"
    )

 WS_Exec(Code)
 
WS_Eval(FileDate, "strFileDate")
 msgbox, %FileDate%


 WS_ReleaseObject(Code)
 WS_Uninitialize()


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: July 21st, 2010, 4:18 pm 
Offline

Joined: November 19th, 2009, 6:23 pm
Posts: 163
Location: Florida
I don't know if this would be of use to anyone, I tried searching on how to get an array out of vb script into ahk but this is what I came up with that worked...

well with this I'm putting something in an array then extracting it into AHK, this can be useful if you're looking up how many people in a list that starts with the last name G or something like that...

Code:
WS_Initialize("VBScript")

Code =
(
Dim index
Dim foo(10)

index=0

While index <= 10
   foo(index) = "bar " & index
   index = index + 1
Wend
)

WS_Exec(Code)

Loop, 10
{
   WS_Eval(bar%A_Index%, "foo(" A_Index ")")
   MsgBox % bar%A_Index%
}

WS_ReleaseObject(Code)
WS_Uninitialize()

if you can understand what I'm trying to say LOL

If this was already figured out let me know and I'll remove this....


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 21st, 2010, 4:26 pm 
Offline

Joined: June 27th, 2007, 9:07 pm
Posts: 101
Location: California
So far this is the first I've seen anyone trying to pass arrays between environments. You got the right idea, although the
Code:
WS_ReleaseObject(Code)
line shouldn't be there (could crash the program).

An alternative approach might be to join all the array items together in a comma-delimited string, then split up the string in AHK. Although that gets tricky if the array items contained commas, so your approach is more robust.

_________________
-m35


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 21st, 2010, 4:35 pm 
Offline

Joined: November 19th, 2009, 6:23 pm
Posts: 163
Location: Florida
something like this?

Code:
WS_Initialize("VBScript")

Code =
(
Dim index
Dim foo

index=0

While index <= 10
   foo = "bar " & index & "," & foo
   index = index + 1
Wend
Msgbox foo
)

WS_Exec(Code)
WS_Eval(thebar, "foo")

Sort, thebar, D,

Loop, Parse, thebar, `,
   MsgBox % A_LoopField

WS_Uninitialize()


as long as you escape the comma in the loop parse you should be ok.. I'm suprised in the sort line though it sorted the way I wanted it to

and yeah you're right about the release, although it never crashed my ahk (yet)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 21st, 2010, 7:21 pm 
Quote:
So far this is the first I've seen anyone trying to pass arrays between environments.

This had been attemped to an extent here: Arrays using ws4ahk, & Dictionary\Array Objects


Report this post
Top
  
Reply with quote  
PostPosted: August 20th, 2010, 9:44 am 
Offline

Joined: May 26th, 2009, 10:32 am
Posts: 20
Maybe somebody can help me:

I have 2 scripts:

script "A" creates an object and passes the object to script "B" to start any action.

Background information:

Since AHK does no multi-threading I would like to use all off my CPUs by doing some actions one the same object with different parameters in parallel.

Many thanks in advance.
Robert


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 20th, 2010, 12:11 pm 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
I am fairly certain that WSH does no multi threading also so your code would have to wait in line any how

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


Report this post
Top
 Profile  
Reply with quote  
PostPosted: August 20th, 2010, 8:38 pm 
Offline

Joined: June 27th, 2007, 9:07 pm
Posts: 101
Location: California
RoAltmann wrote:
Since AHK does no multi-threading I would like to use all off my CPUs by doing some actions one the same object with different parameters in parallel.

Unfortunately I don't know any way to use do multi-threading with the Windows Scripting Control (that ws4ahk uses). My best guess is that it can't be done.

_________________
-m35


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 22nd, 2010, 12:24 pm 
Offline

Joined: May 26th, 2009, 10:32 am
Posts: 20
Is it possible to do something like this?

Script a.ahk (not realy a script, just to show, what I want to do):
Code:
WS_inititialise()
Code= "MyObj = Object.Create("MyApp.Object")"
WS_Exec(Code)
WS_Eval(Obj","MyObj")
RunScriptB(Obj,"CommandA")
RunScriptB(Obj,"CommandB")
RunScriptB(Obj,"CommandC")
ExitAPP
RunScriptB(Obj,Command)
{
  Run, Autohotkey.exe b.ahk %Obj% %Command%
}



Script b.ahk:
Code:
WS_initialise()
MyObj :=%1
MyCmd := %2

Code=
(
 Set MyObj = %MyObj%
 MyObj.Process %MyCmd%
)
WS_Exec(Code)
ExitApp


Regards Robert


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 22nd, 2010, 1:23 pm 
Offline

Joined: June 27th, 2007, 9:07 pm
Posts: 101
Location: California
I'm seeing several errors in your code, but I understand what you're trying to do, and there's no way that would work. You would have to do some very impressive hacking to share objects in memory between two processes.

If you absolutely must run a multi-threaded/multi-process task, I can only suggest the different threads/processes communicate via pipes (stdin/out), Window messages, writing and reading files, or networking. But in all those cases, it's still impossible to share objects in memory. You would only be able to send data, and each thread/process would have to do what it needed to create objects with that data.

_________________
-m35


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 23rd, 2010, 7:53 pm 
Offline

Joined: May 26th, 2009, 10:32 am
Posts: 20
Thanks for your answer.

I will have to find a different way to solve my problem.

Regards, Robert


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 12th, 2010, 10:07 am 
Hi
I'm using ws4ahk.ahk with in a script and it works well.

How every I occasionally get a pop up saying :

Quote:
The script you are executing is taking longer than expected to run. Click End to abort the script, or Continue to continue script execution.


Is there anyway to increase the timeout on the script to stop this happening ?
I'm hoping this is something with in ws4ahk !! ?

Thanks


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 12th, 2010, 11:23 am 
I've tried adding:
Code:
Set cmd = CreateObject("ADODB.Command")
    cmd.CommandTimeout = 600


But that doesn't work !!

I'm testing using this:
Code:
#Include ws4ahk.ahk
 WS_Initialize()
 USERNAME := "<something>"
 PASSWORD := "<something>"
 IPADDRESS := "<something>"
    Code =
    (
      Set objSO = CreateObject("SuperOffice.Application")
      Set ado = CreateObject("ADODB.Connection")
      ado.Provider = "ADSDSOObject"
      ado.Properties("User ID") = "%USERNAME%"
      ado.Properties("Password") = "%PASSWORD%"
      serverName = "%IPADDRESS%:386"
      strFileDate = "file_date" + "%A_DD%.%A_MM%.%A_YYYY%"
    )

 WS_Exec(Code)
 
WS_Eval(FileDate, "strFileDate")
 msgbox, %FileDate%

 WS_ReleaseObject(Code)
 WS_Uninitialize()


Any ideas ?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 12th, 2010, 11:38 am 
Offline

Joined: June 27th, 2007, 9:07 pm
Posts: 101
Location: California
Adding this extra function should let you set the timeout.

Code:
; Set timeout in milliseconds
SetTimeout(iTimeout)
{
   global __WS_iScriptControlObj__
   iErr := DllCall(__WS_VTable(__WS_iScriptControlObj__, 14), "UInt", __WS_iScriptControlObj__
            , "Int", iTimeout
            , "Int")
}


; ------  Test -----------

#include ws4ahk.ahk

WS_Initialize()

SetTimeout(20 * 1000) ; 20 seconds

; Loop for a long time
sCode =
(
For i = 1 to 100000
   For j = 1 to 10000
   Next
Next
)

WS_Exec(sCode)

_________________
-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 ... 11, 12, 13, 14, 15, 16  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: xXDarknessXx and 15 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