Sign in to follow this  
Followers 0
MadBoy

Script to autojump to right window

3 posts in this topic

I have a problem with script below. What it is supposed to do is to jump to right window after it's executed by another program with winjump.exe <securecrt name>. It actually jumps to right window but since new version of SecureCRT (5+) has tabs implemented it's a bit problematic. For example after window change when i want to write something or press some button like '4' or '5' it isn't sent to shell until i take my mouse and press it once or twice to fully activate that window. I tried to use things that are now commented out (like imitating mouse button click), but it sometimes work and sometimes not. Problem on older versions of SecureCRT doesn't exist (when there are no 'tabs'). I also tried to use the ControlFocus but it didn't work as expected. I always have to press some mouse button on window or have to do something else to 'fully' activate the tab. Please help :P

#NoTrayIcon
If $CmdLine[0] = 0 Then
    MsgBox(64, "WinJump", "Usage: WinJump.exe <SecureCRT window name>")
    Exit
EndIf
WinActivate($CmdLine[1], "")
If WinActive($CmdLine[1]) Then
    ControlFocus($CmdLine[1], "", "1443")
;   $pos = MouseGetPos()
;   MouseClick("left", 300, 300, 0)
;   MouseMove($pos[0], $pos[1], 0)
EndIf

My little company: Evotec (PL version: Evotec)

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

If ControlFocus is a ControlID supplied, the I would expect 1443, not "1443". A number, not a string. Can you confirm this !?

Edited by MHz

Share this post


Link to post
Share on other sites

If ControlFocus is a ControlID supplied, the I would expect 1443, not "1443". A number, not a string. Can you confirm this !?

I changed it to 1443 as you suggested and it changed its behaviour. It kinda highlighted the tab (but only the tab) so i had to press mouse button again on the main window so it would work as i wanted it to, but then i played with code and replaced MouseClick("left", 300, 300, 0) with MouseClick("left", 300, 300, 1, 0) and suddenly it started working a bit better (needs more testing in 'hard' situations ;p). But now i am wondering if the ControlFocus($CmdLine[1], "", 1443) is needed at all since actually it doesn't do what it is supposed to do and i think that MouseClick line itself does the job. What you guys think?

If WinActive($CmdLine[1]) Then
    ControlFocus($CmdLine[1], "", 1443)
    $pos = MouseGetPos()
    MouseClick("left", 300, 300, 1, 0)
    MouseMove($pos[0], $pos[1], 0)
EndIf

My little company: Evotec (PL version: Evotec)

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