leighhobson89
New Member
- Joined
- Aug 25, 2016
- Messages
- 36
Good afternoon,
Can anyone provide me with the code required to find the screen co-ordinates of any window, searchable by its window name as it would appear in appActivate() for example? I know nothing about using APIs to find windows, nor handles etc., and the numerous threads I have read make no sense to me. I am looking for a copy and paste solution to move a stubborn window by VBA, that opens exactly in the center of the screen irrespective of the resolution, and maximising and sizing is disabled on it. Incidentally most keyboard shortcuts cannot be used in it either which is the reason for this, so i can simulate mouse clicks instead once i set the location of the window. (I will need help on that too eventually I guess
I need this for 64bit and 32bit API libraries, as it will be used on different versions of excel (i.e. one function fits all via If <64 bit> Then... : Else <32 bit>... ).
It is a big ask, but if anyone has a spare hour it would be a huge help, as I am blocked from completing my macro and can't get my head around this topic at all.
I should add that Application.Top, Application.Left etc don't work for this external window.
e.g.
To be called with something like:
Yours Hopefully!!
Can anyone provide me with the code required to find the screen co-ordinates of any window, searchable by its window name as it would appear in appActivate() for example? I know nothing about using APIs to find windows, nor handles etc., and the numerous threads I have read make no sense to me. I am looking for a copy and paste solution to move a stubborn window by VBA, that opens exactly in the center of the screen irrespective of the resolution, and maximising and sizing is disabled on it. Incidentally most keyboard shortcuts cannot be used in it either which is the reason for this, so i can simulate mouse clicks instead once i set the location of the window. (I will need help on that too eventually I guess
I need this for 64bit and 32bit API libraries, as it will be used on different versions of excel (i.e. one function fits all via If <64 bit> Then... : Else <32 bit>... ).
It is a big ask, but if anyone has a spare hour it would be a huge help, as I am blocked from completing my macro and can't get my head around this topic at all.
I should add that Application.Top, Application.Left etc don't work for this external window.
e.g.
Code:
Sub MoveWindow(posLeftCurrent As Integer, posTopCurrent As Integer, posLeftNew As Integer, posTopNew As Integer, windowNameToMove As String)
...CODE
End Sub
To be called with something like:
Code:
...
appActivate("Untitled - Notepad")
MoveWindow(400, 200, 0, 0, "Untitled - Notepad")
...
Yours Hopefully!!