Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
PowerHome General
 PowerHome Messageboard : PowerHome General
Subject Topic: VB Script & ph. functions Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
SteveA
Groupie
Groupie


Joined: November 28 2002
Location: United States
Online Status: Offline
Posts: 49
Posted: December 19 2002 at 18:50 | IP Logged Quote SteveA

Hi all,

Been trying to send a macro call from a VB script to PH. Tried CreateObject(), GetObject() ect, ect.... Went thru all the PH documentation and also VB's. Still clueless. There a chance someone has an example. I'm trying to call a macro in PH named "SENDSTATUS". Appreciate any pointers.

Thanks... SteveA



__________________
SteveA
Back to Top View SteveA's Profile Search for other posts by SteveA Visit SteveA's Homepage
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: December 23 2002 at 13:53 | IP Logged Quote dhoward

Steve,

Well after a bit of research, it's not quite that easy to call a macro from straight VB script.  I had thought that you could declare external API functions and use the SendMessage routines but VBScript does not have that provision.  So...what I did was create a simple VB application that takes 3 command line arguments and then execute this VB application from within a VBScript.  The application then sends a Windows message to PowerHome and triggers whatever macro I would like.  Im assuming that you are trying to execute VBScript outside of the PowerHome environment.  If you are executing VBScript from within the PowerHome environment then you would just use the ph.macro function.

Anyways, here is a link to the VB PowerHome message program.  It takes three command line parameters and uses the PowerHome WM_USER Windows Message interface.  This interface in PowerHome allows you to declare a trigger on WM_USER messages (1024) through WM_USER + 4 messages (1028).  Using the WM_USER messages, you can pass whatever lparam and wparam values you like and then use those values within the PowerHome trigger however you like.  The first parameter is the WM_USER message number (1 through 5 equating to 1024 through 1028).  The second parameter is the wparam and is a long value.  The third parameter is the lparam value and is also a long value.  Separate the parameters with a space.  You can download the program here: /otherdown/winmsg.exe

If you are interested in the code, its posted below:

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wparam As Long, ByVal lparam As Long) As Long

Private Sub Form_Load()
    Dim msg, wparam, lparam, pos1, pos2
   
    pos1 = InStr(1, Command, " ")
    msg = Mid(Command, 1, pos1 - 1)
   
    pos2 = InStr(pos1 + 1, Command, " ")
    wparam = Mid(Command, pos1 + 1, pos2 - pos1 - 1)
   
    lparam = Mid(Command, pos2 + 1)
   
    SendMessage FindWindow(vbNullString, " PowerHome  "), msg + 1023, wparam, lparam
   
    End
End Sub

To execute this program from within VBScript, just make the calls below:

dim Wshshell

set WshShell = CreateObject("WScript.Shell")

WshShell.Run ("winmsg.exe 1 100 200")

In the above code, I want to trigger within PowerHome on "Trigger 1" of the WM_USER trigger.  Im passing in 100 as the wparam and 200 as the lparam.  These values will be available within the PowerHome trigger in system variables [TEMP3] and [TEMP4] respectively.  I can use these values to determine what action I would like the trigger to take.

Let me know if this helps or not.

Dave.

 

 

Back to Top View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 
SteveA
Groupie
Groupie


Joined: November 28 2002
Location: United States
Online Status: Offline
Posts: 49
Posted: December 26 2002 at 15:21 | IP Logged Quote SteveA

Thanks Dave....

I'll give it a shot and let you know!

 

SteveA

Back to Top View SteveA's Profile Search for other posts by SteveA Visit SteveA's Homepage
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum