| View previous topic :: View next topic |
| Author |
Message |
tov Guest
|
Posted: Wed May 12, 2010 5:16 pm Post subject: |
|
|
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  |
|
| Back to top |
|
 |
tov Guest
|
Posted: Wed May 12, 2010 5:20 pm Post subject: |
|
|
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() |
|
|
| Back to top |
|
 |
The Unknown Jobber
Joined: 19 Nov 2009 Posts: 161 Location: Florida
|
Posted: Wed Jul 21, 2010 3:18 pm Post subject: |
|
|
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.... |
|
| Back to top |
|
 |
erictheturtle
Joined: 27 Jun 2007 Posts: 101 Location: California
|
Posted: Wed Jul 21, 2010 3:26 pm Post subject: |
|
|
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 |
|
| Back to top |
|
 |
The Unknown Jobber
Joined: 19 Nov 2009 Posts: 161 Location: Florida
|
Posted: Wed Jul 21, 2010 3:35 pm Post subject: |
|
|
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) |
|
| Back to top |
|
 |
a4u Guest
|
|
| Back to top |
|
 |
RoAltmann
Joined: 26 May 2009 Posts: 15
|
Posted: Fri Aug 20, 2010 8:44 am Post subject: Using Object in different scripts? |
|
|
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 |
|
| Back to top |
|
 |
tank
Joined: 21 Dec 2007 Posts: 3700 Location: Louisville KY USA
|
Posted: Fri Aug 20, 2010 11:11 am Post subject: |
|
|
I am fairly certain that WSH does no multi threading also so your code would have to wait in line any how _________________
We are troubled on every side‚ yet not distressed; we are perplexed‚
but not in despair; Persecuted‚ but not forsaken; cast down‚ but not destroyed; |
|
| Back to top |
|
 |
erictheturtle
Joined: 27 Jun 2007 Posts: 101 Location: California
|
Posted: Fri Aug 20, 2010 7:38 pm Post subject: Re: Using Object in different scripts? |
|
|
| 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 |
|
| Back to top |
|
 |
RoAltmann
Joined: 26 May 2009 Posts: 15
|
Posted: Sun Aug 22, 2010 11:24 am Post subject: |
|
|
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 |
|
| Back to top |
|
 |
erictheturtle
Joined: 27 Jun 2007 Posts: 101 Location: California
|
Posted: Sun Aug 22, 2010 12:23 pm Post subject: |
|
|
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 |
|
| Back to top |
|
 |
RoAltmann
Joined: 26 May 2009 Posts: 15
|
Posted: Mon Aug 23, 2010 6:53 pm Post subject: |
|
|
Thanks for your answer.
I will have to find a different way to solve my problem.
Regards, Robert |
|
| Back to top |
|
 |
ahk_issue Guest
|
Posted: Fri Nov 12, 2010 9:07 am Post subject: |
|
|
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 |
|
| Back to top |
|
 |
ahk_issue Guest
|
Posted: Fri Nov 12, 2010 10:23 am Post subject: |
|
|
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 ? |
|
| Back to top |
|
 |
erictheturtle
Joined: 27 Jun 2007 Posts: 101 Location: California
|
Posted: Fri Nov 12, 2010 10:38 am Post subject: |
|
|
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 |
|
| Back to top |
|
 |
|