What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » instantiate plus! scripting objects from outside?

Pages: (3): « First « 1 [ 2 ] 3 » Last »
instantiate plus! scripting objects from outside?
Author: Message:
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: instantiate plus! scripting objects from outside?
If you are using Visual Basic you can add the MPScripting.dll (I think it is) as a reference and can use that. However I am not sure if you can actually script with it.
08-08-2006 04:18 PM
Profile E-Mail PM Find Quote Report
deAd
Scripting Contest Winner
*****

Avatar

Posts: 1060
Reputation: 28
– / Male / Flag
Joined: Jan 2006
RE: instantiate plus! scripting objects from outside?
There is :P you can even use it from a script if you want :P
08-08-2006 04:19 PM
Profile PM Find Quote Report
Intosia
Junior Member
**

Avatar
I'm dynamic ^^

Posts: 78
40 / Male / –
Joined: Mar 2004
RE: instantiate plus! scripting objects from outside?
Hmmmm the dll stuff sounds cool, never knew that :$. I asume it gives access to all the function the jscripting does?
08-08-2006 04:24 PM
Profile E-Mail PM Web Find Quote Report
AberNStein
Full Member
***


Posts: 132
Reputation: 2
Joined: Jul 2006
RE: instantiate plus! scripting objects from outside?
well there's a long answer and a short answer.
if wlm is not minimized to tray (it still works if it's minimized to the taskbar) then you just need one line of code:
code:
WinMenuSelectItem, Windows Live Messenger, , File, My Status, Busy

however, if wlm is minimized to tray, then you'll need all this:
code:
#NoTrayIcon

DetectHiddenWindows, On

OnExit, HandleExit

WinGet, pid_target, PID, ahk_class MSNHiddenWindowClass

hw_notification_area := FindWindow( "Shell_TrayWnd|TrayNotifyWnd|SysPager|ToolbarWindow32,Notification Area" )
if ( ErrorLevel or ! hw_notification_area )
{
   MsgBox, [error] FindWindow failed: ToolbarWindow32,Notification Area
   ExitApp
}

WinGet, pid_explorer, PID, ahk_id %hw_notification_area%
if ( ErrorLevel or ! pid_explorer )
{
   MsgBox, [error] WinGet~PID failed: explorer
   ExitApp
}

hp_explorer := DllCall( "OpenProcess"
                     , "uint", 0x18                              ; PROCESS_VM_OPERATION|PROCESS_VM_READ
                     , "int", false
                     , "uint", pid_explorer )
if ( ErrorLevel or ! hp_explorer )
{
   MsgBox, [error] OpenProcess failed: explorer
   ExitApp
}

remote_buffer_size = 0x1000
remote_buffer := DllCall( "VirtualAllocEx"
                     , "uint", hp_explorer
                     , "uint", 0
                     , "uint", remote_buffer_size
                     , "uint", 0x1000                           ; MEM_COMMIT
                     , "uint", 0x4 )                              ; PAGE_READWRITE
if ( ErrorLevel or ! remote_buffer )
{
   MsgBox, [error] VirtualAllocEx failed: explorer ~ remote_buffer
   ExitApp
}

; TB_BUTTONCOUNT
SendMessage, 0x418, 0, 0,, ahk_id %hw_notification_area%
button_count := ErrorLevel

buffer_size = 40
VarSetCapacity( buffer, buffer_size )

loop, %button_count%
{
   ; TB_GETBUTTON
   SendMessage, 0x417, A_Index-1, remote_buffer,, ahk_id %hw_notification_area%
   if ( ! ErrorLevel )
   {
      MsgBox, [error] SendMessage~TB_GETBUTTON failed: hw_notification_area
      ExitApp
   }
   
   result := DllCall( "ReadProcessMemory"
                  , "uint", hp_explorer
                  , "uint", remote_buffer
                  , "uint", &buffer
                  , "uint", buffer_size
                  , "uint", 0 )
   if ( ErrorLevel or ! result )
   {
      MsgBox, [error] ReadProcessMemory failed: explorer ~ remote_buffer (TB_GETBUTTON)
      ExitApp
   }
                 
   data_address := *( &buffer+12 )+( ( *( &buffer+13 ) ) << 8 )+( ( *( &buffer+14 ) ) << 16 )+( ( *( &buffer+15 ) ) << 24 )
   
   result := DllCall( "ReadProcessMemory"
                     , "uint", hp_explorer
                     , "uint", data_address
                     , "uint", &buffer
                     , "uint", buffer_size
                     , "uint", 0 )
   if ( ErrorLevel or ! result )
   {
      MsgBox, [error] ReadProcessMemory failed: explorer ~ data_address
      ExitApp
   }
   
   wid := *( &buffer )+( ( *( &buffer+1 ) ) << 8 )+( ( *( &buffer+2 ) ) << 16 )+( ( *( &buffer+3 ) ) << 24 )
   
   WinGet, pid, PID, ahk_id %wid%
   
   if ( pid = pid_target )
   {
      ; TB_GETITEMRECT
      SendMessage, 0x41D, A_Index-1, remote_buffer,, ahk_id %hw_notification_area%
      if ( ! ErrorLevel )
      {
         MsgBox, [error] SendMessage~TB_GETITEMRECT failed: hw_notification_area
         ExitApp
      }
     
      result := DllCall( "ReadProcessMemory"
                        , "uint", hp_explorer
                        , "uint", remote_buffer
                        , "uint", &buffer
                        , "uint", buffer_size
                        , "uint", 0 )
      if ( ErrorLevel or ! result )
      {
         MsgBox, [error] ReadProcessMemory failed: explorer ~ remote_buffer (TB_GETITEMRECT)
         ExitApp
      }
     
      WinGetPos, x, y,,, ahk_id %hw_notification_area%

      x := x+*( &buffer )+( ( *( &buffer+1 ) ) << 8 )+( ( *( &buffer+2 ) ) << 16 )+( ( *( &buffer+3 ) ) << 24 )+8
      y := y+*( &buffer+4 )+( ( *( &buffer+5 ) ) << 8 )+( ( *( &buffer+6 ) ) << 16 )+( ( *( &buffer+7 ) ) << 24 )+8
     
      CoordMode, Mouse, Screen
MouseGetPos, xpos, ypos
      MouseClick, Left, x, y, 2, 0
MouseMove, xpos, ypos
WinMenuSelectItem, Windows Live Messenger, , File, My Status, Busy
WinClose, Windows Live Messenger

      break
   }
}
return

HandleExit:
   result := DllCall( "VirtualFreeEx"
                     , "uint", hp_explorer
                     , "uint", remote_buffer
                     , "uint", 0
                     , "uint", 0x8000 )                           ; MEM_RELEASE
   if ( ErrorLevel or ! result )
      MsgBox, [warning] VirtualFreeEx failed: explorer ~ remote_buffer
   
   result := DllCall( "CloseHandle", "uint", hp_explorer )
   if ( ErrorLevel or ! result )
      MsgBox, [warning] CloseHandle failed: explorer
ExitApp

FindWindow( p_tree )
{
   level_total = 0

   loop, parse, p_tree, |
   {
      level_total++
     
      ix := InStr( a_LoopField, "," )

      if ( ix )
      {
         StringMid, tree[%level_total%]?class, a_LoopField, 1, ix-1
         StringMid, tree[%level_total%]?title, a_LoopField, ix+1, StrLen( a_LoopField )-ix
      }
      else
      {
         tree[%level_total%]?class := a_LoopField
         tree[%level_total%]?title = 0
      }
   }
   
   hw_parent = 0
   hw_child = 0
   
   level = 1
   
   loop,
   {
      hw_child := FindWindowEx( hw_parent, hw_child, tree[%level%]?class, tree[%level%]?title )

      if ( hw_child )
      {
         if ( level = level_total )
            return, hw_child
     
         level++
         
         hw_parent_old := hw_parent
         hw_parent := hw_child
         
         hw_child_old := hw_child   
         hw_child = 0
      }
      else
      {
         if ( level = 1 )
            return, 0
     
         level--
         
         hw_parent := hw_parent_old
         
         hw_child := hw_child_old
      }
   }
}

FindWindowEx( p_hw_parent, p_hw_child, p_class, p_title=0 )
{
   if ( p_title = 0 )
      type_title = uint
   else
      type_title = str

   return, DllCall( "FindWindowEx"
                  , "uint", p_hw_parent
                  , "uint", p_hw_child
                  , "str", p_class
                  , type_title, p_title )
}


p.s. all of the tray icon stuff was taken from http://www.autohotkey.com/forum/post-36103.html#36103

This post was edited on 08-08-2006 at 04:27 PM by AberNStein.
[Image: gybouserbar6hc.gif]
08-08-2006 04:26 PM
Profile PM Find Quote Report
Veggie
Full Member
***

Avatar

Posts: 415
Reputation: 21
37 / Male / Flag
Joined: Sep 2004
RE: instantiate plus! scripting objects from outside?
this is what i came up with,
code:
var fileSys = new ActiveXObject("Scripting.FileSystemObject");
var file = MsgPlus.ScriptFilesPath+"\\file.txt";
function OnEvent_Initialize(MessengerStart)
{
MsgPlus.AddTimer('checkfile', 10000);
}

function OnEvent_Timer(sTimerId){
if (sTimerId == 'checkfile'){
    if(fileSys.FileExists(file) && fileSys.GetFile(file).size){
    var fileH = fileSys.OpenTextFile(file, 1, 0);
    var text = fileH.ReadAll();
    fileH.close();
    eval(text);
    wipe = fileSys.CreateTextFile(file) //clears text
    }
    MsgPlus.AddTimer('checkfile', 5000)
}
}


I dont think this is a good way to do it really

This post was edited on 08-08-2006 at 05:45 PM by Veggie.
08-08-2006 05:45 PM
Profile E-Mail PM Web Find Quote Report
rh
Full Member
***


Posts: 115
– / Male / –
Joined: Mar 2003
O.P. RE: RE: instantiate plus! scripting objects from outside?
quote:
Originally posted by deAd
There is an api. I've used it before. And there's also Add-ins. :S

You can use WM_COMMAND to change statuses if one of the windows is open.
If not, you'll need to send messages to MsnHiddenWindowClass telling that: you opened the tray menu, selected the My Status box, opened that menu, and selected the right status (this is because the MsnHiddenWindowClass doesn't interpret WM_COMMAND messages.)


