Jump to content
Sign in to follow this  
Hcc

Sending Esc+a to non-active PuTTY

Recommended Posts

Hcc

Hi!

I'm completely new with AutoIt, and I confess I don't have the time to learn scripting with it right now.

I am looking for a way to send a Esc+a keypress to a PuTTY window with a predefined key even when PuTTY is inactive, so that I can easily switch between Irssi (Irc client running on Screen on PuTTY) channel windows.

I am using a dual monitor setup on my system, and for example, when I'm using Firefox on my main screen and PuTTY on my secondary screen, I want to be able to switch Irssi windows with a single keypress (a function key (F1-F12) possibly) when Firefox or any other program is active. Is this possible with AutoIt, and would anyone of you more eperienced guys be willing to write me a script for this purpose?

Thank you in advance for all help!

-Hcc, Finland

 

Edited a missing parenthesis messing up a sentence

Edited by Hcc

Share this post


Link to post
Share on other sites
computergroove

All of this is possible. Do you wnat to send Esc and release then send a or do you want both pushed at the same time?


Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html

Share this post


Link to post
Share on other sites
Hcc

Hi computergroove,

First Esc and then "a" (not "A") right after the Esc should do the trick.

Share this post


Link to post
Share on other sites
MikahS

Hm, something like this might help give you a better understanding of what's going on:

#include <WindowsConstants.au3>


HotKeySet("{F1}", "sendKey")  ; set the F1 key to run the sendKey() function
HotKeySet("{F2}", "Quit")  ; set the F2 key to stop the script from running


While 1
    ;keep this script running infinitely
WEnd


Func sendKey()
    Local $hWin, $pWin, $pWinError
    $pWin = WinGetHandle("") ; get handle to the window that is being used before making Putty the active window
    $hWin = WinActivate("PuTTY") ; make Putty the active window
    If $hWin = 0 Then  ; if we couldn't make Putty the active window, then..
        MsgBox(0, "title", "Could not make Putty the active window")  ; tell us!
        Return ; quit the function since we couldn't make Putty the active window
    EndIf
    Send("{ESC}a") ; if Putty is the active window, then send ESCAPE + "a"
    $pWinError = WinActivate($pWin) ; active the previously active window, since we are done sending to Putty
    If $pWinError = 0 Then ; if we can't find any previously opened window, then..
        MsgBox(0, "prev", "Could not find previously used window") ; tell us!
    EndIf
EndFunc

Func Quit()
    MsgBox(0, "Quit", "Stopping script") ; tell us we are stopping the script..
    Exit ; stop the entire script
EndFunc
 
Edited by MikahS

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites
Hcc

MikahS, Thank you very much - works like a charm!

Let me know if you have paypal or similar to let me buy you a beer/coffee/whatever you fancy :)

Share this post


Link to post
Share on other sites
MikahS

You're very welcome, and no need your gratitude is enough for me :thumbsup:

EDIT: grammar

Edited by MikahS

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites
Hcc

Hi again, I'm returning with a question related to the script provided by MikahS.

I've added some functions to it, and now I'm facing a problem - how can I simulate pressing the left arrow twice and then the up arrow once, all this while holding the WIN key down? I tried something like this:


Send("{LWIN down}{LEFT 2}{UP}{LWIN up}")

but it wasn't any good. Help, please? :)

Edited by Hcc

Share this post


Link to post
Share on other sites
MikahS

This should do it :)

Send("{LWINDOWN}")
Send("{LEFT 2}")
Send("{UP}")
Send("{LWINUP}")

EDIT: Fixed fourth line send statement - from "Send{" to "Send("

Edited by MikahS

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites
Hcc

Thanks! (There's a { instead of a ( on the fourth line, but I figured that out :P)

Share this post


Link to post
Share on other sites
MikahS

Glad to help @Hcc :) nice catch ;)


Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

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  

×