 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
bLisTeRinG
Joined: 15 Nov 2004 Posts: 45 Location: Warrnambool
|
Posted: Wed Sep 13, 2006 12:40 pm Post subject: Send chars to a minimized window containing a batch file? |
|
|
My ahk runs a dos batch file minimised.
The batch file pauses (while I have a phone conversation).
Then I want to send 'any key' to the batch-file in the minimised window (to un-pause and cleanup and exit). Simple huh?
If I restore the window (WinActivate) and use (Send x) while it's on top I can un-pause fine. But even with the window on top I can't make ControlSend work.
I haven't a clue. Please help if you do!
My code:
| Code: |
DetectHiddenWindows, On
DetectHiddenText, On
SetTitleMatchMode, 2
IfWinExist, Phone
{
WinActivate, Phone Call
ControlSendRaw,, a, Phone Call
;Send a
MsgBox, ok `nErrorLevel: %ErrorLevel%.
}
exit
|
The window info:
| Code: |
control ttyGrab1
ahk_id 0xcb8
ahk_class tty
title Phone Call
|
|
|
| Back to top |
|
 |
Peter
Joined: 30 Dec 2005 Posts: 279
|
Posted: Wed Sep 13, 2006 6:30 pm Post subject: |
|
|
| bLisTeRinG wrote: | | Then I want to send 'any key' to the batch-file |
| bLisTeRinG wrote: | The window info:
control ttyGrab1
ahk_class tty
| That doesn't seems to be from a batch file?
(And I can't find a control in a command prompt window.) |
|
| Back to top |
|
 |
bLisTeRinG
Joined: 15 Nov 2004 Posts: 45 Location: Warrnambool
|
Posted: Thu Sep 14, 2006 7:51 am Post subject: |
|
|
I must have been a bit sleepy. Here's the full script & the batch file below it:
| Code: |
;;; ModemAsPhone v0.1
;;; Aureal Vortex is Sound Device 2
gosub mpSaveSet
gosub mpCallSet
run, C:\Progra~1\Tools\Comms\Call.bat %1%,C:\Progra~1\Tools\Comms,min
MsgBox, PhoneCall in progress. `n%1% `nOk when done.
WinActivate, Phone
send, {SPACE}
; ControlSend,,{SPACE}, Phone Call
gosub mpReSet
return
;;; Save Current settings.
mpSaveSet:
SoundGet,mpMas1,Master,volume,1
SoundGet,mpMasM1,Master,mute,1
SoundGet,mpMas2,Master,volume,2
SoundGet,mpMasM2,Master,mute,2
SoundGet,mpTel2,Telephone,volume,2
SoundGet,mpTelM2,Telephone,mute,2
SoundGet,mpAux1,Aux,volume,2
SoundGet,mpAuxM1,Aux,mute,2
SoundGet,mpMic1,Microphone,volume,1
SoundGet,mpMicM1,Microphone,mute,1
SoundGet,mpMic2,Microphone,volume,2
SoundGet,mpMicM2,Microphone,mute,2
SoundGet,mpWav1,Wave,volume,1
SoundGet,mpWavM1,Wave,mute,1
SoundGet,mpLinM1,Line,mute,1
SoundGet,mpCdM1,Cd,mute,1
return
;;; Do Phone-call settings.
mpCallSet:
SoundSet,60,Master,volume,1
SoundSet,0,Master,mute,1
SoundSet,0,Master,volume,2
SoundSet,0,Master,mute,2
SoundSet,90,Telephone,volume,2
SoundSet,0,Telephone,mute,2
SoundSet,mpAux1,Aux,volume,2
SoundSet,mpAuxM1,Aux,mute,2
SoundSet,0,Microphone,volume,1
SoundSet,1,Microphone,mute,1
SoundSet,90,Microphone,volume,2
SoundSet,0,Microphone,mute,2
SoundSet,25,Wave,volume,1
SoundSet,1,Wave,mute,1
SoundSet,1,Line,mute,1
SoundSet,1,Cd,mute,1
return
;;; Restore settings.
mpReSet:
SoundSet,%mpMas1%,Master,volume,1
SoundSet,%mpMasM1%,Master,mute,1
SoundSet,%mpMas2%,Master,volume,2
SoundSet,%mpMasM2%,Master,mute,2
SoundSet,%mpTel2%,Telephone,volume,2
SoundSet,%mpTelM2%,Telephone,mute,2
SoundSet,%mpAux1%,Aux,volume,2
SoundSet,%mpAuxM1%,Aux,mute,2
SoundSet,%mpMic1%,Microphone,volume,1
SoundSet,%mpMicM1%,Microphone,mute,1
SoundSet,%mpMic2%,Microphone,volume,2
SoundSet,%mpMicM2%,Microphone,mute,2
SoundSet,%mpWav1%,Wave,volume,1
SoundSet,%mpWavM1%,Wave,mute,1
SoundSet,%mpLinM1%,Line,mute,1
SoundSet,%mpCdM1%,Cd,mute,1
return
|
The Batch File:
| Code: |
@echo off
rem Lucent WinModem COM:3 IRQ:10 115200
set app1=C:\Progra~1\Tools\Comms\AtSend.exe
set num=D%1
if "%num%" == "D" goto help
if "%num%" == "D0" goto talk
if "%num%" == "DR" goto done
if "%num%" == "DL" goto hear
if "%num%" == "DH" goto hang
%app1% +FCLASS=8;+VGR=128;+VGT=128;+VLS=7;%num%
:done
rem THIS IS THE PAUSE I CAN'T GET CONTROLSEND TO UNPAUSE.........
pause
%app1% Z
%app1% &FE0&C1&D2V1S0=0\V1
%app1% S7=60S30=0L0M1\N3%C1&K3B0B15B2X4
exit
:help
"C:\Program Files\Tools\Util\PopUp.exe" PhoneCall "[path\]!Call.bat phonenumber" or 0(answer) or L(isten) or R(eset) of H(angup)
exit
:hear
%app1% +FCLASS=8;+VLS=5
goto done
:hang
%app1% H
goto done
:talk
%app1% +FCLASS=8;+VSD=64,5;+VGR=128;+VGT=128;+VLS=7
goto done
|
|
|
| Back to top |
|
 |
majkinetor
Joined: 24 May 2006 Posts: 3626 Location: Belgrade
|
Posted: Thu Sep 14, 2006 9:09 am Post subject: |
|
|
You can use my console application GuiBox if you have problems sending keys to console.
Among 100 other things you can use folowing:
1. Hide console window (instead minimising: Guibox /H0 )
2. You can continue script by sending message to it.
3. You can create nice little gui.
To pause it use u start GuiBox dialog with the name, like this
| Code: | | guibox /Nmyinfo thinger - paused |
This will pause the script, dipslay message pause from the tray.
This little windows is named "myinfo"
Later, when you want to release the batch, you can start another instance of batch saying this
| Code: | | GuiBox "/[myinfo die]" |
This GuiBox instance will contact the myinfo dialog and tell it to exit, then your script will continue
You can alse send WM_MESSAGE to Guibox without starting the second instance of it, directly from AHK, but I don't remember what exactly should be specified, I programmed it before 2 years and it is not ment to be used that way
There are possibly easier ways to do it, like finding some workaround to direct send (I don't know why it doesn't work, didn't test it) but this will surrely work. GuiBox is 70K, it is made to hide console and create common types of dialogs, so with it, you can avoid using AHK at all for this job.
| Quote: | | "C:\Program Files\Tools\Util\PopUp.exe" PhoneCall "[path\]!Call.bat phonenumber" or 0(answer) or L(isten) |
| Code: | | GuiBox "/P1 /A40" thinger - "Phone Call from the number %NUM%" (/P1 = upper left corner of the screen, transparency 40%) |
Your batch will be much faster that way also.
You can download GuiBox here _________________
 |
|
| Back to top |
|
 |
bLisTeRinG
Joined: 15 Nov 2004 Posts: 45 Location: Warrnambool
|
Posted: Thu Sep 14, 2006 12:32 pm Post subject: |
|
|
I'll create a beautiful gui when the methodology works, I absolutely agree. But in the meantime I simply can't send the message to the dos window! Is this a failure, an Autohotkey limitation?
I may be misunderstanding the process (it's happened before).
But all I want to do is send a message to an existing process. What could be easier? |
|
| Back to top |
|
 |
Peter
Joined: 30 Dec 2005 Posts: 279
|
Posted: Thu Sep 14, 2006 11:07 pm Post subject: |
|
|
The following works fine for me | Code: | F10::Run, G:\Test.bat, , , Bat_PID
F11::ControlSend, , {enter}, ahk_pid %Bat_PID% ; stops pause, also on minimized window | Batch file Test.bat: | Code: | cls
echo Batchfile started
pause
echo 2nd pause here
pause |
|
|
| Back to top |
|
 |
bLisTeRinG
Joined: 15 Nov 2004 Posts: 45 Location: Warrnambool
|
Posted: Fri Sep 15, 2006 5:10 am Post subject: |
|
|
Didn't work!
I see the idea - identify the process with Bat_PID, then use it to find the process when unpausing. But it still doesn't work. Perhaps my OS has something to do with it (Win98se), but I wouldn't have thought so. I tried it with my script, then when it didn't work I tried yours, it wouldn't work either! F10 was ok but F11? Nothing. Boo Hoo  |
|
| Back to top |
|
 |
bLisTeRinG
Joined: 15 Nov 2004 Posts: 45 Location: Warrnambool
|
Posted: Fri Sep 15, 2006 6:14 am Post subject: |
|
|
| I just updated and tried SendEvent and SendInput but just as before with Send, the window has to be visible. But I want it minimized. |
|
| Back to top |
|
 |
majkinetor
Joined: 24 May 2006 Posts: 3626 Location: Belgrade
|
Posted: Fri Sep 15, 2006 7:45 am Post subject: |
|
|
Well, you see, this is a trivial thing, and for some strange reason it doesn't work at your place. Since we are not at the center of the scene, I guess there aren't much things we can do.
I suggested you what to use if you can't solve this problem in AHK. _________________
 |
|
| Back to top |
|
 |
bLisTeRinG
Joined: 15 Nov 2004 Posts: 45 Location: Warrnambool
|
Posted: Fri Sep 15, 2006 8:08 am Post subject: |
|
|
Yes, yes...
I"m sure it could be done just using batch-files. But I don't want to! I want AHK to do what it should do. The whole tool was written easily in half-an-hour, but this stupid problem has cost me two days. I know ahk can do it, and I want to know why it won't in this particular instance. Look at the code, I've only done ordinary things. And anyway this is causing problems to other people too. I searched the site and found problems going right back to 2004.
I think this problem should be solved, or definitively explained.
I really do...
Wish me Good Luck because I'm going to try some more stuff. |
|
| Back to top |
|
 |
Peter as guest Guest
|
Posted: Fri Sep 15, 2006 8:09 am Post subject: |
|
|
| bLisTeRinG wrote: | | Perhaps my OS has something to do with it (Win98se) | Maybe I can try it later on a Win98SE PC. |
|
| Back to top |
|
 |
bLisTeRinG
Joined: 15 Nov 2004 Posts: 45 Location: Warrnambool
|
Posted: Fri Sep 15, 2006 8:45 am Post subject: |
|
|
Thanks, that'd be great!
I'm trying every possible variation of Send, ControlSend, SendEvent, SendInput, etc...
Back soon-ish... |
|
| Back to top |
|
 |
majkinetor
Joined: 24 May 2006 Posts: 3626 Location: Belgrade
|
Posted: Fri Sep 15, 2006 9:23 am Post subject: |
|
|
Try this:
F10::Run, d:\Test.bat
F11::ControlSend, , {enter}, TEST ; stops pause, also on minimized window
In batch file put your first line to be
title TEST
It works here minimised maximized... the Peters version was working too. This is just without PIDs. I don't have ME to check it out. _________________
 |
|
| Back to top |
|
 |
Peter
Joined: 30 Dec 2005 Posts: 279
|
Posted: Fri Sep 15, 2006 7:33 pm Post subject: |
|
|
Bad news. ControlSend doesn't work either with my batchfile on my WIN98SE PC.
| majkinetor wrote: | In batch file put your first line to be
title TEST | This is what I was afraid for, Title command doesn't work in Win98. It only knows those batch commands from the DOS ages. |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|