Jump to content

keystroke to inactive window. Help.


Recommended Posts

Hello guys, i'm new here, I would like to get some help to fix my script, I'm trying to send keystroke to Fiddler Web Debugging, it seem like i have to keep the window focus to get it to work.

Func MyExit()
    Exit
EndFunc   ;==>MyExit

HotKeySet("{ESC}", "MyExit")

While True
    ControlSend("Fiddler Web Debugger", "", "", "{s}")
    Sleep(1000)
WEnd
Link to comment
Share on other sites

not sure what to do... I search around.

I found

If WinActive("[CLASS:Notepad]") Then
    MsgBox(0, "", "Window was active")
EndIf

Where it say Class:Notepad.. I am not sure what to put in there, I used Au3info.exe to find class, and this is what i found "Class:WindowsForms10.Window.8.app.0.ea7f4a_r11_ad1" looks kinda too long.

Where do i need to place these code?

Edited by frostchill
Link to comment
Share on other sites

Maybe you can save current window handle and then restore it after ControlSend, but still it's annoying:

Local $hCurrentWin
While True
    If WinExists("Fiddler Web Debugger") Then
        $hCurrentWin = WinGetActive()
        WinActivate("Fiddler Web Debugger")
        ControlSend("Fiddler Web Debugger", "", "", "{s}")
        WinActivate($hCurrentWin[0])
    EndIf
    Sleep(1000)
WEnd

Func WinGetActive()
    Dim $window[2]
    Dim $winlist
    $winlist = WinList()
    For $i = 1 to $winlist[0][0]
        If $winlist[$i][0] <> "" AND IsVisible($winlist[$i][1]) Then
            $window[0] = $winlist[$i][0]
            $window[1] = $winlist[$i][1]
            ExitLoop
        EndIf
    Next
    Return $window
EndFunc

Func IsVisible($handle)
    If BitAnd( WinGetState($handle), 2 ) Then
        Return 1
    Else
        Return 0
    EndIf
EndFunc
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...