Jump to content

problem with WinMove


Go to solution Solved by ayatest,

Recommended Posts

Posted

I saw, that some people experienced similar problems, but at the end I don't know what can/should I do and how. Here is a script:

;Run("notepad.exe")

;Local $hWnd = WinWait("[CLASS:Notepad]", "", 10)



Local $sEnvVar = EnvGet("ProgramFiles(x86)")

Run($sEnvVar & "\my folder1\my folder2\myapp.exe")

Local $hWnd = WinWait("[CLASS:myapp.exe]", "", 10)



Sleep(1000)

Send("r")

Sleep(2000)

Send("r")



while 1

activities2()

wend



func activities2()

; generate random (int) coordinates (and window sizes - min value is limited by autoit) within current screen resolution range.

; autoit debugger shows that coordinates are random per each loop cycle.



Sleep(1000)

$xwin = Random(0, @DeskTopWidth, 1)

$ywin = Random(0, @DeskTopHeight, 1)

$wwin = Random(0, @DeskTopWidth, 1)

$hwin = Random(0, @DeskTopHeight, 1)

WinMove($hWnd, "", $xwin, $ywin, $wwin, $hwin)

endfunc

When I switch to notepad - everything works fine, as expected. When I switch to myapp (a program under stress tests) - the app starts, receives test hotheys, but WinMove (move across the screen and resize) is not performed. Debugger shows no errors.

App is standard Win program, resizable, in non-maximized state.

How can I check why this is not working (I'm guessing tha WinMove isn't finding the window for some reason) and how can I fix it? This is 32bit app under 64bit win 8.

functional testing. multimedia recording. flowstone. mouseclick, hotkeys and modularity in general.

Posted (edited)

One is commented out, I imagine been used for testing.

The real test should be carried out after...

Local $hWnd = WinWait("[CLASS:myapp.exe]", "", 10)

To ensure winwait succeeded.

Yes, notepad is commented out because it was for testing (interchangeably).

WinClose with no effect.

For class - I used what task manager shows in processes list. Was it wrong?

Edited by ayatest

functional testing. multimedia recording. flowstone. mouseclick, hotkeys and modularity in general.

  • Solution
Posted (edited)

Following some other suggestions, I did two things:

1) Added

Opt("WinTitleMatchMode", 2)

In the header, so that Win operator looks for partial string within app section

2) Changed

WinWait("[CLASS:.........
into
WinWait("[TITLE:..........

(since title is unique for the app)

Works like a charm.

Quick references for other seekers:

https://www.autoitscript.com/autoit3/docs/functions/AutoItSetOption.htm#WinTitleMatchMode

https://www.autoitscript.com/autoit3/docs/intro/windowsadvanced.htm

Any suggestions or comments to the method I used? (any limitations or problems to expect?)

Edited by ayatest

functional testing. multimedia recording. flowstone. mouseclick, hotkeys and modularity in general.

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...