AutoHotkey Community

It is currently May 27th, 2012, 12:21 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 11 posts ] 
Author Message
PostPosted: August 30th, 2005, 4:57 pm 
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. :roll:

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


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: August 30th, 2005, 9:02 pm 
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.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: August 31st, 2005, 2:05 am 
Offline

Joined: August 17th, 2005, 11:10 pm
Posts: 8
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". :)

-tb2

_________________
-tb2


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 31st, 2005, 8:24 am 
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


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: August 31st, 2005, 8:47 am 
Offline

Joined: January 31st, 2005, 9:50 am
Posts: 3910
Location: Bremen, Germany
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
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 31st, 2005, 3:14 pm 
Offline

Joined: August 17th, 2005, 11:10 pm
Posts: 8
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 :?:

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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 31st, 2005, 3:33 pm 
Offline

Joined: January 31st, 2005, 9:50 am
Posts: 3910
Location: Bremen, Germany
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
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 31st, 2005, 3:35 pm 
Offline

Joined: January 31st, 2005, 9:50 am
Posts: 3910
Location: Bremen, Germany
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
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 31st, 2005, 3:43 pm 
Offline

Joined: November 6th, 2004, 11:03 am
Posts: 170
Location: Salt Lake City, UT
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!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 31st, 2005, 3:54 pm 
Offline

Joined: January 31st, 2005, 9:50 am
Posts: 3910
Location: Bremen, Germany
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
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 2nd, 2005, 8:15 pm 
Offline

Joined: November 6th, 2004, 11:03 am
Posts: 170
Location: Salt Lake City, UT
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.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Leef_me, Pulover, rjgatito, XstatyK, Yahoo [Bot] and 22 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:
cron
Powered by phpBB® Forum Software © phpBB Group