Go Back   PCMech Forums > Help & Discussion > Web Design / Development

Need Some Help? Type Your Keywords Here:

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Old 10-02-2004, 04:33 AM   #1
Member (10 bit)
 
Designer's Avatar
 
Join Date: Mar 2004
Location: Essex, UK
Posts: 982
Send a message via AIM to Designer Send a message via MSN to Designer
Need some help with a Visual Basic problem

Hi there, I'm trying to get around a problem with a bit of software called Sweetlight where it controls something through an external smartbox. The problem is that I have to click a few buttons in the program and i'm looking at a way to automate this (like on a timer), and i've found out that I can assign the buttons to keystrokes in their configuration software, so while the program is open pressing the key 'A' on the keyboard would trigger sequence A in their program, 'B' for B etc.

Recently, this was posted on their forum (www.sweetlight-controller.com) and it's in C, so i'm not famailiar at all with it
Quote:
It is possible to run MACROs of USER screen with Windows messages. The following example explain how to run the first MACRO button of USER screen (written in c++ language).

Code:
#define      MACRO1_ON   101
#define      MACRO2_ON   MACRO1_ON + 1
...
#define      MACRO35_ON   MACRO34_ON + 1
CWnd*      Window;
COPYDATASTRUCT   cds;
Window = FindWindow(NULL, "user screen");
if(Window) {
  cds.dwData = MACRO1_ON;
  cds.lpData = "ext prog";
  cds.cbData = strlen("ext prog");
  Window->sendMessage(WM_COPYDATA, (WPARAM)NULL, (LPARAM)&cds);
}
Apparently this will give triggers from an external program (or so i'm told). Does anyone know a way of doing this in Visual Basic. Someone on their forum sent me this but it doesnt appear to work

Code:
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Type COPYDATASTRUCT
        dwData As Long
        cbData As Long
        lpData As Long
End Type
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const WM_COPYDATA = &H4A


    Const MACRO1_ON = 101
    Const MACRO2_ON = MACRO1_ON + 1
    ...
    Const MACRO35_ON = MACRO34_ON + 1
   
    Dim Window As Long
    Dim cds As COPYDATASTRUCT
    Dim message_out As String

    Window = FindWindow(vbNullString, "user screen")
    If Window <> vbNull Then
        cds.dwData = MACRO1_ON
        message_out = StrConv("ext prog", vbFromUnicode)
        cds.lpData = StrPtr(message_out)
        cds.cbData = LenB(message_out) + 1
        SendMessage Window, WM_COPYDATA, vbNull, cds
    End If
This is really bugging me now, so any help with this problem would be greatly appreciated.

Thanks
__________________
Intel Core i7 920 2.66GHz | Asus P6T SE| 6GB Corsair ram | XFX Radeon HD 4780 | 2 x 250 Gb Maxtor SATA II (in RAID 0), 1 x 250GB SATA II | Creative XFI soundcard | Coolermaster 650W PSU | ThermalTake Tsunami case

My new website -Carp Fishing Forums
Designer is offline   Reply With Quote
Old 11-21-2004, 04:56 AM   #2
Member (10 bit)
 
Designer's Avatar
 
Join Date: Mar 2004
Location: Essex, UK
Posts: 982
Send a message via AIM to Designer Send a message via MSN to Designer
Oh well I finally found the answer to this by myself, just thought i'd post it so everyone else knows.

Code:
AppActivate ("user screen")
SendKeys ("a"), wait
Alright, I know strictly this isnt the proper answer to the problem but it works, instead of doing what its supposed to it just sends a keystroke to the USER SCREEN program which effectively gives the same end result.


Quite straightforward in the end, lol it's just taken me about 8 months to do it though

Last edited by Designer; 11-21-2004 at 04:58 AM.
Designer is offline   Reply With Quote
Reply

Bookmarks

Still Need Help? Type Your Keywords Here:


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 06:54 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 PL2