AutoHotkey Community

It is currently May 26th, 2012, 1:39 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 164 posts ]  Go to page Previous  1 ... 6, 7, 8, 9, 10, 11  Next
Author Message
 Post subject:
PostPosted: November 27th, 2008, 1:23 am 
Offline
User avatar

Joined: December 29th, 2004, 1:28 pm
Posts: 2542
Serenity wrote:
It doesn't. I get a << Process Terminated by Esc Key >> message and then it freezes/crashes.
Thanks for the feedback. I am able to reproduce this error with version 3.2.1 and above on Windows 2000 SP4 but I was not able to reproduce the error with version 3.1.2 (also available for download in the first post).


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 8th, 2008, 12:19 pm 
Offline
User avatar

Joined: December 29th, 2004, 1:28 pm
Posts: 2542
CMDret 4c (BETA) - Download (cmdret.dll + a couple of test scripts)

- updated the RunWCB() function for Win2k compatibility (hopefully)

I would appreciate feedback from anyone that has a chance to test this version. Only the RunWCB() function has been updated in this Beta version. If this seems to fix the issue when running in Windows 2000 then I'll update the other functions in the next release :) .


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 9th, 2008, 12:06 am 
Offline

Joined: November 8th, 2004, 12:46 am
Posts: 1271
Thanks corrupt. :) I tried both scripts and neither crashed.

_________________
"Anything worth doing is worth doing slowly." - Mae West
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 9th, 2008, 1:34 am 
Offline

Joined: February 6th, 2008, 12:26 am
Posts: 14
Location: the land of enchantment
corrupt wrote:
...If this seems to fix the issue when running in Windows 2000...

thanks i'll give it a go ~ let you know 8)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 14th, 2008, 11:03 pm 
Offline
User avatar

Joined: December 29th, 2004, 1:28 pm
Posts: 2542
CMDret 4d Beta - Download (cmdret.dll, cmdstub.exe, several test scripts)
- updated all functions for Windows 2000 compatibility (hopefully)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 22nd, 2008, 11:00 am 
Offline
User avatar

Joined: December 29th, 2004, 1:28 pm
Posts: 2542
Serenity wrote:
Thanks corrupt. :) I tried both scripts and neither crashed.
Thanks for the feedback :) .


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 3rd, 2009, 8:16 am 
Hey you guys,

The issue with the script not responding is related to threads.
When you make the dllCall the script waits for the call to end.

I made a script to launch a Tomcat server, and for that, I wanted to be able to grab the console output for debugging purposes.
The trouble I had was that the Tomcat server is not suposed to end.
Thus, is was freezing the script.

The solution is to make the dllCall into a separate thread.
See:

Code:
;// Consts
WINDOW_TITLE    = Tomcat Console

;// GUI
Menu, Tray, NoStandard
Menu, Tray, Add, Exit, GuiClose
Gui, +ToolWindow
Gui, Add, Edit, x6 y10 w460 h360 +HScroll HWNDoutputh
Gui, Show, center h377 w477, %WINDOW_TITLE%
WinWait, %WINDOW_TITLE%

;// Create CMD
CMD := COMSPEC . " /C dir c:\*.* /b /s"

;// Make thread
CBA_PIPE := RegisterCallback( "pipeThread" )  ;// pipeThread is the function to run in a separate thread
threadID := DllCall( "CreateThread", UInt,0, UInt,0, UInt,CBA_PIPE, UInt,0, UInt,0, UInt,0 )

;// Loop
Return

;// Quit
GuiClose:
        ;// Kill the stuff
        Process, Close, "cmd.exe", 10   ;// not sure this works but whatever

   ;// Kill thread
   DllCall( "TerminateThread", UInt, threadID, UInt, 0 )
   DllCall( "CloseHandle", UInt, threadID )
   ExitApp, 0


;/**
; * Thread that writes to text area.
; */
pipeThread() {
   global cmd, outputh
   rc := DllCall("cmdret.dll\RunInControl", "str", CMD, "Uint", outputh) ;// outputh is the handler to the text area
}


