AutoHotkey Community

It is currently May 27th, 2012, 12:17 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 164 posts ]  Go to page Previous  1 ... 7, 8, 9, 10, 11
Author Message
 Post subject:
PostPosted: March 21st, 2011, 3:32 am 
Offline

Joined: December 19th, 2010, 5:32 am
Posts: 235
corrupt wrote:
aSEioT wrote:
The tool is really great! But do not support ahk unicode version rightnow, what a pity! :?
I'm not currently using AhkL but will look into it. Thanks
I would appreciate it if you got this to work worth AutoHotkey_L Unicode 32 bit :D


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 31st, 2011, 3:38 am 
zzzooo10 wrote:
corrupt wrote:
aSEioT wrote:
The tool is really great! But do not support ahk unicode version rightnow, what a pity! :?
I'm not currently using AhkL but will look into it. Thanks
I would appreciate it if you got this to work worth AutoHotkey_L Unicode 32 bit :D


use

libiconv: character set conversion library


or win api
Code:
/*
CP_ACP   = 0
CP_OEMCP = 1
CP_MACCP = 2
CP_UTF7  = 65000
CP_UTF8  = 65001
*/

Ansi2Oem(sString)
{
   Ansi2Unicode(sString, wString, 0)
   Unicode2Ansi(wString, zString, 1)
   Return zString
}

Oem2Ansi(zString)
{
   Ansi2Unicode(zString, wString, 1)
   Unicode2Ansi(wString, sString, 0)
   Return sString
}

Ansi2UTF8(sString)
{
   Ansi2Unicode(sString, wString, 0)
   Unicode2Ansi(wString, zString, 65001)
   Return zString
}

UTF82Ansi(zString)
{
   Ansi2Unicode(zString, wString, 65001)
   Unicode2Ansi(wString, sString, 0)
   Return sString
}

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)
}


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 31st, 2011, 4:09 pm 
Online
User avatar

Joined: May 5th, 2007, 7:24 pm
Posts: 1240
Location: Seville, Spain
Instead of doing what the Guest said, you can use built-in features such as the ASTR DllCall type, StrGet(), etc.

_________________
fincs
Highly recommended: AutoHotkey_L (see why) (all my code snippets require it)
Formal request to polyethene - I support the unity of the AutoHotkey community
Get SciTE4AutoHotkey v3.0.00 (Release Candidate)
[My project list]


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 6th, 2011, 7:29 am 
well
the
CMDret - v3.2.1 (DLL version)
were killed by antivirus
and CMDret 4d Beta were ok

and
CMD := "ipconfig /all"
the msgbox were empty on a non-english OS
and StdoutToVar were ok


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: June 6th, 2011, 8:11 am 
Offline
User avatar

Joined: November 7th, 2010, 2:48 am
Posts: 72
Location: Egret Island
Thanks for your work!

I think using WshShell Object maybe a better way. For details, please see:
[AHK&AHK_l]Using COM to interact with command-line progs

_________________
Recommended: AutoHotkey_L My code is based on it or similar versions, e.g. AutoHotkey_H.
Image
Together with AutoHotkey, we grow and march forward. No matter how the future will be, this period of days is still epic.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 22nd, 2011, 9:25 pm 
Offline

Joined: July 6th, 2011, 10:20 pm
Posts: 42
Rats! This program looked like just what I needed, but without the ability to send user input to the console window before outputting the window's contents I can't use it.

So I'll just add a +1 for that feature, if you're still working on this program. :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 17th, 2011, 8:20 pm 
Offline
User avatar

Joined: November 19th, 2010, 9:54 am
Posts: 184
I tried using the example in the first page to stream something out but didn't work, I'm I doing something wrong?

Code:
Gui, Add, Edit, x6 y10 w460 h360 +HScroll
Gui, Show, x398 y110 h377 w477, CMDret - DLL version - Streaming Test App

; CMD = ping 127.0.0.1
CMD = "D:\df.exe" c: /large *.* 100

OutputWindow := WinExist("CMDret - DLL version - Streaming Test App")
StrOut := DllCall("cmdret.dll\RunInControl", "str", CMD, "Uint", OutputWindow, "str", "Edit", "int", "1")
Return

