Sign in to follow this  
Followers 0
ayatest

problem with WinMove

9 posts in this topic

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.

Share this post


Link to post
Share on other sites



give each window a separate handle. You are using $hwnd for both

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

#4 ·  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.

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

Use the spy tool and output the window's information.

I doubt the class of your app includes .exe in it.

Also, do error handling on the winwait (IsHwnd) to verify you are in fact grabbing the handle.


IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

#6 ·  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.

Share this post


Link to post
Share on other sites

As jdelaney points out, use the AutoIt Window Info Tool to get the class, located in the same directory where you installed AutoIt (AU3Info.exe)


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

#8 ·  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.

Share this post


Link to post
Share on other sites

Title is the default.  It will work as you provided, or just as a string in the first param.


IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

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