AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CMDret - AHK functions
Goto page Previous  1, 2, 3 ... 8, 9, 10, 11, 12  Next
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
majkinetor



Joined: 24 May 2006
Posts: 3652
Location: Belgrade

PostPosted: Tue Feb 27, 2007 8:07 am    Post subject: Reply with quote

Supporting concurency is not such a big problem with static arrays.

The bigger problem lays in the fact that if the user creates handler that is longer then timer, the sentence will not be received (here, at least, and my handler wasn't much extensive, 1 - Tooltip, 1-GuiControl; when I removed GuiControl line I received the first line, when I set it on, first line was never received). So you will probably need to buffer data .... and + concurancy = buffering multiple set of data.

I suggest you forget about it, and just leave it like it is, maybe buffer some data if gosub didn't return on your "next pipe message". Its much more important that in single process, this work reliable.
_________________
Back to top
View user's profile Send private message MSN Messenger
corrupt



Joined: 29 Dec 2004
Posts: 2436

PostPosted: Tue Feb 27, 2007 9:56 am    Post subject: Reply with quote

Out of curiosity, does that also happen with the version I posted? That was the reason behind buffering the data using the timer and additional function but I originally had a few more If statements with a previous version that didn't seem necessary that were removed in the current version. I used a few test scripts that used different methods for processing each line retrieved but haven't done extensive testing...
Back to top
View user's profile Send private message Visit poster's website
majkinetor



Joined: 24 May 2006
Posts: 3652
Location: Belgrade

PostPosted: Tue Feb 27, 2007 7:13 pm    Post subject: Reply with quote

cant say now.... i used my version from above

we can test this during weekend if you want, using IM
_________________
Back to top
View user's profile Send private message MSN Messenger
corrupt



Joined: 29 Dec 2004
Posts: 2436

PostPosted: Thu Mar 01, 2007 7:38 am    Post subject: Reply with quote

majkinetor wrote:
we can test this during weekend if you want, using IM
Sounds good. I'll likely be on ICQ if you're available sometime during the weekend.
Back to top
View user's profile Send private message Visit poster's website
majkinetor



Joined: 24 May 2006
Posts: 3652
Location: Belgrade

PostPosted: Thu Mar 01, 2007 8:04 am    Post subject: Reply with quote

Okay
_________________
Back to top
View user's profile Send private message MSN Messenger
W2k4EVER



Joined: 02 Mar 2007
Posts: 2

PostPosted: Fri Mar 02, 2007 11:21 am    Post subject: Sample script that includes the new CMDret_Stream Reply with quote

Hi corrupt (Post from Mon Feb 19, 2007 8:13 am)

I have tried your script and I receive the following error:

Error at line 140:
Error: The leftmost character above is illegal in an expression


Line 140 is: tcWrk := WorkingDir=0 ? "Int" : "Str"


Any help?

Markus
Back to top
View user's profile Send private message
skwire



Joined: 18 Jan 2006
Posts: 172
Location: Conway, Arkansas

PostPosted: Fri Mar 02, 2007 4:21 pm    Post subject: Reply with quote

Are you running the latest version of AutoHotkey? If not, upgrade and try again.
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
corrupt



Joined: 29 Dec 2004
Posts: 2436

PostPosted: Sat Mar 03, 2007 7:09 am    Post subject: Reply with quote

My guess would also be that you are running an older version of AutoHotkey. You will likely need to either update to at least version 1.0.46 of AutoHotkey or use If...else statements instead of using the ternary operator. I should probably make a note somewhere in the first post what the minimum version required to use the function would be...
Back to top
View user's profile Send private message Visit poster's website
washboard
Guest





PostPosted: Thu Mar 08, 2007 9:26 pm    Post subject: Reply with quote

Hi, corrupt.

At first thanks for this very good script. But I have a problem.
I use this script to run this vbscript and to get back the result :

Code:
On Error Resume Next

Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open ("D:\Database.xls")

intRow = 2

Do Until objExcel.Cells(intRow,1).Value = ""
    If objExcel.Worksheets("Paris").Cells(intRow, 2).Value = "B" Then
       Resultat = Resultat & objExcel.Worksheets("Paris").Cells(intRow, 4).Value & vbTab & _
       objExcel.Worksheets("Paris").Cells(intRow, 5).Value & vbTab & _
       objExcel.Worksheets("Paris").Cells(intRow, 6).Value & vbTab & _
       objExcel.Worksheets("Paris").Cells(intRow, 7).Value & vbTab & _
       objExcel.Worksheets("Paris").Cells(intRow, 8).Value & vbCrLf
    End If
    intRow = intRow + 1
Loop

objExcel.Quit

Wscript.Echo Resultat

When I run the vbs file, the result is absolutely OK. I retreive the contents needed.

but when I use my ahk script to retreive the result

Code:
x := CMDret_RunReturn("cscript.exe D:\TestXL1.vbs")
Msgbox Recup VBS `r`n%x%
return

The result is correct, excepted for the diacritics signs (the accentued lettters) that are in use in my language (french).

So "Joël" returns as "Jo%l", or "Séverine" returns as "S,verine".

I think that this is the effect of the use of the command line, in DOS format for the characters. The same problem occurs if I use StdoutToVar from Sean. (I didn't seen a difference between this two scripts as Excel is not displayed in one of these progs, and it is what I want...)

So can you add the necessary code to "translate" back the characters from DOS to have a good result (may be there is a API call that do the job) ?

Thanks by advance.
Back to top
Sean



Joined: 12 Feb 2007
Posts: 1394

PostPosted: Fri Mar 09, 2007 12:47 am    Post subject: Reply with quote

washboard wrote:
I think that this is the effect of the use of the command line, in DOS format for the characters. The same problem occurs if I use StdoutToVar from Sean.

You're right. Console apps use the OEM codepage while Window apps use the ANSI codepage. There are various ways to workaround it, e.g, using Clipboard (copy the result from the console app to Clipboard then paste it to the window app). However, the direct solution may be using

Code:
; DllCall("SetConsoleCP", "Uint", DllCall("GetACP"))  ; Input
DllCall("SetConsoleOutputCP", "Uint", DllCall("GetACP"))  ; Output

(:Looks like the code above affects the console of the calling process, so, the code should be run from cscript.exe, not from AHK. Although I think this can be done using the technique used in my GetCommandLine script, it seems too much for this job. And, the other might-be method like calling DllCall("SetFileApisToOEM") before & DllCall("SetFileApisToANSI") after also seems too much to me, even if it would work. So, using Unicode I/O looks like the best soution.)

IMHO, however, the ideal solution is using Unicode for I/O, then, convert the result to ANSI using WideCharToMultiByte API. Fortunately, looks like cscript has that option. So, it could be

Code:
cscript.exe D:\TestXL1.vbs //U
; cmd /U /c cscript.exe D:\TestXL1.vbs
Back to top
View user's profile Send private message
washboard
Guest





PostPosted: Fri Mar 09, 2007 5:22 am    Post subject: Reply with quote

Hi Sean,

Thanks for your answer.
I tried :
Code:
x := CMDret_RunReturn("cscript.exe G:\CMDRet\TestXL1.vbs /U")
Msgbox Recup VBS `r`n%x%
return
but that didn't worked. I tried with "/U /c" and the result is the same.
I don't know how I can use clipboard in vbs, as it seems that the clipboard object is present in vba but not in vbs.
I think that I can use the FileSystem Object to write the result in a file and then read the file with AHK, but as I will use this Excel query solution many times, that would make a lot of create/read/delete file calls, so it would be a lot of hard disk usage and it would be slow.
I think I can use StringReplace, may be in a loop, to handle all the characters to replace to get back the good characters and do the job.
But I was thinking there was a simple solution to do the trick. Never mind.
Back to top
Sean



Joined: 12 Feb 2007
Posts: 1394

PostPosted: Fri Mar 09, 2007 6:55 am    Post subject: Reply with quote

washboard wrote:
I tried :

What I meant was something like this (:I couldn't tested it myself as both ANSI and OEM codepages are the same in my system.)
Code:
x := CMDret_RunReturn("cscript.exe G:\CMDRet\TestXL1.vbs")
Clipboard = %x%
Msgbox Recup VBS `r`n%Clipboard%
return
(:On second thought, obviously it won't work, the copy to the clipboard should be done from the console side. So forget about it.)

BTW, you can't use cscript.exe ... //U just as it is now, have to implement a routine to convert the result from Unicode to ANSI.
And, yes, 'cmd /U /c' turned out to work only with internal commands like
cmd /U /c set > set.text
Back to top
View user's profile Send private message
Sean



Joined: 12 Feb 2007
Posts: 1394

PostPosted: Fri Mar 09, 2007 8:07 am    Post subject: Reply with quote

OK, I wrote a script to convert OEM text to ANSI text.

Code:
/*
Oem2Ansi.ahk
*/

zString := "..."         ; OEM String

Ansi2Unicode(zString, wString, 1)   ; CP_OEMCP = 1
Unicode2Ansi(wString, sString, 0)   ; CP_ACP   = 0

MsgBox % sString         ;ANSI String

Ansi2Unicode(ByRef sString, ByRef wString, CP = 0)
{
     nSize := DllCall("MultiByteToWideChar"
      , "Uint", CP
      , "Uint", 0
      , "Uint", &sString
      , "int",  -1
      , "Uint", 0
      , "int",  0)

   VarSetCapacity(wString, nSize * 2)

   DllCall("MultiByteToWideChar"
      , "Uint", CP
      , "Uint", 0
      , "Uint", &sString
      , "int",  -1
      , "Uint", &wString
      , "int",  nSize)
}

Unicode2Ansi(ByRef wString, ByRef sString, CP = 0)
{
     nSize := DllCall("WideCharToMultiByte"
      , "Uint", CP
      , "Uint", 0
      , "Uint", &wString
      , "int",  -1
      , "Uint", 0
      , "int",  0
      , "Uint", 0
      , "Uint", 0)

   VarSetCapacity(sString, nSize)

   DllCall("WideCharToMultiByte"
      , "Uint", CP
      , "Uint", 0
      , "Uint", &wString
      , "int",  -1
      , "str",  sString
      , "int",  nSize
      , "Uint", 0
      , "Uint", 0)
}
Back to top
View user's profile Send private message
washboard
Guest





PostPosted: Fri Mar 09, 2007 8:17 am    Post subject: Reply with quote

Hi Sean,
I tried the clipboard solution and it didn't worked.
But your Oem2Ansi.ahk script work like a charm !!!
It's exactly what I needed.
A very high thanks.
I don't know how to use DllCall and API calls, so it would be not possible for me to do that. Thanks a lot.
Back to top
BoBo
Guest





PostPosted: Fri Mar 09, 2007 8:25 am    Post subject: Reply with quote

Quote:
OK, I wrote a script to convert OEM text to ANSI text.
If not done already - wouldn't it make sense to provide it within a seperate post?

Thx for your efforts & for sharing this script.
Much appreciated. Cool
Back to top
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page Previous  1, 2, 3 ... 8, 9, 10, 11, 12  Next
Page 9 of 12

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group