I didnt test that code, its just to illustrate the thread stuff with CMDRet.
I used CMDret 4b BTW.

Hope that was usefull.

Cya 8)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: July 7th, 2009, 12:30 am 
Offline

Joined: May 13th, 2009, 11:30 pm
Posts: 11
I'm trying to use this in conjunction with a third party perl script. It's a perl script that downloads a FLV file by calling command line programs (e.g. rtmpdump.exe)

The problem I'm having is that CMDRet doesn't seem to be handling the output in the same way that a console window would. Specifically, there's a part of the perl script that shows a percentage complete. In a regular Windows DOS box it looks like a percentage that increases 'on the spot', i.e. the cursor stays at the same position and the percentage increases.

If I use the function method (CMDret_Stream) then I see no percentage progress at all until it's completely done, and then for some reason it doesn't show the newline characters properly. e.g.

[]0.051 KB[]0.108 KB[]0.605 KB (0.0%)[]0.679 KB (0.0%)[]0.752 KB[](0.0%)[]17.865 KB (0.0%)[]17.884 KB (0.0%)[]18.179 KB (0.0%)

...for lines and lines all the way up to 100, where [] is shown as a box which is in fact a newline character. (I couldn't paste the exact code here as the box gets translated into new lines).

If I use the DLL test script (testx3.ahk or cmdret4b_1.ahk) then I see the progress as it happens, but again, the newline character is instead shown as a square. Since I'm seeing the progress as it happens, I ought to be able to parse it and display it properly, but I don't know how to do that since it's going directly to the Edit Box.

Here's what it looks like in the testx3.ahk

Image

Anyone know how I can a) avoid the newline characters showing up as boxes? b) parse the output from the dll before it gets to the Edit Box?

Thanks in advance.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 11th, 2009, 6:53 pm 
Offline
User avatar

Joined: December 29th, 2004, 1:28 pm
Posts: 2542
DavidA wrote:
Anyone know how I can a) avoid the newline characters showing up as boxes? b) parse the output from the dll before it gets to the Edit Box?

Thanks in advance.
You might want to have a look at the examples for the RunWCB() function in the dll. A StripNull() function has been added to the examples in attempt to compensate for Null, non-printable characters in the output that AHK does not currently handle the same way.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 12th, 2009, 10:54 pm 
Offline

Joined: May 13th, 2009, 11:30 pm
Posts: 11
Thanks Corrupt. The memory handling in cmdret4b_1 is a little beyond me, but I think I've made some progress.

I've changed your example so that it parses the data using my own parser:

Code:
VarSetCapacity(TOut, nchar + 1, 0)
DllCall(df_lstrcat, "str", TOut, "UInt", cmdout)
VarSetCapacity(TOut, -1)
StripNull(TOut, nchar) ; remove NULL characters from output
ParseData(TOut, nchar)
;DllCall(df_SendMessage, "UInt", Ed1, "UInt", 0xC2, "UInt", 0, "UInt", &TOut)


Notice the new line, ParseData and the DLLCall on the following line remarked out.

And then my ParseData routine is as follows:

Code:
ParseData(strData, intCharacters)
{   
  global Ed1
  Loop, Parse, strData, `r`n
  {
    if %A_LoopField%
    {
      strThisLine = %A_LoopField%
      SendMessage 0xB1, -2, -1, , ahk_id %Ed1%
      Control, EditPaste, %strThisLine%`r`n, , ahk_id %Ed1%
    }
  }
}


It works, but I'm not sure how dangerous it is to handle the data in that way. It's the only way I understand right now. Would that be safe?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 13th, 2009, 9:49 pm 
Offline

Joined: June 18th, 2009, 11:13 pm
Posts: 73
Just a short wort of thank.
I am recently learning C#, and thanks to your file I can hopefully use my C#-work to speed up some of my AHK-Scripts.

Localisation issue
On the german version of WinXP3, all the ä, ö, and ü (no idea if displayed in your browser) get hopelessly screwed up.

Is there any Idea for a solution?


