Thanks for all the help before. They are all working perfectly. I can now draw text on the images inside clipboard, and i can do the Hotkey as well as capture any screen i want. Shall i publish my code somewhere?
Anyway, to my question today. I was given the following C code which i need to translate to PB. Basically i need to be able to call the procedere, TB_execute(hWndOfTB, FALSE, "send paste"), inside PB. This procedere will enable me to send a command to an external programme (TB) which in turn will execute the send paste command.
Here is the C code:
Code: Select all
//
// CECIL.C
//
#include <windows.h>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
// needed because WM_COPYDATA isn't defined in the 16-bit Windows API Headers
//
#if !defined(WM_COPYDATA) && !defined(WIN32)
#define WM_COPYDATA 0x4a // as for WIN32
typedef struct tagCOPYDATASTRUCT
{
DWORD dwData; // a place to put just 32 bits of data
DWORD cbData; // size in bytes of data pointed to by PVOID
LPVOID lpData; // other data to be passed to the reciving app
} COPYDATASTRUCT, FAR * LPCOPYDATASTRUCT;
#endif
#if !defined(LPCOPYDATASTRUCT) && defined(WIN32)
typedef struct tagCOPYDATASTRUCT FAR * LPCOPYDATASTRUCT;
#endif
// This "ID" is used to implement an equivalent to TBM_EXECUTE that operates
// across 32-bit processes
//
// "lpData" is an LPCOPYDATA_EXECUTE
//
#define COPYDATA_EXECUTE (0x00000003)
typedef struct COPYDATA_EXECUTEtag
{
long bSysSuspendOff; // TRUE == sysSuspend is set to false
// during command execution
char szStatements[1]; // A zero-terminated ASCII string containing
// the OpenScript statements to be executed.
} COPYDATA_EXECUTEDATA, FAR * LPCOPYDATA_EXECUTEDATA;
// Cecil - this function will execute a string from Pure Basic
// eg. TB_execute(hWndOfTB, FALSE, "send paste")
BOOL TB_execute( HWND hWnd, BOOL bSysSuspendOff, LPCSTR lpStatements )
{
BOOL bResult;
LPCOPYDATA_EXECUTEDATA lpExec;
COPYDATASTRUCT Data;
HANDLE hStr;
Data.dwData = COPYDATA_EXECUTE;
Data.cbData = sizeof(*lpExec) + lstrlen(lpStatements) + 1;
hStr = GlobalAlloc(GMEM_ZEROINIT|GMEM_MOVEABLE, (DWORD)(Data.cbData));
if (hStr != NULL) {
lpExec = (LPCOPYDATA_EXECUTEDATA)GlobalLock(hStr);
if ( lpExec != NULL )
{
Data.lpData = lpExec;
lpExec->bSysSuspendOff = bSysSuspendOff;
lstrcpy(lpExec->szStatements, lpStatements );
bResult = ( SendMessage( hWnd, WM_COPYDATA,
NULL, (LPARAM)(LPVOID)&Data ) != 0 );
GlobalUnlock(hStr);
} else {
bResult = FALSE;
}
GlobalFree(hStr);
} else {
bResult = FALSE;
}
return bResult;
}Thanks in advance.
Cecil


