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 

Stumbling Block - ControlSend

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Guest






PostPosted: Tue Aug 30, 2005 4:57 pm    Post subject: Stumbling Block - ControlSend Reply with quote

All:

I've been using AHK for awhile, but my "programs" are generally pretty simple scripts. Though they have saved me enormous amounts of time and keystrokes, they are very "foreground" in nature.

I *assume* that AHK will run in background - that is to say go on doing it's thing in a window I have minimized while I go on about other tasks. And I'm pretty sure that ControlSend is the key. But I have yet to get a handle on it. I've searched these forums, and I see I'm not the only one. However, I still can't seem to get past this command. And with only a few parameters, it does make me feel a little dense. Rolling Eyes

Here is a typical example: I have to log into 150+ nodes via telnet, and execute a command or two. Say, update my password. I use Hummingbird emulator (NOT by choice - believe me!). It runs perfectly as long a focus remains on that window. I try to go off to read mail, shrink that window, etc and disaster strikes (particularly if I don't make AHK "window sensitive"). So I'm pretty much stuck just watching AHK do my legwork for 30 minutes, doing nothing myself, sipping my coffee.

The AHK script in the example above is maybe 10 lines long. The same thing using Hummingbird's language would be in the ballpark of the Old Testament. Which is why I'm reluctant to learn Hummingbird's bozo language.

So, can I get there from here using AHK?

Thanks in advance!

-tb2
Back to top
BoBo
Guest





PostPosted: Tue Aug 30, 2005 9:02 pm    Post subject: Reply with quote

Quote:
Here is a typical example: I have to log into 150+ nodes via telnet, and execute a command or two. Say, update my password.
Wouldn't it be possible to use [psexec] ?
Quote:
Utilities like Telnet and remote control programs like Symantec's PC Anywhere let you execute programs on remote systems, but they can be a pain to set up and require that you install client software on the remote systems that you wish to access. PsExec is a light-weight telnet-replacement that lets you execute processes on other systems, complete with full interactivity for console applications, without having to manually install client software. PsExec's most powerful uses include launching interactive command-prompts on remote systems and remote-enabling tools like IpConfig that otherwise do not have the ability to show information about remote systems
That way you can use AHK's Run/RunWait to trigger whatever is necessary on the remote box.
Back to top
timbuk2



Joined: 17 Aug 2005
Posts: 8

PostPosted: Wed Aug 31, 2005 2:05 am    Post subject: Reply with quote

Interesting.... VERY interesting.

But, to be honest, I'd was hoping to control the whole thing from a single source.

With AHK - I've got a one text file with all the nodes I wish to execute the commands on. Another text file with the file containing the commands I wish to execute. Compile the AHK puppy, and I've got a tool that knocks out a whole lot of work with very simple text entries.

Not to say I wont give it a whirl. It looks like you've turned me onto something pretty slick. Hey - always looking to make the job easier.

Thanks VERY much, BoBo! Sounds like you're the proverbial "been there, done that". Smile

-tb2
_________________
-tb2
Back to top
View user's profile Send private message
BoBo
Guest





PostPosted: Wed Aug 31, 2005 8:24 am    Post subject: Reply with quote

Quote:
Compile the AHK puppy, and I've got a tool that knocks out a whole lot of work with very simple text entries
which shouldn't be a problem (even with psexec included) check out AHK's
Quote:
FileInstall
--------------------------------------------------------------------------------
Includes the specified file inside the compiled script.

FileInstall, Source, Dest, Flag
Back to top
toralf



Joined: 31 Jan 2005
Posts: 3842
Location: Bremen, Germany

PostPosted: Wed Aug 31, 2005 8:47 am    Post subject: Reply with quote

You could as well use putty or plink.
I like them since they can use ssh connections with public/private key authentication. Both support remote commands, and plink is even designed for use in batch files. No installation neccessary, only the exe files.
_________________
Ciao
toralf
Back to top
View user's profile Send private message Send e-mail Visit poster's website
timbuk2



Joined: 17 Aug 2005
Posts: 8

PostPosted: Wed Aug 31, 2005 3:14 pm    Post subject: Reply with quote

The question of emulators is moot. I got Hummingbird shoved down my throat, like it or not. No other emulators allowed. I used to use KEA -next generation XTALK - and could program it to peel a bananna if you laid it on your monitor. The point is - I'm stuck with Hummingbird, and can't even use run-of-the-mill software like Putty.

PsExec, while pretty cool, doesn't seem to know what to do with UNIX, VMS or SSH connections. I don't work on PCs (thank God!), so I'm afraid that doesn't help with my current problem.

Which brings me back to AHK.

I have not seen this stated in here or the help documentation (doesn't mean it's not) so let me ask this one basic question:

Can AHK, or can it not, run in a minimized window while I do other things on my PC Question

If it can, I'll just keep plugging at it until I figure out how. If not, I guess I'm going to have to subject myself to learning Hummingbirds half-assed Visual Basic scripting language.

Regardless, I appreciate all your suggestions!
_________________
-tb2
Back to top
View user's profile Send private message
toralf



Joined: 31 Jan 2005
Posts: 3842
Location: Bremen, Germany

PostPosted: Wed Aug 31, 2005 3:33 pm    Post subject: Reply with quote

Please have a look at the command "ControlSend". I think it is possible to send data to also minimized windows. Please test it.
_________________
Ciao
toralf
Back to top
View user's profile Send private message Send e-mail Visit poster's website
toralf



Joined: 31 Jan 2005
Posts: 3842
Location: Bremen, Germany

PostPosted: Wed Aug 31, 2005 3:35 pm    Post subject: Reply with quote

uuuppps, I just re-read your first post, you knew about ControlSend. Sorry.

What is the problem with that command? Could you post some small code?
_________________
Ciao
toralf
Back to top
View user's profile Send private message Send e-mail Visit poster's website
ranomore



Joined: 06 Nov 2004
Posts: 178
Location: Salt Lake City, UT

PostPosted: Wed Aug 31, 2005 3:43 pm    Post subject: Reply with quote

My experience has been that ControlSend works a lot better with some programs if it has a window ID to work on, as opposed to a window name.
Code:
   
WinGet, active_WindowID, ID, A
ControlSend,Edit1,Text,ahk_id %active_WindowID%

Maybe that helps, but I think Toralf is right that we can do a lot more with a little bit of code!
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
toralf



Joined: 31 Jan 2005
Posts: 3842
Location: Bremen, Germany

PostPosted: Wed Aug 31, 2005 3:54 pm    Post subject: Reply with quote

I have a script that opens a ssh connection with putty and changes the directory via ControlSend. It also works for minized windows. Maybe you can modify it to work with hummingbird
Code:
;#############   Open SHH connection to server   ####################################
OpenSSHConnection:
  Run, "%ExeSSHclient%" -ssh -i "%FilePublicSSHKey%" %USERNAME%@%A_ThisMenuItem%,,,SSH_PID
  WinWait, ahk_pid %SSH_PID%,,2
  if not ErrorLevel
    {
      ;prepare change of directory
      StringMid, ScratchNumber, A_ThisMenuItem, 6, 3
      String =
        (LTrim
          cd /scratch/scr%ScratchNumber%a/%USERNAME%
          clear
          pwd
        )
     
      ;wait for authentification to take place
      Sleep, 1500

      ;change directory
      ControlSend, ahk_parent, %String%{Enter}, ahk_pid %SSH_PID%
    }
Return


If someone knows how to avoid the Sleep, I would like to get a pointer.
_________________
Ciao
toralf
Back to top
View user's profile Send private message Send e-mail Visit poster's website
ranomore



Joined: 06 Nov 2004
Posts: 178
Location: Salt Lake City, UT

PostPosted: Fri Sep 02, 2005 8:15 pm    Post subject: Reply with quote

Quote:
If someone knows how to avoid the Sleep, I would like to get a pointer.


First, let me say that I've never actually tried this, I've kind of just absorbed it from the forum.

Second, I don't know anything about putty, so I'm not sure if this is possible (although I did look at the documentation for it a little). There is some related explanation here:
http://www.autohotkey.com/forum/viewtopic.php?t=3340
or you could search the forum for "pipesplit" (it's a command line utility).

The basic idea is that putty, or whatever the command line util is, sends messages via errorlevel. Assuming you know how putty sends errorlevel messages, and you know which one to look for, you can avoid the need for the "Sleep" command. It seems like a lot of work to me, but I'd rather do it than use the "Sleep" command too.
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
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