A question to speed:
As I will need to call this DLL about 50.000 times in a loop, I´d like to understand that part of the documentations:
Code:
; In the following example, if the DLL isn't yet loaded, use LoadLibrary in place of GetModuleHandle.
MulDivProc := DllCall("GetProcAddress", uint, DllCall("GetModuleHandle", str, "kernel32"), str, "MulDiv")
Loop 500
    DllCall(MulDivProc, int, 3, int, 4, int, 3)


I do not see where to enter the "cmdret.dll".

Please could anyone give the code?
I am going to insert it right after
Code:
hModule := DllCall("LoadLibrary", "str", "cmdret.dll") 


Thanks in advance!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 7th, 2009, 8:03 am 
why this doesnt work

Code:
; CMDret DLL version 3.1 (or greater) required

Run, Notepad,,, notepid
WinWait, ahk_pid %notepid%
WinWaitActive, ahk_pid %notepid%

CMD := "dir"
ControlGet, OutputWindow, Hwnd,, Edit1, ahk_pid %notepid%
if OutputWindow <> 0
  StrOut := DllCall("cmdret.dll\RunInControl", "str", CMD, "Uint", OutputWindow, "str", "Edit", "int", "1")


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: October 25th, 2009, 3:32 am 
Offline

Joined: February 11th, 2009, 10:34 pm
Posts: 13
hi,
how do I make the CMD work when the program requires parameters?

this works:
Code:
CMD := "C:\Program Files\Wireshark\tshark.exe"


but as soon as I add parameters it won't work. I don't get any output so I guess the program won't be executed/found:

Quote:
CMD := "C:\Program Files\Wireshark\tshark.exe port 6112 -T fields -e data"


how do I get it work with parameters??

of course it has to be:
Quote:
"C:\Program Files\Wireshark\tshark.exe" port 6112 -T fields -e data
, in quotes, but since the CMD := "" already needs those two "" it doenst work!! and I can't find a syntax descriptiin in the autohotkey documentation.... in most languages \" would work but in ahk it doesnt!! :twisted:

here is the complety code:
Code:
;// Consts
WINDOW_TITLE    = Tomcat Console

;// GUI
Menu, Tray, NoStandard
Menu, Tray, Add, Exit, GuiClose
Gui, Add, Edit, x6 y10 w790 h790 +HScroll HWNDoutputh
Gui, Show, center h800 w800, %WINDOW_TITLE%
WinWait, %WINDOW_TITLE%

;// Create CMD
CMD := "C:\Program Files\Wireshark\tshark.exe port 6112 -T fields -e data"

;// Make thread
CBA_PIPE := RegisterCallback( "pipeThread" )  ;// pipeThread is the function to run in a separate thread
threadID := DllCall( "CreateThread", UInt,0, UInt,0, UInt,CBA_PIPE, UInt,0, UInt,0, UInt,0 )

;// Loop
Return

;// Quit
GuiClose:
        ;// Kill the stuff
        Process, Close, "cmd.exe",   ;// not sure this works but whatever

   ;// Kill thread
   DllCall( "TerminateThread", UInt, threadID, UInt, 0 )
   DllCall( "CloseHandle", UInt, threadID )
   ExitApp, 0


;/**
; * Thread that writes to text area.
; */
pipeThread() {
   global cmd, outputh
   rc := DllCall("cmdret.dll\RunInControl", "str", CMD, "Uint", outputh) ;// outputh is the handler to the text area
}



Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 25th, 2009, 7:56 am 
Offline

Joined: October 2nd, 2009, 12:43 pm
Posts: 283
Code:
CMD := """C:\Program Files\Wireshark\tshark.exe"" port 6112 -T fields -e data"


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 25th, 2009, 6:01 pm 
Offline

Joined: February 11th, 2009, 10:34 pm
Posts: 13
flak wrote:
Code:
CMD := """C:\Program Files\Wireshark\tshark.exe"" port 6112 -T fields -e data"

works, thanks!


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 ... 6, 7, 8, 9, 10, 11  Next

All times are UTC [ DST ]


Who is online

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