Stickies
« external notification when a stickie is received? »

Welcome Guest. Please Login or Register.
Dec 13th, 2017, 08:39am


Click to go to the
Zhorn Software Web Site
Click to go to the
Knowledgebase

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: external notification when a stickie is received?  (Read 95 times)
doubleu
New Member
Image


member is offline

Avatar




PM


Posts: 2
xx external notification when a stickie is received?
« Thread started on: Nov 16th, 2017, 11:15am »

Hello all. I'm curious if there is any way to have some sort of external notification (like an email, instant message, or text message) when a new stickie is received? For example, I'm frequently away from my desk, and it would be extremely helpful to know that I've received a stickie when i'm away. Whether it's via some 3rd party scripting or something, i'm just curious if anyone had any ideas.
User IP Logged

eef
Junior Member
ImageImage


member is offline

Avatar




PM


Posts: 40
xx Re: external notification when a stickie is receiv
« Reply #1 on: Nov 18th, 2017, 07:01am »

I looked into it because of the new "messenger" app Telegram that allows easy linking with its api.

It is easy to get a event notification/trigger using stickies api when a sticky comes through the network.

When you send a sticky to a "Friend" and it fails you have the option of sending it as email.Unfortunately using the netsend command this email option does not seem to be triggered.

It means you have to create the code for sending an email after the network sticky is detected.

This cannot be a problem but i had not yet time to look into it but i guess it would only be a few lines of code .

This is the code for detecting a new network sticky on PC.

Code:
#SingleInstance
setworkingdir %A_ScriptDir%
TargetScriptTitle = ZhornSoftwareStickiesMain
DetectHiddenWindows On
SetTitleMatchMode 2
WinGet, HA , ID, %A_ScriptName%


OnMessage(0x4a, "Receive_WM_COPYDATA")  
StringToSend=do register
IDc:=40
Send_(StringToSend,IDc)
return


send_notification:
StringToSend=do netsend %sid% address onlyemail ; Friend name with only valid email adress
IDc:=40
Send_(StringToSend,IDc)
MsgBox, 4,,notify sticky %sid%,4
return

esc::exitapp


Receive_WM_COPYDATA(wParam, lParam)
{
		Global datastring ,sid ,edit2 ,l
		ID                := NumGet(lParam + 0)
		len               := NumGet(lParam + A_PtrSize)
    StringAddress     := NumGet(lParam + 2*A_PtrSize)
  
    VarSetCapacity(CopyOfData, len,0)
    CopyOfData:= StrGet(StringAddress,len,"cp0")

ifinstring,CopyOfData,will send
msgbox ,4,, %copyofdata%,4

ifinstring,CopyOfData,network
{
sid:=regexreplace(CopyOfData,".*network (\w+)$","$1")
settimer,send_notification,-20
}

return true
}

Send_(StringToSend,IDc)
{
global TargetScriptTitle


    DetectHiddenWindows On
    SetTitleMatchMode 2 

    VarSetCapacity(CopyDataStruct, 3*A_PtrSize, 0)
     
    StringToSend=api %StringToSend%
    len := StrPutVar(StringToSend, StringToSend, "cp0")+1

    NumPut(IDc          , CopyDataStruct, 0) 
    NumPut(len , CopyDataStruct, 4)  
    NumPut(&StringToSend, CopyDataStruct, 8) 

    SendMessage, 0x4a, %A_ScriptHwnd%, &CopyDataStruct,, %TargetScriptTitle% 
    
  if (errorlevel="fail")
	{
  MsgBox SendMessage failed. Does the target application runs?
	
	} 
  
    return  
}

StrPutVar(string, ByRef var, encoding) 
{ 
    VarSetCapacity(var, StrPut(string, encoding) * ((encoding="UTF-16"||encoding="CP1200") ? 2 : 1)) 
    return StrPut(string, &var, encoding) 
}





 

« Last Edit: Nov 18th, 2017, 07:09am by eef » User IP Logged

eef
Junior Member
ImageImage


member is offline

Avatar




PM


Posts: 40
xx Re: external notification when a stickie is receiv
« Reply #2 on: Nov 18th, 2017, 08:52am »

Here is a basic version with email code included , you need to adapt the password and username of the gmail account if you want to try it. ( tested on win10 pro using ahk version 1.1.26.01)