GuiClose:
ExitApp

df.exe = commandline version of defraggler


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 27th, 2011, 10:49 pm 
Offline

Joined: July 10th, 2011, 5:03 am
Posts: 272
hi corrupt,

will this work with psql.exe?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 15th, 2012, 4:45 am 
Offline
User avatar

Joined: December 29th, 2004, 1:28 pm
Posts: 2545
Sample script for ANSI or UNICODE 32bit _L versions using the current version of cmdret.dll
Code:
ret1 := CMDret(COMSPEC " /C set")
MsgBox, % ret1

CMDret(CMD)
{
  VarSetCapacity(StrOut, 20000)
  RetVal := DllCall("cmdret.dll\RunReturn", A_IsUnicode ? "AStr" : "Str", CMD, "Str", StrOut)
  Return, A_IsUnicode ? StrGet(&StrOut, "cp0") : StrOut
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 15th, 2012, 6:11 am 
Offline
User avatar

Joined: December 29th, 2004, 1:28 pm
Posts: 2545
Streaming example (ANSI or UNICODE 32bit _L)
Code:
; ---------------------------------------------------------------------------
; CMDret 4b - Beta test
; March 15, 2012 - corrupt
;
; cmdret version 4b or above required
; _L ANSI or UNICODE 32bit compatibile
; ---------------------------------------------------------------------------

Gui, Add, Edit, x6 y50 w420 h590 +WantReturn HwndEd1,
Gui, Add, Button, x6 y10 w100 h30 gRunCMD, Run Command
Gui, Add, Edit, x116 y10 w200 h30 -Multi vcmd1, ping 127.0.0.1 -n 10
Gui, Add, Button, x327 y10 w100 h30 gClr, Clear
Gui, Add, StatusBar, , Ready
Gui, Show, h666 w432, CMDret 4b - Beta
Return

GuiClose:
ExitApp



RunCMD:
  Gui, Submit, NoHide
  If not EnumAddress
    EnumAddress := RegisterCallback("cmdoutProc", "", 4)
  SB_SetText("Executing... Hold <Esc> to terminate")
  ; ---------------------------------------------------------------------------
  ; RunWCB -> CMD=command to execute, EnumAddress=Address from RegisterCallback
  ; ---------------------------------------------------------------------------
  RetVal := DllCall("cmdret.dll\RunWCB", A_IsUnicode ? "AStr" : "Str", cmd1, "UInt", EnumAddress)
  If !(RetVal)
    SB_SetText("Failed to Execute...")
  Else
    SB_SetText("Ready")
Return



cmdoutProc(cmdpid, nchar, cmdout, FutureUse)
{
  global Ed1 ; Edit control HWND
; ---------------------------------------------------------------------------
  Static df_lstrcat
  Static df_SendMessage

  If !(df_lstrcat)
    df_lstrcat := DllCall("GetProcAddress", UInt, DllCall("GetModuleHandle", Str, "kernel32"), A_IsUnicode ? "AStr" : "Str", "lstrcat")
  If !(df_SendMessage)
    df_SendMessage := DllCall("GetProcAddress", UInt, DllCall("GetModuleHandle", Str, "user32"), A_IsUnicode ? "AStr" : "Str", "SendMessageA")

; ---------------------------------------------------------------------------
; Values returned:
; cmdpid = ProcessId
; ** = WM_USER + 1
; nchar = number of characters returned in the buffer
; cmdout = pointer to the buffer
; FutureUse = FutureUse
; ---------------------------------------------------------------------------
    VarSetCapacity(TOut, nchar + 1, 0)
    DllCall(df_lstrcat, "str", TOut, "UInt", cmdout)
    VarSetCapacity(TOut, -1)
    StripNull(TOut, nchar) ; remove NULL characters from output
    DllCall(df_SendMessage, "UInt", Ed1, "UInt", 0xC2, "UInt", 0, "UInt", &TOut)
    If (GetKeyState("Esc" , "P")) {
     Process, Close, %cmdpid%
      DllCall(df_SendMessage, "UInt", Ed1, "UInt", 0xC2, "UInt", 0, "Str", "`r`n`r`n<<  Process Terminated by Esc Key  >>")
   }
    Sleep, 0  ; short sleep to allow minimizing/restoring window   
    Return TRUE
}



StripNull(Var1, DataSize)
{
  Local Static df_RtlZeroMemory
  If !(df_RtlZeroMemory)
    df_RtlZeroMemory := DllCall("GetProcAddress", uint, DllCall("GetModuleHandle", str, "kernel32"), A_IsUnicode ? "AStr" : "Str", "RtlZeroMemory")
  Var1 := A_IsUnicode ? StrGet(&Var1, "cp0") : Var1
  IF (StrLen(Var1) < (DataSize - 1)) {
    VarSetCapacity(CMcpy, DataSize, 32)
    DataSize2 = %DataSize%
    Loop {
      DllCall(df_RtlZeroMemory, "UInt", &CMcpy, Int, DataSize)
      NULLptr := StrLen(Var1)
      cpsize := DataSize - NULLptr
      DllCall(df_RtlZeroMemory, "UInt", &CMcpy, "UInt", (&Var1 + NULLptr + 2), "Int", (cpsize - 1))
      DllCall(df_RtlZeroMemory, "UInt", (&Var1 + NULLptr), Int, cpsize)
      DllCall(df_RtlZeroMemory, "UInt", (&Var1 + NULLptr), "UInt", &CMcpy, "Int", cpsize)
      DataSize2 --
      IF (StrLen(Var1) > DataSize2)
        break
    }
  }
  VarSetCapacity(Var1, -1)
Return Var1
}

Clr:
GuiControl,, Edit1,
SB_SetText("Ready")
Return


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Re:
PostPosted: April 8th, 2012, 8:28 pm 
Offline

Joined: February 16th, 2010, 4:01 am
Posts: 60
Guest wrote:
CMD := "ipconfig /all"
the msgbox were empty on a non-english OS
and StdoutToVar were ok


I have this issue as well. Having trouble diagnosing it. On Win7 64bit with latest CMDRet and non-L AHK, the ability to pass output to a var and display in a MsgBox is inconsistent for me. Even the sample code from corrupt is failing for me now.


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Re: Re:
PostPosted: April 9th, 2012, 3:02 am 
Offline
User avatar

Joined: December 29th, 2004, 1:28 pm
Posts: 2545
tain wrote:
Guest wrote:
CMD := "ipconfig /all"
the msgbox were empty on a non-english OS
and StdoutToVar were ok


I have this issue as well. Having trouble diagnosing it. On Win7 64bit with latest CMDRet and non-L AHK, the ability to pass output to a var and display in a MsgBox is inconsistent for me. Even the sample code from corrupt is failing for me now.

I'm currently using Win7 64 bit. Would you be able to post the code that you are currently trying to use (or PM if you prefer)? The last code I posted was for use with AHK_L


Report this post
Top
 Profile  
Reply with quote  
PostPosted: April 13th, 2012, 6:58 pm 
Offline

Joined: February 16th, 2010, 4:01 am
Posts: 60
I was referring to sample code from the first post.


Report this post
Top
 Profile  
Reply with quote  
PostPosted: April 14th, 2012, 3:52 am 
Offline
User avatar

Joined: December 29th, 2004, 1:28 pm
Posts: 2545
tain wrote:
I was referring to sample code from the first post.

There seems to be an issue with using params with the RunReturn function. For example, "ipconfig" seems to work ok here but not "ipconfig /all". It has been a while since I put it together but I'll dig out the source for the dll file and have a look. As an alternative, the following seems to work on this machine. Please let me know if this works for you:
Code:
CMD := "ipconfig /all"
RunWaitEx(CMD,"","", stdout, stderr)
MsgBox % stdout

RunWaitEx(CMD, CMDdir, CMDin, ByRef CMDout, ByRef CMDerr, Capx=100000)
{
  VarSetCapacity(CMDOut, Capx)
  VarSetCapacity(CMDerr, Capx)
  Return, % DllCall("cmdret.dll\RunWEx", "str", CMD, "str", CMDdir, "str", CMDin, "str", CMDout, "str", CMDerr)
}


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 164 posts ]  Go to page Previous  1 ... 7, 8, 9, 10, 11

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 2 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