Jump to content

WinMove won't move a certain window - (Locked)


jebus495
 Share

Recommended Posts

This one really has me scratching my head, so much so that I've resorted to the help of wonderful friendly internet people.

So I made a simple script to move and resize half a dozen windows into their proper positions for my twitch stream.

The problem is that one of these windows does not want to cooperate.

Here is my script:

#include <Array.au3>

HotKeySet("{END}", "_Terminate")
HotKeySet("{INSERT}", "_WinMove")

Global $aWin[][] = _
[["Chat - Twitch", 1051, 557, 872, 495] _
, ["Raid and Host - Twitch", 0, 625, 404, 397] _
, ["Stream Information - Twitch", 808, 261, 242, 763] _
, ["Stream Markers - Twitch", 406, 625, 400, 399] _
, ["Stats - Twitch", 807, 0, 243, 261] _
, ["OBS", 1050, 0, 873, 557] _
, ["Diablo", 0, 0, "", ""]]

;_ArrayDisplay($aWin)

While 1
    Sleep(50)
WEnd

Func _WinMove()
    ;$d2hndle = WinGetHandle("Diablo II")
    ;WinActivate($d2hndle)
    ;WinMove($d2hndle, "", 0, 0)

    For $i = 0 To 6
        $aWinHan = WinActivate($aWin[$i][0])
        WinWaitActive($aWinHan)
        Sleep(50)
        WinMove($aWinHan, "", $aWin[$i][1], $aWin[$i][2], $aWin[$i][3], $aWin[$i][4])
    Next
EndFunc

Func _Terminate()
    Exit
EndFunc

So I set up an array with all the data I want to use and then use a loop to move all the windows. The diablo window is the only window that will not move to the x, y location specified. As a test I made a text file with "Diablo II" in its title and tested the script on that, it moves the text window to 0, 0 as expected.

The Diablo 2 window responds to WinActivate but it will not move to the 0, 0 position (or any position) using the WinMove function for reasons I can't comprehend. I specifically recall using AutoIt to do this exact same thing several years ago.

Link to comment
Share on other sites

have you tried just moving the window in a simple test script without the variables to see if AutoIt WILL in fact move the window?

also, are you sure AutoIt is grabbing the correct window title?

If @error Then
    MsgBox(262192, "", @ComputerName & " slaps " & @UserName & " around a bit with a large trout!")
EndIf

"Yeah yeah yeah patience, how long will that take?"  -Ed Gruberman

REAL search results  |  SciTE4AutoIt3 Editor Full Version

Link to comment
Share on other sites

not to shit on your very nice array loop setup (i would have never thought to do it that way), but why not just use 7 simple winmove commands since the names and positions dont change?

also, if the window title ends up being the problem you may need to change wintitlematchmode option 

Opt("WinTitleMatchMode", 1) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase
If @error Then
    MsgBox(262192, "", @ComputerName & " slaps " & @UserName & " around a bit with a large trout!")
EndIf

"Yeah yeah yeah patience, how long will that take?"  -Ed Gruberman

REAL search results  |  SciTE4AutoIt3 Editor Full Version

Link to comment
Share on other sites

Here is a more basic explanation

WinMove("Diablo II", "", 0, 0)

This will work if it matches a notepad window with Diablo II in the title but it will not work with the actual game window Diablo II.

 

    ;$d2hndle = WinGetHandle("Diablo II")
    ;WinActivate($d2hndle)
    ;WinMove($d2hndle, "", 0, 0)

I tested this by uncommenting this section and then commenting out the entire For loop.

It will activate the window but it will not move it.

Edited by jebus495
Link to comment
Share on other sites

i understood your post, my point is that if winmove works on a notepad named "Diablo II" but not on the actual Diablo window, then the title of the Diablo window may not be what you think it is, have you double checked it with the window info tool?

forget about the fact that the winactivate is working, that may be a false positive leading you the wrong direction.

 

If @error Then
    MsgBox(262192, "", @ComputerName & " slaps " & @UserName & " around a bit with a large trout!")
EndIf

"Yeah yeah yeah patience, how long will that take?"  -Ed Gruberman

REAL search results  |  SciTE4AutoIt3 Editor Full Version

Link to comment
Share on other sites

also i remember seeing other posts in the past about certain games blocking ALL automation tools, not sure if that would affect the actual window or not though.

If @error Then
    MsgBox(262192, "", @ComputerName & " slaps " & @UserName & " around a bit with a large trout!")
EndIf

"Yeah yeah yeah patience, how long will that take?"  -Ed Gruberman

REAL search results  |  SciTE4AutoIt3 Editor Full Version

Link to comment
Share on other sites

for a basic test to check if title is issue, do a simple script...

Opt("WinTitleMatchMode", -2) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase
WinMove("diablo", "", 0, 0)

but make sure there are NO other windows with "Diablo" anywhere in the title, no test .txt. nor the window info tool.

one time i was testing a script and it kept closing the window info tool instead because it had the window title in it. took me 30 minutes to figure it out.

If @error Then
    MsgBox(262192, "", @ComputerName & " slaps " & @UserName & " around a bit with a large trout!")
EndIf

"Yeah yeah yeah patience, how long will that take?"  -Ed Gruberman

REAL search results  |  SciTE4AutoIt3 Editor Full Version

Link to comment
Share on other sites

I have used the window info tool and I used the WinList function with an _ArrayDisplay and they both confirm that the window title is Diablo II

If it blocks all automation tools then I find it hard to understand why WinActivate works but WinMove does not. The only workaround I have at this point is using MouseClickDrag to move it xD

I found _WinAPI_MoveWindow() and I tried that function but the same result. It will move other windows but not Diablo II.

Edited by jebus495
Link to comment
Share on other sites

  • Developers

Welcome to the AutoIt forum.

Unfortunately you appear to have missed the Forum rules on your way in. Please read them now - particularly the bit about not discussing game automation - and then you will understand why you will get no help and this thread will now be locked.

See you soon with a legitimate question I hope.

The Moderation team

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

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