Jump to content

Recommended Posts

Posted (edited)

Hi,

with using WinList() I store a Winhandle ($handle = 0x00270492) in a listview.

Later on I will use it in WinActivate($handle). But that doesn't work.

For testing I wrote the given handle ($handleSaved = "0x00270492") manual in and use it in WinActivate.

That also doesn't work.

If I compare via Winlist the actual given handle from Winlist with $handleSaved

I get the result: both are the same.

But if I use in WinActivate the actual given handle it works, if I use $handleSaved it doesn't work.

Attached the (poor) testing script.

Let it rune once to note a $handleSaved. In the second run it should activate the saved window.

best regards, Reinhard

PS: I know that I can activate the Window bay using the comparison and WinList() again, but I think there is a more direct way.

$var = WinList()
$handleSaved = "0x00040440";"0x00270492"
$Test = "N"

For $i = 1 to $var[0][0]
; Only display visble windows that have a title
  If $var[$i][0] <> "" AND IsVisible($var[$i][1]) Then
    $handle = $var[$i][1]
    consolewrite($handle &@LF)
    if $handleSaved = $handle then $Test = "Y"
    $OK = MsgBox(1, "Details", "Title=" & $var[$i][0] & @LF & "Handle=" & $var[$i][1] &@lf&@lf _ 
    &"WinActivate?"&"  "&isbinary($handle)&":"&isHWND($handle)&":"&$Test)
    if $OK = 1 then WinActivate($handleSaved)
    $Test = "N"
  EndIf
Next

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

EndFunc
Edited by ReFran
Posted

I can't replicate cause I'm not sure what this line is... WinActivate($handleSE)

Whats $handleSE meant to be?

Excuse me.

I used $handleSE in my origin, but thought on a public basic $handleSaved is better.

I change it in above script.

Thanks, Reinhard

Posted

You need to remember the handle changes every time you close/open the window. I'm not sure if this is your problem but I usually check the PID of the process against the returned info (handle/title). If it is the same then I store that handle in a Global variable. This may also be your problem.

Posted

That's not the problem.

The process is running,

the comparison part say the values are equal,

but I don't get the stored or typed in value to act as HWnd.

I can set up a workaround, but I think it's a bug, or?

br, Reinhard

Attached some more testing:

;;; 0x0066055C = Running process of Total commander

Opt ("WinTitleMatchMode", 4)
GLOBAL $handleGlobal = 0x0066055C
$handle = "0x0066055C"
 
; Winactivate($handleGlobal); as goblal - don't work
; WinActivate(0x0066055C); manual typed in - don't work
; WinActivate($handle);as saved string - don't work
$handleBin = Binary($handle)
; Winactivate($handleBin);dont work
Posted

Here's what I do, it might help you out. I don' have the program you're using so I can't test myself but this might give you a hint or something. Hope it helps somehow.

$list = WinList("Total commander")
For $i = 1 To $list[0][0]
    If WinGetProcess($list[$i][0]) = $PID Then
        Global $handle = $list[$i][1]
    EndIf
Next
Posted

Mmmh,

that works somehow. Will test it more and then see if I use that or my workaround (reactivate handle value to hwnd).

It drives me crazy if I think I can write it in some few minutes

and then I need hours to get it to work.

Thank you very much for your testing and solution,

have to go out for some fresh air ;-)

Reinhard

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
×
×
  • Create New...