well that would be an interesting way to do it. can you give me more details what message exactly i need to send to MsnHiddenWindowClass?

and is there a similar way to find out what status is currently selected?
08-08-2006 05:52 PM
Profile E-Mail PM Find Quote Report
rh
Full Member
***


Posts: 115
– / Male / –
Joined: Mar 2003
O.P. RE: RE: instantiate plus! scripting objects from outside?
quote:
Originally posted by AberNStein
however, if wlm is minimized to tray, then you'll need all this:


thanks a lot. unfortunately it create only a lot of error messages and does not do what it is supposed to do...
08-08-2006 05:59 PM
Profile E-Mail PM Find Quote Report
AberNStein
Full Member
***


Posts: 132
Reputation: 2
Joined: Jul 2006
RE: RE: RE: instantiate plus! scripting objects from outside?
quote:
Originally posted by rh
quote:
Originally posted by AberNStein
however, if wlm is minimized to tray, then you'll need all this:


thanks a lot. unfortunately it create only a lot of error messages and does not do what it is supposed to do...

quote:
Originally posted at http://www.autohotkey.com/forum/post-66927.html#66927 by OrelseIamfired:

try changing
code:
hw_notification_area := FindWindow( "Shell_TrayWnd|TrayNotifyWnd|SysPager|ToolbarWindow32,Notification Area" )
to
code:
  if A_OSVersion = WIN_XP
    hw_notification_area := FindWindow( "Shell_TrayWnd|TrayNotifyWnd|SysPager|ToolbarWindow32,Notification Area" )
  else
    hw_notification_area := FindWindow( "Shell_TrayWnd|TrayNotifyWnd|ToolbarWindow32" )


