Unir 2 ejecutables en 1 Topic is solved

Esta sección es para preguntas sobre programación/scripting usando AutoHotkey.

Moderator: Flipeador

Dsalomon
Posts: 22
Joined: 02 Mar 2021, 23:01

Unir 2 ejecutables en 1

Post by Dsalomon » 27 Sep 2022, 14:12

Buen día, quisiera ayuda para unir estos 2 scripts en 1

Lo estoy haciendo así pero no me funciona:

Code: Select all

DetectHiddenWindows, on
SetTitleMatchMode, 2

Funcion1() 
Funcion2()
return

Funcion1(){
	
Loop
	{
	COMPROBAR:
	IfWinExist, ahk_exe mpc-be64.exe
	{
		SendMessage, 0x111, 888,,, ahk_class MediaPlayerClassicW
		PostMessage , 0x112 , 0xF060 ,,, ahk_exe Dream Scroller.exe
		Goto, ESPERAR
	}
	Goto, COMPROBAR
	ESPERAR:
	IfWinNotExist, ahk_exe mpc-be64.exe
	{
		SendMessage, 0x111, 887,,, ahk_class MediaPlayerClassicW
		Goto, ESPERAR
	}
	Goto, COMPROBAR
}	
}


Funcion2(){
	Loop
	{
		WinGetTitle, VR, MPC`-HC`, D3D a pantalla completa
		WinGet, Variable_unico, ID, %VR% ahk_exe mpc-hc64.exe
		IfWinExist, ahk_id %Variable_unico%
		{
			WinSet, Bottom, , ahk_id %Variable_unico%
		}
	}	
}

desde ya agradecido.

Lepes
Posts: 141
Joined: 06 May 2021, 07:32
Location: Spain

Re: Unir 2 ejecutables en 1

Post by Lepes » 27 Sep 2022, 15:32

No sé muy bien en qué orden debe ejecutarse la función 2 con respecto a la función 1. Yo lo he hecho así, pero no tengo ninguno de los 3 programas y tampoco sé lo que pretendes hacer.
Tal cual lo he puesto, cuando exista la ventana ahk_exe mpc-be64.exe, entonces entraría a funcionar tu "funcion2".

Code: Select all

DetectHiddenWindows, on
SetTitleMatchMode, 2

Funcion1() 
return

Funcion1(){
	
Loop
	{
	COMPROBAR:
	IfWinExist, ahk_exe mpc-be64.exe
	{
		SendMessage, 0x111, 888,,, ahk_class MediaPlayerClassicW
		PostMessage , 0x112 , 0xF060 ,,, ahk_exe Dream Scroller.exe
		Goto, ESPERAR
	}
	Goto, COMPROBAR
	ESPERAR:
	IfWinNotExist, ahk_exe mpc-be64.exe
	{
		SendMessage, 0x111, 887,,, ahk_class MediaPlayerClassicW
		Goto, ESPERAR
	}
    WinGetTitle, VR, MPC`-HC`, D3D a pantalla completa   ;inicio funcion2
    WinGet, Variable_unico, ID, %VR% ahk_exe mpc-hc64.exe
    IfWinExist, ahk_id %Variable_unico%
    {
      WinSet, Bottom, , ahk_id %Variable_unico%
    }  ; fin funcion2
	Goto, COMPROBAR
}	
}

Si no es lo que quieres, es cuestión de subir o bajar todo el bloque desde "inicio funcion2" hasta "fin funcion2" para situarlo en el orden que tu necesitas.

Dsalomon
Posts: 22
Joined: 02 Mar 2021, 23:01

Re: Unir 2 ejecutables en 1

Post by Dsalomon » 27 Sep 2022, 18:11

Gracias por tu respuesta, la verdad es que la primera función verifica, lamentablemente el código que me corregiste no me aplica

La explicación rápida seria, cuando se inicia un proceso especifico de un reproductor de video y si lo detecta ejecuta una combinación SendKey
La segunda función mantiene un programa constantemente en Bottom, a ver si me explico:
Al iniciar ;
Ejecute Funcion1 () ;permanentemente (en un Loop constante, hace una verificación que debe permanecer )
Ejecute Funcion2 () ;permanentemente (en un Loop constante, hace una verificación que debe permanecer)

regularmente tengo cada función en un archivo de script independiente pero ya me llene de iconos Systray y quisiera unificar para solo tener corriendo un script, gracias.
Attachments
imagen_2022-09-27_170928596.png
imagen_2022-09-27_170928596.png (16.15 KiB) Viewed 663 times

Lepes
Posts: 141
Joined: 06 May 2021, 07:32
Location: Spain

Re: Unir 2 ejecutables en 1  Topic is solved

Post by Lepes » 27 Sep 2022, 20:50

En tu primer código, funcion1 es un bucle que no sale jamás de ahí, por tanto funcion2 nunca se va a ejecutar.
La idea es tener un solo bucle y que se ejecute indefinidamente y pasando por las 3 condiciones.

Prueba esto a ver si tienes más suerte:

Code: Select all

DetectHiddenWindows, on
SetTitleMatchMode, 2
	
Loop 
{
  IfWinExist, ahk_exe mpc-be64.exe
  {
    SendMessage, 0x111, 888,,, ahk_class MediaPlayerClassicW
    PostMessage , 0x112 , 0xF060 ,,, ahk_exe Dream Scroller.exe
  } else  {
    SendMessage, 0x111, 887,,, ahk_class MediaPlayerClassicW
  }
  WinGetTitle, VR, MPC`-HC`, D3D a pantalla completa
  WinGet, Variable_unico, ID, %VR% ahk_exe mpc-hc64.exe
  IfWinExist, ahk_id %Variable_unico%
  {
    WinSet, Bottom, , ahk_id %Variable_unico%
  }  
}	

kintar0e
Posts: 41
Joined: 05 Mar 2019, 07:32

Re: Unir 2 ejecutables en 1

Post by kintar0e » 27 Sep 2022, 21:27

Puede ser de esta manera:

Code: Select all

DetectHiddenWindows, on
SetTitleMatchMode, 2
#Persistent

SetTimer, COMPROBAR, 1000
SetTimer, ESPERAR, 800
SetTimer, windowBottom, 500
return

COMPROBAR:
	if WinExist("ahk_exe mpc-be64.exe")
	{
		SendMessage, 0x111, 888,,,ahk_class MediaPlayerClassicW
		PostMessage , 0x112 , 0xF060 ,,, ahk_exe Dream Scroller.exe
	}
return

ESPERAR:
	if not WinExist("ahk_exe mpc-be64.exe")
	{
		SendMessage, 0x111, 887,,, ahk_class MediaPlayerClassicW
	}
return

windowBottom:
	WinGetTitle, VR, MPC`-HC`, D3D a pantalla completa
	WinGet, Variable_unico, ID, %VR% ahk_exe mpc-hc64.exe
	IfWinExist, ahk_id %Variable_unico%
	{
		WinSet, Bottom, , ahk_id %Variable_unico%
	}
return

Dsalomon
Posts: 22
Joined: 02 Mar 2021, 23:01

Re: Unir 2 ejecutables en 1

Post by Dsalomon » 29 Sep 2022, 01:03

@Lepes
@kintar0e

Muchas gracias a ambos, interesante que los 2 funcionan uno muy resumido excelente.

Resuelto y aprendido.

Post Reply

Return to “Pedir Ayuda”