stickies add_menu set as wallpaper only win10

Post your working scripts, libraries and tools for AHK v1.1 and older
User avatar
noname
Posts: 515
Joined: 19 Nov 2013, 09:15

stickies add_menu set as wallpaper only win10

13 Jan 2018, 05:31

Image

For software http://www.zhornsoftware.co.uk/stickies/ and only for win10 !

Adds a menu item to every TitleBar RightClick_menu to set the image as wallpaper , it needs to start after sticky.exe has started to request OnMessage support.

Code: Select all

#noenv
SetTitleMatchMode, slow
DetectHiddenWindows On
SetTitleMatchMode 2
setworkingdir:=a_scriptdir
OnExit, bye

TargetScriptTitle = ZhornSoftwareStickiesMain

OnMessage(0x4a, "Receive_WM_COPYDATA") 
send_("do register",20) 
if errorlevel
    {
    msgbox %errorlevel% in return code is stickies running?
    exit
    }
sleep 500
send_("do stickymenuadd setwall set wallpaper_center",20)
send_("do stickymenuadd setwallfill set wallpaper_fill",20)
return


setwall:
gosub check_image_sticky
gosub get_image_dir
gosub check_file
RegWrite, REG_SZ, HKEY_CURRENT_USER\Control Panel\Desktop, WallPaperStyle ,0
if errorlevel
{
MsgBox, error writing to registry
return
}
DllCall("SystemParametersInfo", uint, 0x0014, uint, 0x0000, str, sfile, uint, 0x0003)
return


setwallfill:

gosub check_image_sticky
gosub get_image_dir
gosub check_file
RegWrite, REG_SZ, HKEY_CURRENT_USER\Control Panel\Desktop, WallPaperStyle ,10
if errorlevel
MsgBox, error
DllCall("SystemParametersInfo", uint, 0x0014, uint, 0x0000, str, sfile, uint, 0x0003)
return

check_image_sticky:
sleep 200
ControlSend, ,+^s,ASticky
stringtosend=get desktop %sid% type
send_(stringtosend,10)
ifnotinstring,datastring,001 1 
  {
  msgbox not an image sticky !!
  exit
  } 
return

get_image_dir:
stringtosend=get datapath
send_(stringtosend,10)

path:=substr(DataString,5)

IfNotExist, %path%
    {
    msgbox error in finding imagepath %path%
    exitapp
    }
sfile=%path%images\%sid%.png 
  
return

check_file:
counter:=0
loop 20
{
counter++
IfExist, %sfile%
break
sleep 500
}
if (counter>18)
    {
    msgbox error in finding image %image_file%
    exit
    }
return

bye:
try
  {
  send_("do stickymenudel setwallfill" ,20)
  send_("do stickymenudel setwall" ,20)
  }
exitapp


Receive_WM_COPYDATA(wParam, lParam)
{
		Global datastring ,sid ,edit2
		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,setwall
    {
    if instr(CopyOfData,"setwallfill")
    {
    sid:=regexreplace(CopyOfData,".*setwallfill (\w+)$","$1")
    settimer,setwallfill,-20
    }
    else
    {
    sid:=regexreplace(CopyOfData,".*setwall (\w+)$","$1")
    settimer,setwall,-20
    }
    return true
    }
    
ifinstring,CopyOfData,will send
    SoundBeep 

if !(ID=10) 
return

datastring:= CopyOfData
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) 
}



Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: No registered users and 232 guests