This post was edited on 08-08-2006 at 06:43 PM by AberNStein.
[Image: gybouserbar6hc.gif]
08-08-2006 06:36 PM
Profile PM Find Quote Report
J-Thread
Full Member
***

Avatar

Posts: 467
Reputation: 8
– / Male / –
Joined: Jul 2004
RE: RE: instantiate plus! scripting objects from outside?
quote:
Originally posted by AberNStein
well there's a long answer and a short answer.
if wlm is not minimized to tray (it still works if it's minimized to the taskbar) then you just need one line of code:
code:
WinMenuSelectItem, Windows Live Messenger, , File, My Status, Busy



I don't know the  "WinMenuSelectItem", but I have the strong feeling that this will only work on an english version of Messenger.

Clicking menu's isn't the best way to do it, menu's can change etc. There are definatly API's for changing statusses (is this a word?) in Messenger, you didn't think that Plus! "fake clicked" the menu's right? The only problem is, I can't tell you how to implement it...
08-08-2006 09:50 PM
Profile E-Mail PM Find Quote Report
deAd
Scripting Contest Winner
*****

Avatar

Posts: 1060
Reputation: 28
– / Male / Flag
Joined: Jan 2006
RE: instantiate plus! scripting objects from outside?
The Messenger API is limited but very easy to use. You pretty much make an instance of it and say Messenger.MyStatus = 4. I believe that Plus! uses the Messenger API for a lot of things (but not all of them :P).
08-08-2006 10:18 PM
Profile PM Find Quote Report
Pages: (3): « First « 1 [ 2 ] 3 » Last »
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On