Set Window Position

Aquí puedes preguntar o compartir tus dudas y conocimientos acerca del programa
Hi Forum, I need a simple code to set the window from Center to Upper, about 300 pixels.
I would insert this code in a button so I can decide the Window position.
Here there is an animated gif link to better understand what I need.
Thanks a lot in advance


http://s16.imagestime.com/out.php/i1112402_Demo.gif
Window.SetPos
Window.SetPos(Application.GetWndHandle (), 10, 20)
Como te dice el amigo de arriba, usa Windows.SetPos

Primero debes obtener la posición del eje X para poder mover solo la altura de los 300px;
local nPos = Window.GetPos(Application.GetWndHandle()); -- Se obtiene la posición de los ejes
	Window.SetPos(Application.GetWndHandle(), nPos.X, 300); -- Con la variable nPos en el index X llamamos a la posición sobre el eje 
 X para solamente mover el eje Y



Ahora para centrar de nuevo, pues debes obtener primero el tamaño completo de la pantalla;
local nDisplaySize = System.GetDisplayInfo(); -- Se obtiene el tamaño completo de la pantalla
local nAppSize = Window.GetSize(Application.GetWndHandle()); -- Se obtiene el tamaño de la ventana

Window.SetPos(Application.GetWndHandle(), (nDisplaySize.Width/2) - (nAppSize.Width/2), (nDisplaySize.Height/2) - (nAppSize.Height/2)); --Con una simple división y resta matemática obtenemos los valores para la posición de la ventana 

Suerte en tu proyecto :expolota

Imagen
Thanks, I appreciate this!
Only a last question: If I would to move the window in the upper right corner of the screen, what is the code?
I know that the "Action Extension" allows this easily, but I want to use only AMS code, avoiding external plugins.
Thanks Forum!
Holly escribió:Thanks, I appreciate this!
Only a last question: If I would to move the window in the upper right corner of the screen, what is the code?
I know that the "Action Extension" allows this easily, but I want to use only AMS code, avoiding external plugins.
Thanks Forum!
TOP_CENTER	  	= "TOP_CENTER"; 
TOP_RIGTH		= "TOP_RIGTH"; 
TOP_LEFT    	= "TOP_LEFT";
CENTER      	= "CENTER";
LEFT_CENTER 	= "LEFT_CENTER"; 
RIGTH_CENTER 	= "RIGTH_CENTER"; 
BOTTOM_LEFT  	= "BOTTOM_LEFT";
BOTTOM_CENTER	= "BOTTOM_CENTER";
BOTTOM_RIGTH 	= "BOTTOM_RIGTH";

