//Declaro una funcion en Global External Functions
Public Function unsignedlong FindWindow (long classname, string windowname) LIBRARY "user32.dll" ALIAS FOR FindWindowW
//Declar una variable de Instancia o Global
OleObject i_wsh
//En el open de mi window
i_wsh = Create OleObject
li_i = i_wsh.ConnectToNewObject('WScript.Shell')
//En el boton de enviar a WhatsApp este es el codigo:
String ls_cmd, ls_path
Integer li_i
uInt hWnd
hWnd = FindWindow(0,"Whatsapp")
if hWnd <= 0 Then
MessageBox ("Aviso","Whatsapp NO está corriendo")
Return
end if
if Len(sle_telefono.text) = 0 then
MessageBox("Error","No hay teléfono registrado",StopSign!)
sle_telefono.setfocus()
Return
end if
ls_cmd = "Whatsapp://send?phone="+sle_telefono.text+"&text=Presente%20este%20codigo%20QR%20en%20Entrada"
li_i = i_wsh.Run(ls_cmd, 3, TRUE)
if li_i <> 0 then
MessageBox("Error","No se pudo enviar el mensaje",StopSign!)
Return
end if
//La variable gs_path contiene el path y nombre de la imagen que voy a enviar
ClipBoard(gs_path)
Sleep(0.3)
i_wsh.SendKeys('+{TAB}')
Sleep(0.3)
i_wsh.SendKeys('{ENTER}')
Sleep(0.5)
i_wsh.SendKeys('{DOWN}')
Sleep(0.3)
i_wsh.SendKeys('{ENTER}')
Sleep(0.5)
i_wsh.SendKeys('^{V}')
Sleep(0.3)
i_wsh.SendKeys('{ENTER}') //Para enviar
Sleep(0.5)
i_wsh.SendKeys('{ENTER}') //Para enviar
i_wsh.SendKeys('{ENTER}') //Para enviar