The script is paused when started ( trayicon red) to unpause use hotkey ctrl+alt+p or use the traymenu option pause.

I am still looking for an easier interface that makes it much clearer when the script is active but for the moment i just test this for a few days.

Gmail gave a warning that a less secure app was using the account i had to agree to using it anyway :)

update after testing it:


  • Works with a "locked" PC.
  • Password is unencrypted and have no solution for that.Compile the script gives small protection.
  • Gmail account has to accept "less secure" applications.
  • I can send email through smtp server from service provider without password to gmail.That would be a solution for the previous two security points.
  • Can send sticky content too only tested for ascii.


Code:
#SingleInstance
setworkingdir %A_ScriptDir%
TargetScriptTitle = ZhornSoftwareStickiesMain
DetectHiddenWindows On
SetTitleMatchMode 2
WinGet, HA , ID, %A_ScriptName%

OnMessage(0x4a, "Receive_WM_COPYDATA")  
StringToSend=do register
IDc:=40
Send_(StringToSend,IDc)

pause
return


^!p::pause


send_notification:

StringToSend=get desktop %sid% title
IDc:=40
Send_(StringToSend,IDc)
title:=CopyOfData
SendGmail("sticky received " title,"mygmailname@gmail.com") ; set correct email adress
MsgBox, 4,,notify sticky %sid%,4
return

esc::exitapp


SendGmail(message,emailto){	
	pmsg := ComObjCreate("CDO.Message")
	pmsg.From := """stickies"" <myPCemail@gmail.com>"
	pmsg.To := emailto
	pmsg.Subject := "Notification"
	pmsg.TextBody := message
	
	fields := Object()
	fields.smtpserver := "smtp.gmail.com"
	fields.smtpserverport := 465
	fields.smtpusessl := True
	fields.sendusing := 2
	fields.smtpauthenticate := 1
	fields.sendusername := "myemail@gmail.com" ; set correct name
	fields.sendpassword := "mypassword"        ; set correct password
	fields.smtpconnectiontimeout := 60
	
	schema := "http://schemas.microsoft.com/cdo/configuration/"
	pfld := pmsg.Configuration.Fields
	For field,value in fields
		pfld.Item(schema . field) := value
	pfld.Update()
	pmsg.Send()
	pmg.Close
}


Receive_WM_COPYDATA(wParam, lParam)
{
		Global CopyOfData ,sid 
		ID                := NumGet(lParam + 0)
		len               := NumGet(lParam + A_PtrSize)
    StringAddress     := NumGet(lParam + 2*A_PtrSize)
  
    VarSetCapacity(CopyOfData, len,0)
    CopyOfData:= StrGet(StringAddress,len,"cp0")

ifinstring,CopyOfData,will send
msgbox ,4,, %copyofdata%,4

ifinstring,CopyOfData,network
{
sid:=regexreplace(CopyOfData,".*network (\w+)$","$1")
settimer,send_notification,-20
}

return true
}

Send_(StringToSend,IDc)
{
global TargetScriptTitle


    DetectHiddenWindows On
    SetTitleMatchMode 2 

    VarSetCapacity(CopyDataStruct, 3*A_PtrSize, 0)
     
    StringToSend=api %StringToSend%
    len := StrPutVar(StringToSend, StringToSend, "cp0")+1

    NumPut(IDc          , CopyDataStruct, 0) 
    NumPut(len , CopyDataStruct, 4)  
    NumPut(&StringToSend, CopyDataStruct, 8) 

    SendMessage, 0x4a, %A_ScriptHwnd%, &CopyDataStruct,, %TargetScriptTitle% 
    
  if (errorlevel="fail")
	{
  MsgBox SendMessage failed. Does the target application runs?
	
	} 
  
    return  
}

StrPutVar(string, ByRef var, encoding) 
{ 
    VarSetCapacity(var, StrPut(string, encoding) * ((encoding="UTF-16"||encoding="CP1200") ? 2 : 1)) 
    return StrPut(string, &var, encoding) 
}





 
« Last Edit: Nov 19th, 2017, 02:31am by eef » User IP Logged

doubleu
New Member
Image


member is offline

Avatar




PM


Posts: 2
xx Re: external notification when a stickie is receiv
« Reply #3 on: Nov 21st, 2017, 09:41am »

works like a charm! thank you so much, eef!
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

Donate $6.99 for 50,000 Ad-Free Pageviews!


This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls