0
votes

I've tested my script on other windows, such as the Calculator (so it's not simply a problem with my script), but when I'm running the CarbonPoker application, the table window won't move. I can activate the window, and I can get the title and display it with MsgBox, but I can't get it to move.

I've tried

WinMove,0,0

and I've tried

WinGetTitle, Title, A
WinMove,ahk_id %Title%,, %xval%,%yval%,%width%,%height%

and I've tried

WinMove,%Title%,, %xval%,%yval%,%width%,%height%

Are there some applications which can't have their windows moved? Or is there a way to still do it for such applications? Thanks.

2
Also WinGet OutputVar is null, or if I use this other approach: UniqueID := WinActive(%Title%) then UniqueID is 0x0user2278448
Try UniqueID := WinExist(Title)Joe DF
Did you check any of the answers? Did they work for you?vasili111

2 Answers

0
votes

Code Updated. Now you can move window if it is overlapped by other window. Also added variable for WinTitle.

You can also try to move window other way:

CoordMode, Mouse, Screen ;sets coordinate mode relative to screen.

DestX:=200 ; the x coordinate of the point where you want to see left upper point of window.
DestY:=10 ; the y coordinate of the point where you want to see left upper point of window.
WinTitleVar:="Notepad" ; The part of WinTitle of window that we need to move.

;Here are shift variables. What they meen? You cant just drug by left upper corner of window. You need to shift slightly right and down to be able to drag window. That variables are giving that shift to your coordinates.
ShiftX:= 30 ; shift for x coordinate.
ShiftY:= 10 ; shift for y coordinate.

DestX:= DestX + ShiftX ; apply shift to DestX .
DestY:= DestY + ShiftY ; apply shift to DestY .

SetTitleMatchMode, 2 ; Whith that command a window's title can contain WinTitle anywhere inside it to be a match. It is for WinGetPos command. You can remove this command, but then you need to use exact title in WinGetPos command.
WinGetPos, InitX, InitY,,, %WinTitleVar% ; get current upper left position of notepad window.
InitX:= InitX + ShiftX ; apply shift to InitX .
InitY:= InitY + ShiftY ; apply shift to InitY .

WinActivate, %WinTitleVar% ; Activates Window. This command is here in cases if other window overlaps the window that we need to move.
Click, Left, Down, %InitX%, %InitY% ; Click the left button but dont release it at the shifted coordinates of current window location. 
MouseMove, %DestX%, %DestY% ; Move mouse to the shifted destination coordinates.
Click, Left, Up ; Release Left mouse button.

I commented code as much as possible but if you have any questions feel free to ask.

0
votes

First, if your other application is being run as administrator, then your script also needs to be run with the same administrator permissions. I would check this first.

Next, you can try using the hwnd instead of the title:

; hover mouse over the window, and press f3 to move window

f3::
   MouseGetPos,,, hwnd
   WinMove, ahk_id %hwnd%,, 0, 0
return