Sign in to follow this  
Followers 0
t0ddie

keys not sending correctly

7 posts in this topic

#1 ·  Posted (edited)

I dont know why, but the script i was using that did not work, works today. i changed nothing.

go figure.

anyways, thanks for all the advice guys.

problem solved i guess... heh

Edited by t0ddie

Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.

Share this post


Link to post
Share on other sites



You could pipe the DOS program output to a text file and read that in AutoIT.

eg: PROG.exe >> output_text_file.txt

(Check out the common DOS batch commands including the "|" option)

Share this post


Link to post
Share on other sites

Try this:

Opt("WinTitleMatchMode", 2)     ;1=start, 2=subStr, 3=exact, 4=advanced
Opt("SendKeyDelay", 1)          ;milliseconds

FileDelete(@ScriptDir&"\output.txt")
FileDelete(@ScriptDir&"\gen.bat")
FileWriteLine(@ScriptDir&"\gen.bat","d2skey.exe > output.txt")

$pid = run(@comspec,@scriptdir,@SW_HIDE)
$hwnd = _ProcessGetWin($pid)
ControlSend($hwnd,"","","script.bat{enter}")
ControlSend($hwnd,"","","2")
ControlSend($hwnd,"","","1.mpq{enter 2}")
ControlSend($hwnd,"","","exit{enter}")

$output = FileRead(@scriptdir&"\output.txt")
FileDelete(@ScriptDir&"\output.txt")
FileDelete(@ScriptDir&"\gen.bat")

msgbox(0,"Output from d2skey.exe",$output)


func _ProcessGetWin($procID)
    sleep(100)
    $var = WinList()
    For $i = 1 to $var[0][0]
      $thispid = WinGetProcess($var[$i][1])
      if $thispid = $procID then return $var[$i][1]
    Next
EndFunc


[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

Share this post


Link to post
Share on other sites

Well I sort of solved a problem I had about keeping the cmd window open by using:

Run(@SystemDir & "\cmd.exe", @SystemDir)

then using the Send() function to do a command.

Share this post


Link to post
Share on other sites

The code I wrote works for me when I run it. Place it in the diablo directory with the program. Try changing:

$pid = run(@comspec,@scriptdir,@SW_HIDE)

to

$pid = run(@comspec,@scriptdir)

so that it doesn't run the command window hidden. Also try sprinkling in some

sleep(1000)

comands so that you can see what it's doing. Also try commenting out the FileDeletes, so you can take a look at the Output.txt file it's creating to capture the output from the program. It should be working fine.


[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0