Jump to content

Recommended Posts

Posted

hi guys,

need some help here. ok i have a short program that can run and scan for the active window's PID. And from there, i can know the PID for the individual window. So now i am wondering how do i switch window using the PID? What commands to use? I have tried using Winactivate() but then it does not seems to work. Can someone enlighten me?

thanks.

Posted

hi guys,

need some help here. ok i have a short program that can run and scan for the active window's PID. And from there, i can know the PID for the individual window. So now i am wondering how do i switch window using the PID? What commands to use? I have tried using Winactivate() but then it does not seems to work. Can someone enlighten me?

thanks.

If you show us your code, we can help you fix it.

Posted

here is the short code ...

Global $xy, $start, $windows, $i, $win

$WinList=WinList()
for $i=1 to $WinList[0][0]
    If $WinList[$i][0] <> "" AND IsVisible($WinList[$i][1]) Then
        $win = WinGetTitle($WinList[$i][1])
        $win1 = WinGetProcess($WinList[$i][1])
        Sleep(2000)
        msgbox(4096, "Test",$WinList[$i][1] & @LF & $win & @LF & $win1,5)
    ;Sleep(2000)
        WinActivate($win)
        Sleep(2000)
        
    EndIf
Next

Func IsVisible($handle)
  If BitAnd( WinGetState($handle), 2 ) Then 
    Return 1
  Else
    Return 0
  EndIf

EndFunc
Posted

Seems to work for me. I simplified the IsVisible() func. Don't think that made a difference though.

Global $xy, $start, $windows, $i, $win

$WinList=WinList()
for $i=1 to $WinList[0][0]
    If $WinList[$i][0] <> "" AND IsVisible($WinList[$i][1]) Then
        $win = WinGetTitle($WinList[$i][1])
        $win1 = WinGetProcess($WinList[$i][1])
        Sleep(2000)
        msgbox(4096, "Test",$WinList[$i][1] & @LF & $win & @LF & $win1,5)
    ;Sleep(2000)
        WinActivate($win)
        Sleep(2000)
        
    EndIf
Next

Func IsVisible($handle)
  Return BitAnd( WinGetState($handle), 2 )
EndFunc
Posted

A similar question was asked recently- wanting to know how to get a window handle from a PID. I posted this-

$handle=_GetPIDWindows(4072)
if IsHWnd($handle) then
    WinKill($handle)
EndIf

func _GetPIDWindows($PID)
    $WinList=WinList()
    for $i=1 to $WinList[0][0]
        if WinGetProcess($WinList[$i][1])=$PID then 
            Return $WinList[$i][1]
        EndIf
    Next
    Return 0
EndFunc

You can change WinKill() to WinActivate() and 4072 to the PID in question.

Posted

hi guys,

the program will work. It will switch the window because i use "winactivate(the window title)". i want it to switch using the PID instead. like for example if i found that both similar name window PID is 2060 n 2828 respectivitly, how do i write it to switch to 2060 when i want it instead of 2828? i tried using "winactivate(2060)". it doesn't seems to work. hope you guys can understand. thanks.

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
  • Recently Browsing   0 members

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