function WindowSetPosAlwais(Args)
	desktop = System.GetDisplayInfo();
	pageSize = Window.GetSize(Application.GetWndHandle());
	hTrayWnd = DLL.CallFunction(_SystemFolder.."\\User32.dll", "FindWindowA", "\"Shell_trayWnd\",\"\"", DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL)
	TrayPos = Window.GetPos(hTrayWnd)
	TraySize = Window.GetSize(hTrayWnd)
	
	if (Args == "CENTER" or Args == 1) then 
		cordX = (desktop.Width/2)-(pageSize.Width/2);
		cordY = (desktop.Height/2)-(pageSize.Height/2);
	elseif (Args == BOTTOM_RIGTH or Args == 2) then
		if (TrayPos.X == 0 and TrayPos.Y > 0) then --abajo
			cordX = (desktop.Width)-(pageSize.Width);
			cordY = (desktop.Height)-(pageSize.Height)- (TraySize.Height);
		elseif (TrayPos.X > 0 and TrayPos.Y == 0) then--dercha
			cordX = (desktop.Width)-(pageSize.Width)- (TraySize.Width);
			cordY = (desktop.Height)-(pageSize.Height);
		else
			cordX = (desktop.Width)-(pageSize.Width)
			cordY = (desktop.Height)-(pageSize.Height);
		end
	elseif (Args == "BOTTOM_CENTER" or Args == 3) then
		if (TrayPos.X == 0 and TrayPos.Y > 0) then
			cordX = (desktop.Width/2)-(pageSize.Width/2)
			cordY = (desktop.Height)-(pageSize.Height)- (TraySize.Height);
		else
			cordX = (desktop.Width/2)-(pageSize.Width/2)
			cordY = (desktop.Height)-(pageSize.Height);
		end
	elseif (Args == "BOTTOM_LEFT" or Args == 4) then
		if(TrayPos.X==0 and TrayPos.Y==0 and TraySize.Height == desktop.Height) then--izkierda
			cordX = TraySize.Width;
			cordY = (desktop.Height)-(pageSize.Height);
		elseif (TrayPos.X == 0 and TrayPos.Y > 0) then
			cordX = 0;
			cordY = (desktop.Height)-(pageSize.Height)- (TraySize.Height);
		else
			cordX = 0;
			cordY = (desktop.Height)-(pageSize.Height);
		end
	elseif (Args == "RIGTH_CENTER" or Args == 5) then
		if (TrayPos.X > 0 and TrayPos.Y == 0) then--dercha
			cordX = (desktop.Width)-(pageSize.Width)- (TraySize.Width);
			cordY = (desktop.Height/2)-(pageSize.Height/2);
		else
			cordX = (desktop.Width)-(pageSize.Width)
			cordY = (desktop.Height/2)-(pageSize.Height/2);
		end
	elseif (Args == "LEFT_CENTER" or Args == 6) then
		if(TrayPos.X==0 and TrayPos.Y==0 and TraySize.Height == desktop.Height) then--izkierda
			cordX = TraySize.Width;
			cordY = (desktop.Height/2)-(pageSize.Height/2);
		else
			cordX = 0;
			cordY = (desktop.Height/2)-(pageSize.Height/2);
		end
	elseif (Args == "TOP_CENTER" or Args == 7) then
		if (TrayPos.X==0 and TrayPos.Y==0 and TraySize.Width == desktop.Width) then--arriba
			cordX = (desktop.Width/2)-(pageSize.Width/2)
			cordY = TraySize.Height;
		else
			cordX = (desktop.Width/2)-(pageSize.Width/2)
			cordY = 0;
		end
	elseif (Args == "TOP_LEFT" or Args == 8) then
		if (TrayPos.X==0 and TrayPos.Y==0 and TraySize.Width == desktop.Width) then--arriba
			cordX = 0;
			cordY = TraySize.Height;
		elseif(TrayPos.X==0 and TrayPos.Y==0 and TraySize.Height == desktop.Height) then--izkierda
			cordX = TraySize.Width;
			cordY = 0;
		else
			cordX = 0;
			cordY = 0;
		end
	elseif (Args == "TOP_RIGTH" or Args == 9) then
		if (TrayPos.X==0 and TrayPos.Y==0 and TraySize.Width == desktop.Width) then--arriba
				cordX = (desktop.Width)-(pageSize.Width)
				cordY = TraySize.Height;
		elseif (TrayPos.X > 0 and TrayPos.Y == 0) then
			cordX = (desktop.Width)-(pageSize.Width)-(TraySize.Width);
			cordY = 0;
		else
			cordX = (desktop.Width)-(pageSize.Width)
			cordY = 0;
		end
	end
	Window.SetPos(Application.GetWndHandle(),cordX,cordY);
	return Application.GetLastError();
end

WindowSetPosAlwais(9)
Holly escribió:Thanks, I appreciate this!
Only a last question: If I would to move the window in the upper right corner of the screen, what is the code?
I know that the "Action Extension" allows this easily, but I want to use only AMS code, avoiding external plugins.
Thanks Forum!
Es el mismo concepto, obtén el tamaño completo de la pantalla con System.GetDisplayInfo y solo has la resta
hHandle :: Es el numero de ventana
x :: Ancho total de la pantalla menos el ancho total de la ventana de la aplicacion (Window.GetSize)
y:: 0 (cero) para ponerlo hasta arriba

Window.SetPos(hHandle, x ,y)
Thanks to all, I will try it!