Brandon
03-30-2011, 12:03 PM
LAST UPDATED: APRIL 4TH 2011.
Changes:
Added Hotkeys.
Added Query. (Allows User to enter script name)
Added MultiThreading. (Detects if S.M.A.R.T. + Script Window is open without interupting the program)
Fix Memory/CPU issues when running with S.M.A.R.T. (This was a Repeat Until Loop that raised CPU from 0 to 50... Now CPU is always 0 or 1.. Uses less resources)
Optimized Code(Fix Code a lot! Rewrote the whole thing, Less threads, Proper Hotkey Detection, Removed all Deprecated Headers, Better Error Handling)
Fixed Typo's In MessageBoxes (For Better Error Handling and Debugging for the User)
Added The Ability To Choose HotKeys. (User Defined HotKeys)
Added Help Menu For HotKey Codes, Etc.
Fixed Button Display Bug. (In The New version, It WASN'T being Painted Properly)
Credits:
Sm0k3. For Creating SmartChat Extension (Gave me motivation to create this).
Description:
What this does is add or remove a button to SMART and when clicked, sends the F12 Key to the simba client whether or not its in the system tray.
It was made to work with Sm0k3's SmartChat.sex (Link (http://villavu.com/forum/showthread.php?t=63432)).
It can be modified to do whatever basically. TO add the button, u run it, to remove the button u added, u kill the program.
Everything below is all C++ Code & Pictures. Program Is Below the Source Code.. Last Few Lines of this Post.
Form1.h
#define REPEAT do{
#define UNTIL( condition ) }while(!(condition));
#pragma once
#pragma comment(lib, "advapi32.lib")
#pragma comment(lib, "user32.lib")
#include <windows.h>
#include <tlhelp32.h>
#include <iostream>
#include <sstream>
#include <cstdlib>
#include "Query.h"
using namespace std;
namespace SmartChat {
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
using namespace System::Security::Permissions;
using namespace System::Runtime::InteropServices;
using namespace System::Threading;
/// <summary>
/// Summary for Form1
///
/// WARNING: If you change the name of this class, you will need to change the
/// 'Resource File Name' property for the managed resource compiler tool
/// associated with all .resx files this class depends on. Otherwise,
/// the designers will not be able to interact properly with localized
/// resources associated with this form.
/// </summary>
string SimbaName;
public ref class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
//
//TODO: Add the constructor code here
//
}
public:
System::String^ SysStr;
System::String^ HotKey1;
System::String^ HotKey2;
protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~Form1()
{
if (components)
{
delete components;
}
}
private: System::ComponentModel::BackgroundWorker^ Worker;
private: System::Windows::Forms::Button^ button1;
protected:
private:
/// <summary>
/// Required designer variable.
/// </summary>
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent(void)
{
System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(F orm1::typeid));
this->Worker = (gcnew System::ComponentModel::BackgroundWorker());
this->button1 = (gcnew System::Windows::Forms::Button());
this->SuspendLayout();
//
// Worker
//
this->Worker->DoWork += gcnew System::ComponentModel::DoWorkEventHandler(this, &Form1::Worker_DoWork);
//
// button1
//
this->button1->BackColor = System::Drawing::Color::Tan;
this->button1->BackgroundImage = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"button1.BackgroundImage")));
this->button1->BackgroundImageLayout = System::Windows::Forms::ImageLayout::Stretch;
this->button1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 7, System::Drawing::FontStyle::Italic, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->button1->ForeColor = System::Drawing::Color::Gold;
this->button1->Location = System::Drawing::Point(0, 0);
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(27, 33);
this->button1->TabIndex = 0;
this->button1->Text = L"Sc";
this->button1->UseVisualStyleBackColor = true;
this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
//
// Form1
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(27, 33);
this->Controls->Add(this->button1);
this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::FixedTool Window;
this->MaximizeBox = false;
this->MinimizeBox = false;
this->Name = L"Form1";
this->ShowInTaskbar = false;
this->Text = L"SChat";
this->WindowState = System::Windows::Forms::FormWindowState::Minimized ;
this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
this->ResumeLayout(false);
}
#pragma endregion
DWORD CountProcesses(CHAR *pProcessName)
{
DWORD dwCount = 0;
HANDLE hSnap = NULL;
PROCESSENTRY32 proc32;
if((hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0)) == INVALID_HANDLE_VALUE)
return -1;
proc32.dwSize=sizeof(PROCESSENTRY32);
while((Process32Next(hSnap, &proc32)) == TRUE)
if(_stricmp(proc32.szExeFile,pProcessName) == 0)
++dwCount;
CloseHandle(hSnap);
return dwCount;
}
void MarshalString (String ^ s, string& os) {
const char* chars = (const char*)(Marshal::StringToHGlobalAnsi(s)).ToPointer( );
os = chars;
Marshal::FreeHGlobal(IntPtr((void*)chars));
}
private: System::Void Worker_DoWork(System::Object^ sender, System::ComponentModel::DoWorkEventArgs^ e) {
enum {F9_KEYID = 1, F10_KEYID = 2};
HWND Simba = FindWindow(NULL, SimbaName.c_str());
if(RegisterHotKey(0, F9_KEYID, 0x4000, UInt32::Parse(HotKey1, System::Globalization::NumberStyles::HexNumber))) //F9 = 0x78
{
MessageBox::Show("SmartChat -- Registered HotKey: 0x" + HotKey1);
}
else
{
MessageBox::Show("Another Program Currently has the F9 Key in use -- Terminating SmartChat.");
exit(0);
}
if(RegisterHotKey(0, F10_KEYID, 0x4000, UInt32::Parse(HotKey2, System::Globalization::NumberStyles::HexNumber))) //F10 = 0x79
{
MessageBox::Show("SmartChat -- Registered HotKey: 0x" + HotKey2 + " To Exit");
}
else
{
MessageBox::Show("Another Program Currently has the F10 Key in use -- Terminating SmartChat.");
}
MSG msg;
char cProcess[20] = "Simba.exe";
DWORD dwReturn;
dwReturn = CountProcesses(cProcess);
REPEAT
while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
{
switch(msg.message)
{
case WM_HOTKEY:
if(msg.wParam == F9_KEYID)
{
::SendMessage(Simba, WM_KEYDOWN, VK_F12,0);
}
else if(msg.wParam == F10_KEYID)
{
MessageBox::Show("0x" + HotKey2 + " HotKey Pressed -- Exiting SmartChat.");
exit(0);
}
break;
}
break;
}
if(dwReturn != -1)
{
if((dwReturn < 1))
{
MessageBox::Show("Simba Isn't Running -- Terminating SmartChat.");
dwReturn = CountProcesses(cProcess);
exit(0);
}
HWND Smart = FindWindow("SunAwtFrame", "Public SMARTv6.6 - SMART Minimizing Autoing Resource Thing - By BenLand100");
if(Smart == NULL)
{
MessageBox::Show("S.M.A.R.T. isn't running -- Terminating SmartChat.");
exit(0);
}
dwReturn = CountProcesses(cProcess);
}
Sleep(1000);
Thread::Sleep(0);
UNTIL(false);
}
private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) {
Form1::Visible = false;
Query ^ Form2 = gcnew Query();
Form2->ShowDialog();
HotKey1 = Form2->textBox2->Text;
HotKey2 = Form2->textBox3->Text;
System::String^ ScrName = Form2->textBox1->Text;
System::String^ SmbName = "Simba - " + ScrName;
SysStr = SmbName;
IntPtr SimbaPtr = System::Runtime::InteropServices::Marshal::StringT oHGlobalAnsi(SysStr);
MarshalString(SysStr, SimbaName);
System::Runtime::InteropServices::Marshal::FreeHGl obal(SimbaPtr);
if(SimbaName == "")
{
MessageBox::Show("Query: ScriptName Field Was Left Blank -- Terminating SmartChat.");
exit(0);
}
HWND Simba = FindWindow(0, SimbaName.c_str());
HWND Smart = FindWindowW(L"SunAwtFrame", L"Public SMARTv6.6 - SMART Minimizing Autoing Resource Thing - By BenLand100");
if(Simba == NULL)
{
MessageBox::Show("SimbaScript Not Found -- Terminating SmartChat.");
exit(0);
}
if(Smart == NULL)
{
MessageBox::Show("S.M.A.R.T. Is Not Running -- Terminating Smartchat.");
exit(0);
}
ShowWindow((HWND)Form1::Handle.ToPointer(), SW_HIDE);
SetParent((HWND)button1->Handle.ToPointer(), Smart);
button1->Location = Point(528, 469);
Worker->RunWorkerAsync();
}
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
HWND Simba = FindWindow(NULL, SimbaName.c_str());
if(Simba == NULL)
{
MessageBox::Show("Cannot Find Simba -- Terminating SmartChat.");
exit(0);
}
::SendMessage(Simba, WM_KEYDOWN, VK_F12,0);
}
};
}
Query A.k.a. Form2
#define REPEAT do{
#define UNTIL( condition ) }while(!(condition));
#include <Windows.h>
#include <tchar.h>
#include <iostream>
using namespace std;
#pragma once
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
using namespace System::Threading;
namespace SmartChat {
/// <summary>
/// Summary for Query
///
/// WARNING: If you change the name of this class, you will need to change the
/// 'Resource File Name' property for the managed resource compiler tool
/// associated with all .resx files this class depends on. Otherwise,
/// the designers will not be able to interact properly with localized
/// resources associated with this form.
/// </summary>
public ref class Query : public System::Windows::Forms::Form
{
private:
public:
Query(void)
{
InitializeComponent();
//
//TODO: Add the constructor code here
//
}
protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~Query()
{
if (components)
{
delete components;
}
}
public: System::Windows::Forms::TextBox^ textBox1;
protected:
private: System::Windows::Forms::Label^ label1;
private: System::Windows::Forms::Button^ button1;
private: System::Windows::Forms::Label^ label2;
public: System::Windows::Forms::TextBox^ textBox2;
private:
private: System::Windows::Forms::Label^ label3;
public: System::Windows::Forms::TextBox^ textBox3;
private:
private: System::Windows::Forms::Button^ button2;
private: System::Windows::Forms::RichTextBox^ richTextBox1;
private:
/// <summary>
/// Required designer variable.
/// </summary>
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent(void)
{
System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(Q uery::typeid));
this->textBox1 = (gcnew System::Windows::Forms::TextBox());
this->label1 = (gcnew System::Windows::Forms::Label());
this->button1 = (gcnew System::Windows::Forms::Button());
this->label2 = (gcnew System::Windows::Forms::Label());
this->textBox2 = (gcnew System::Windows::Forms::TextBox());
this->label3 = (gcnew System::Windows::Forms::Label());
this->textBox3 = (gcnew System::Windows::Forms::TextBox());
this->button2 = (gcnew System::Windows::Forms::Button());
this->richTextBox1 = (gcnew System::Windows::Forms::RichTextBox());
this->SuspendLayout();
//
// textBox1
//
this->textBox1->Location = System::Drawing::Point(12, 25);
this->textBox1->Name = L"textBox1";
this->textBox1->Size = System::Drawing::Size(71, 20);
this->textBox1->TabIndex = 0;
this->textBox1->TextChanged += gcnew System::EventHandler(this, &Query::textBox1_TextChanged);
this->textBox1->KeyPress += gcnew System::Windows::Forms::KeyPressEventHandler(this, &Query::textBox1_KeyPress);
//
// label1
//
this->label1->AutoSize = true;
this->label1->Location = System::Drawing::Point(9, 9);
this->label1->Name = L"label1";
this->label1->Size = System::Drawing::Size(65, 13);
this->label1->TabIndex = 1;
this->label1->Text = L"ScriptName:";
//
// button1
//
this->button1->Location = System::Drawing::Point(128, 25);
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(47, 24);
this->button1->TabIndex = 2;
this->button1->Text = L"Submit";
this->button1->UseVisualStyleBackColor = true;
this->button1->Click += gcnew System::EventHandler(this, &Query::button1_Click);
//
// label2
//
this->label2->AutoSize = true;
this->label2->Location = System::Drawing::Point(13, 92);
this->label2->Name = L"label2";
this->label2->Size = System::Drawing::Size(81, 13);
this->label2->TabIndex = 3;
this->label2->Text = L"HotKey To Exit:";
//
// textBox2
//
this->textBox2->Location = System::Drawing::Point(16, 69);
this->textBox2->Name = L"textBox2";
this->textBox2->Size = System::Drawing::Size(67, 20);
this->textBox2->TabIndex = 4;
this->textBox2->TextChanged += gcnew System::EventHandler(this, &Query::textBox2_TextChanged);
this->textBox2->KeyPress += gcnew System::Windows::Forms::KeyPressEventHandler(this, &Query::textBox2_KeyPress);
//
// label3
//
this->label3->AutoSize = true;
this->label3->Location = System::Drawing::Point(13, 53);
this->label3->Name = L"label3";
this->label3->Size = System::Drawing::Size(91, 13);
this->label3->TabIndex = 5;
this->label3->Text = L"HotKey For Msgs:";
//
// textBox3
//
this->textBox3->Location = System::Drawing::Point(16, 110);
this->textBox3->Name = L"textBox3";
this->textBox3->Size = System::Drawing::Size(67, 20);
this->textBox3->TabIndex = 6;
this->textBox3->TextChanged += gcnew System::EventHandler(this, &Query::textBox3_TextChanged);
this->textBox3->KeyPress += gcnew System::Windows::Forms::KeyPressEventHandler(this, &Query::textBox3_KeyPress);
//
// button2
//
this->button2->Location = System::Drawing::Point(128, 80);
this->button2->Name = L"button2";
this->button2->Size = System::Drawing::Size(38, 30);
this->button2->TabIndex = 7;
this->button2->Text = L"Help";
this->button2->UseVisualStyleBackColor = true;
this->button2->Click += gcnew System::EventHandler(this, &Query::button2_Click);
//
// richTextBox1
//
this->richTextBox1->BackColor = System::Drawing::Color::Gainsboro;
this->richTextBox1->Font = (gcnew System::Drawing::Font(L"Arial", 7.5F, System::Drawing::FontStyle::Italic, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->richTextBox1->ForeColor = System::Drawing::Color::Blue;
this->richTextBox1->Location = System::Drawing::Point(-2, -1);
this->richTextBox1->Name = L"richTextBox1";
this->richTextBox1->ReadOnly = true;
this->richTextBox1->Size = System::Drawing::Size(229, 144);
this->richTextBox1->TabIndex = 8;
this->richTextBox1->Text = resources->GetString(L"richTextBox1.Text");
this->richTextBox1->Visible = false;
this->richTextBox1->Click += gcnew System::EventHandler(this, &Query::richTextBox1_Click);
//
// Query
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(226, 142);
this->Controls->Add(this->richTextBox1);
this->Controls->Add(this->button2);
this->Controls->Add(this->textBox3);
this->Controls->Add(this->label3);
this->Controls->Add(this->textBox2);
this->Controls->Add(this->label2);
this->Controls->Add(this->button1);
this->Controls->Add(this->label1);
this->Controls->Add(this->textBox1);
this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::FixedTool Window;
this->MaximizeBox = false;
this->MinimizeBox = false;
this->Name = L"Query";
this->ShowIcon = false;
this->Text = L"Query";
this->Deactivate += gcnew System::EventHandler(this, &Query::Query_Deactivate);
this->Load += gcnew System::EventHandler(this, &Query::Query_Load);
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
private: System::Void textBox1_TextChanged(System::Object^ sender, System::EventArgs^ e) {
}
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
String^ Script = textBox1->Text;
String^ HotKey1 = textBox2->Text;
String^ HotKey2 = textBox3->Text;
if((Script == "")||(HotKey1 == "")||(HotKey2 == ""))
{
MessageBox::Show("You Have Left A HotKey Field Blank or ScriptName Blank");
}
Query::Close();
}
private: System::Void Query_Load(System::Object^ sender, System::EventArgs^ e) {
IntPtr Qptr = Query::Handle;
HWND hQuery = (HWND)Qptr.ToPointer();
ShowWindow(hQuery, SW_SHOW);
SetWindowPos(hQuery, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE);
Query::Activate();
}
private: System::Void textBox1_KeyPress(System::Object^ sender, System::Windows::Forms::KeyPressEventArgs^ e) {
String^ Script = textBox1->Text;
String^ HotKey1 = textBox2->Text;
String^ HotKey2 = textBox3->Text;
if(e->KeyChar == 0x0D)
{
if((HotKey1 == "")||(HotKey2 == ""))
{
MessageBox::Show("You Have Left A HotKey Field Blank");
}
Query::Close();
}
}
private: System::Void Query_Deactivate(System::Object^ sender, System::EventArgs^ e) {
IntPtr Qptr = Query::Handle;
HWND hQuery = (HWND)Qptr.ToPointer();
ShowWindow(hQuery, SW_SHOW);
SetWindowPos(hQuery, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE);
IntPtr tBoxptr = textBox1->Handle;
HWND hTBoxptr = (HWND)tBoxptr.ToPointer();
RECT rcClient;
GetClientRect(hQuery, &rcClient);
POINT ptClientUL; // client upper left corner
POINT ptClientLR; // client lower right corner
POINT ptClientUR; // client upper right corner
POINT ptClientLL; // client lower left corner
ptClientUR.x = rcClient.right;
ptClientUR.y = rcClient.top;
ptClientLL.x = rcClient.left - 1;
ptClientLL.y = rcClient.bottom - 1;
ptClientUL.x = rcClient.left;
ptClientUL.y = rcClient.top;
ptClientLR.x = rcClient.right + 1;
ptClientLR.y = rcClient.bottom + 1;
ClientToScreen(hQuery, &ptClientUL);
ClientToScreen(hQuery, &ptClientLR);
ClientToScreen(hQuery, &ptClientUR);
ClientToScreen(hQuery, &ptClientLL);
//Clips the cursor to the specified client window..
SetRect(&rcClient, ptClientUL.x, ptClientUL.y,
ptClientLR.x, ptClientLR.y);
ClipCursor(&rcClient);
SetCursorPos(ptClientUR.x - 119 , ptClientUR.y + 38);
POINT cursorPos;
GetCursorPos(&cursorPos);
int h = (int) cursorPos.x;
int k = (int) cursorPos.y;
Sleep(500);
mouse_event(MOUSEEVENTF_LEFTDOWN, h, k, 0, 0);
mouse_event(MOUSEEVENTF_LEFTUP, h, k, 0, 0);
ClipCursor(NULL);
Sleep(500);
}
private: System::Void richTextBox1_Click(System::Object^ sender, System::EventArgs^ e) {
richTextBox1->Visible = false;
}
private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {
richTextBox1->Visible = true;
}
private: System::Void textBox2_TextChanged(System::Object^ sender, System::EventArgs^ e) {
}
private: System::Void textBox3_TextChanged(System::Object^ sender, System::EventArgs^ e) {
}
private: System::Void textBox2_KeyPress(System::Object^ sender, System::Windows::Forms::KeyPressEventArgs^ e) {
String^ Script = textBox1->Text;
String^ HotKey1 = textBox2->Text;
String^ HotKey2 = textBox3->Text;
if(!Char::IsDigit(e->KeyChar) && (e->KeyChar != 0x08) && (e->KeyChar != 0x0D))
{
e->Handled = true;
MessageBox::Show("Enter The Corresponding Key Number Only -- See Help For Details.");
}
else if(e->KeyChar == 0x0D)
{
if((Script == "")||(HotKey2 == ""))
{
MessageBox::Show("You Have Left A HotKey Field Blank or ScriptName Blank");
}
Query::Close();
}
}
private: System::Void textBox3_KeyPress(System::Object^ sender, System::Windows::Forms::KeyPressEventArgs^ e) {
String^ Script = textBox1->Text;
String^ HotKey1 = textBox2->Text;
String^ HotKey2 = textBox3->Text;
if(!Char::IsDigit(e->KeyChar) && (e->KeyChar != 0x08) && (e->KeyChar != 0x0D))
{
e->Handled = true;
MessageBox::Show("Enter The Corresponding Key Number Only -- See Help For Details.");
}
else if(e->KeyChar == 0x0D)
{
if((Script == "")||(HotKey1 == ""))
{
MessageBox::Show("You Have Left A HotKey Field Blank or ScriptName Blank");
}
Query::Close();
}
}
};
}
SmartChat.CPP
// SmartChat.cpp : main project file.
#include "stdafx.h"
#include "Form1.h"
using namespace SmartChat;
using namespace System::Threading;
[STAThreadAttribute]
int main(array<System::String ^> ^args)
{
Mutex^ m = gcnew Mutex( false,"SmartChat" );
bool exists = m->WaitOne(10, true);
Console::WriteLine("Application already running {0}", exists);
if(!exists)
{
MessageBox::Show("An Instance of SmartChat is Already Running, Press F10 to stop SmartChat.");
return 0;
}
Thread::Sleep(5000);
// Enabling Windows XP visual effects before any controls are created
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(fal se);
// Create the main window and run it
Application::Run(gcnew Form1());
GC::KeepAlive(m);
return 0;
}
App.rc
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon placed first or with lowest ID value becomes application icon
LANGUAGE 9, 4
#pragma code_page(1252)
0 ICON "SChat.ico"
1 ICON "app.ico"
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
"\0"
END
2 TEXTINCLUDE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE
BEGIN
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED
Program Alone (v3): http://www.multiupload.com/08I6LOEGM7
(http://www.multiupload.com/08I6LOEGM7)
Program itself (in the Release folder) + The source-code:
Updated As Of: April 4th 2011.
http://www.multiupload.com/L4MNLQ3AFT
OLDER VERSION (v2)
http://www.multiupload.com/ZD4WG24BGH
(http://www.multiupload.com/ZD4WG24BGH)
Source:
http://www.multiupload.com/CPUIV796Y9
MUST DO!:
Go to Sm0k3's thread here to get the latest SmartChat.sex: LINK (http://villavu.com/forum/showthread.php?t=63432&highlight=smartchat)
Next you must Replace all the code in the SmartChat.Simba file with:
procedure WriteSMART;
begin
if StrToBool(ReadINI('Changed', 'Changed', IncludePath+'SRL/SRL/SMARTchat/SMARTchat.INI')) then
begin
WriteINI('Changed', 'Changed', 'False', IncludePath+'SRL/SRL/SMARTchat/SMARTchat.INI');
if((ReadINI('SMART', 'SMART', IncludePath+'SRL/SRL/SMARTchat/SMARTchat.INI') = '[Enter]') or
(ReadINI('SMART', 'SMART', IncludePath+'SRL/SRL/SMARTchat/SMARTchat.INI') = '[E]'))then
begin
TypeSendEx(+Chr(13),False);
end else
if((ReadINI('SMART', 'SMART', IncludePath+'SRL/SRL/SMARTchat/SMARTchat.INI') = '[Tab]') or
(ReadINI('SMART', 'SMART', IncludePath+'SRL/SRL/SMARTchat/SMARTchat.INI') = '[T]'))then
begin
TypeSendEx(+Chr(9), False);
end else
if((ReadINI('SMART', 'SMART', IncludePath+'SRL/SRL/SMARTchat/SMARTchat.INI') = '[Back]') or
(ReadINI('SMART', 'SMART', IncludePath+'SRL/SRL/SMARTchat/SMARTchat.INI') = '[B]')) then
begin
TypeSendEx(+Chr(8), False);
end else
if(ReadINI('SMART', 'SMART', IncludePath+'SRL/SRL/SMARTchat/SMARTchat.INI') = '[Esc]') then
begin
TypeSendEx(+Chr(27), False);
end else
if((ReadINI('SMART', 'SMART', IncludePath+'SRL/SRL/SMARTchat/SMARTchat.INI') = '[Down]') or
(ReadINI('SMART', 'SMART', IncludePath+'SRL/SRL/SMARTchat/SMARTchat.INI') = '[D]'))then
begin
TypeSendEx(+Chr(40), False);
end else
if((ReadINI('SMART', 'SMART', IncludePath+'SRL/SRL/SMARTchat/SMARTchat.INI') = '') or
(ReadINI('SMART', 'SMART', IncludePath+'SRL/SRL/SMARTchat/SMARTchat.INI') = '[U]'))then
begin
TypeSendEx(+Chr(38), False);
end else
if((ReadINI('SMART', 'SMART', IncludePath+'SRL/SRL/SMARTchat/SMARTchat.INI') = '[Left]') or
(ReadINI('SMART', 'SMART', IncludePath+'SRL/SRL/SMARTchat/SMARTchat.INI') = '[L]'))then
begin
TypeSendEx(+Chr(37), False);
end else
if((ReadINI('SMART', 'SMART', IncludePath+'SRL/SRL/SMARTchat/SMARTchat.INI') = '[Right]') or
(ReadINI('SMART', 'SMART', IncludePath+'SRL/SRL/SMARTchat/SMARTchat.INI') = '[R]'))then
begin
TypeSendEx(+Chr(39), False);
end else
TypeSend(ReadINI('SMART', 'SMART', IncludePath+'SRL/SRL/SMARTchat/SMARTchat.INI'));
end;
end;
And the outcome of running it:
Press the SmartChat button (on the game window) to bring up this menu OR Press F9 on the Keyboard.
10934
How To Setup:
Run SmartChat.
10941
This Menu Comes up for you to enter script name.
10942
Enter the Name of the Script your running. AKA the Name of the .Simba file.
Example:
10943
How To Exit Smart Chat (F10 Key to exit):
10944
Enjoy.
Credits:
[U]Thank you Sm0k3 for creating SmartChat extension which got me interested and motivated enough to create this program.
Changes:
Added Hotkeys.
Added Query. (Allows User to enter script name)
Added MultiThreading. (Detects if S.M.A.R.T. + Script Window is open without interupting the program)
Fix Memory/CPU issues when running with S.M.A.R.T. (This was a Repeat Until Loop that raised CPU from 0 to 50... Now CPU is always 0 or 1.. Uses less resources)
Optimized Code(Fix Code a lot! Rewrote the whole thing, Less threads, Proper Hotkey Detection, Removed all Deprecated Headers, Better Error Handling)
Fixed Typo's In MessageBoxes (For Better Error Handling and Debugging for the User)
Added The Ability To Choose HotKeys. (User Defined HotKeys)
Added Help Menu For HotKey Codes, Etc.
Fixed Button Display Bug. (In The New version, It WASN'T being Painted Properly)
Credits:
Sm0k3. For Creating SmartChat Extension (Gave me motivation to create this).
Description:
What this does is add or remove a button to SMART and when clicked, sends the F12 Key to the simba client whether or not its in the system tray.
It was made to work with Sm0k3's SmartChat.sex (Link (http://villavu.com/forum/showthread.php?t=63432)).
It can be modified to do whatever basically. TO add the button, u run it, to remove the button u added, u kill the program.
Everything below is all C++ Code & Pictures. Program Is Below the Source Code.. Last Few Lines of this Post.
Form1.h
#define REPEAT do{
#define UNTIL( condition ) }while(!(condition));
#pragma once
#pragma comment(lib, "advapi32.lib")
#pragma comment(lib, "user32.lib")
#include <windows.h>
#include <tlhelp32.h>
#include <iostream>
#include <sstream>
#include <cstdlib>
#include "Query.h"
using namespace std;
namespace SmartChat {
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
using namespace System::Security::Permissions;
using namespace System::Runtime::InteropServices;
using namespace System::Threading;
/// <summary>
/// Summary for Form1
///
/// WARNING: If you change the name of this class, you will need to change the
/// 'Resource File Name' property for the managed resource compiler tool
/// associated with all .resx files this class depends on. Otherwise,
/// the designers will not be able to interact properly with localized
/// resources associated with this form.
/// </summary>
string SimbaName;
public ref class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
//
//TODO: Add the constructor code here
//
}
public:
System::String^ SysStr;
System::String^ HotKey1;
System::String^ HotKey2;
protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~Form1()
{
if (components)
{
delete components;
}
}
private: System::ComponentModel::BackgroundWorker^ Worker;
private: System::Windows::Forms::Button^ button1;
protected:
private:
/// <summary>
/// Required designer variable.
/// </summary>
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent(void)
{
System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(F orm1::typeid));
this->Worker = (gcnew System::ComponentModel::BackgroundWorker());
this->button1 = (gcnew System::Windows::Forms::Button());
this->SuspendLayout();
//
// Worker
//
this->Worker->DoWork += gcnew System::ComponentModel::DoWorkEventHandler(this, &Form1::Worker_DoWork);
//
// button1
//
this->button1->BackColor = System::Drawing::Color::Tan;
this->button1->BackgroundImage = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"button1.BackgroundImage")));
this->button1->BackgroundImageLayout = System::Windows::Forms::ImageLayout::Stretch;
this->button1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 7, System::Drawing::FontStyle::Italic, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->button1->ForeColor = System::Drawing::Color::Gold;
this->button1->Location = System::Drawing::Point(0, 0);
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(27, 33);
this->button1->TabIndex = 0;
this->button1->Text = L"Sc";
this->button1->UseVisualStyleBackColor = true;
this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
//
// Form1
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(27, 33);
this->Controls->Add(this->button1);
this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::FixedTool Window;
this->MaximizeBox = false;
this->MinimizeBox = false;
this->Name = L"Form1";
this->ShowInTaskbar = false;
this->Text = L"SChat";
this->WindowState = System::Windows::Forms::FormWindowState::Minimized ;
this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
this->ResumeLayout(false);
}
#pragma endregion
DWORD CountProcesses(CHAR *pProcessName)
{
DWORD dwCount = 0;
HANDLE hSnap = NULL;
PROCESSENTRY32 proc32;
if((hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0)) == INVALID_HANDLE_VALUE)
return -1;
proc32.dwSize=sizeof(PROCESSENTRY32);
while((Process32Next(hSnap, &proc32)) == TRUE)
if(_stricmp(proc32.szExeFile,pProcessName) == 0)
++dwCount;
CloseHandle(hSnap);
return dwCount;
}
void MarshalString (String ^ s, string& os) {
const char* chars = (const char*)(Marshal::StringToHGlobalAnsi(s)).ToPointer( );
os = chars;
Marshal::FreeHGlobal(IntPtr((void*)chars));
}
private: System::Void Worker_DoWork(System::Object^ sender, System::ComponentModel::DoWorkEventArgs^ e) {
enum {F9_KEYID = 1, F10_KEYID = 2};
HWND Simba = FindWindow(NULL, SimbaName.c_str());
if(RegisterHotKey(0, F9_KEYID, 0x4000, UInt32::Parse(HotKey1, System::Globalization::NumberStyles::HexNumber))) //F9 = 0x78
{
MessageBox::Show("SmartChat -- Registered HotKey: 0x" + HotKey1);
}
else
{
MessageBox::Show("Another Program Currently has the F9 Key in use -- Terminating SmartChat.");
exit(0);
}
if(RegisterHotKey(0, F10_KEYID, 0x4000, UInt32::Parse(HotKey2, System::Globalization::NumberStyles::HexNumber))) //F10 = 0x79
{
MessageBox::Show("SmartChat -- Registered HotKey: 0x" + HotKey2 + " To Exit");
}
else
{
MessageBox::Show("Another Program Currently has the F10 Key in use -- Terminating SmartChat.");
}
MSG msg;
char cProcess[20] = "Simba.exe";
DWORD dwReturn;
dwReturn = CountProcesses(cProcess);
REPEAT
while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
{
switch(msg.message)
{
case WM_HOTKEY:
if(msg.wParam == F9_KEYID)
{
::SendMessage(Simba, WM_KEYDOWN, VK_F12,0);
}
else if(msg.wParam == F10_KEYID)
{
MessageBox::Show("0x" + HotKey2 + " HotKey Pressed -- Exiting SmartChat.");
exit(0);
}
break;
}
break;
}
if(dwReturn != -1)
{
if((dwReturn < 1))
{
MessageBox::Show("Simba Isn't Running -- Terminating SmartChat.");
dwReturn = CountProcesses(cProcess);
exit(0);
}
HWND Smart = FindWindow("SunAwtFrame", "Public SMARTv6.6 - SMART Minimizing Autoing Resource Thing - By BenLand100");
if(Smart == NULL)
{
MessageBox::Show("S.M.A.R.T. isn't running -- Terminating SmartChat.");
exit(0);
}
dwReturn = CountProcesses(cProcess);
}
Sleep(1000);
Thread::Sleep(0);
UNTIL(false);
}
private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) {
Form1::Visible = false;
Query ^ Form2 = gcnew Query();
Form2->ShowDialog();
HotKey1 = Form2->textBox2->Text;
HotKey2 = Form2->textBox3->Text;
System::String^ ScrName = Form2->textBox1->Text;
System::String^ SmbName = "Simba - " + ScrName;
SysStr = SmbName;
IntPtr SimbaPtr = System::Runtime::InteropServices::Marshal::StringT oHGlobalAnsi(SysStr);
MarshalString(SysStr, SimbaName);
System::Runtime::InteropServices::Marshal::FreeHGl obal(SimbaPtr);
if(SimbaName == "")
{
MessageBox::Show("Query: ScriptName Field Was Left Blank -- Terminating SmartChat.");
exit(0);
}
HWND Simba = FindWindow(0, SimbaName.c_str());
HWND Smart = FindWindowW(L"SunAwtFrame", L"Public SMARTv6.6 - SMART Minimizing Autoing Resource Thing - By BenLand100");
if(Simba == NULL)
{
MessageBox::Show("SimbaScript Not Found -- Terminating SmartChat.");
exit(0);
}
if(Smart == NULL)
{
MessageBox::Show("S.M.A.R.T. Is Not Running -- Terminating Smartchat.");
exit(0);
}
ShowWindow((HWND)Form1::Handle.ToPointer(), SW_HIDE);
SetParent((HWND)button1->Handle.ToPointer(), Smart);
button1->Location = Point(528, 469);
Worker->RunWorkerAsync();
}
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
HWND Simba = FindWindow(NULL, SimbaName.c_str());
if(Simba == NULL)
{
MessageBox::Show("Cannot Find Simba -- Terminating SmartChat.");
exit(0);
}
::SendMessage(Simba, WM_KEYDOWN, VK_F12,0);
}
};
}
Query A.k.a. Form2
#define REPEAT do{
#define UNTIL( condition ) }while(!(condition));
#include <Windows.h>
#include <tchar.h>
#include <iostream>
using namespace std;
#pragma once
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
using namespace System::Threading;
namespace SmartChat {
/// <summary>
/// Summary for Query
///
/// WARNING: If you change the name of this class, you will need to change the
/// 'Resource File Name' property for the managed resource compiler tool
/// associated with all .resx files this class depends on. Otherwise,
/// the designers will not be able to interact properly with localized
/// resources associated with this form.
/// </summary>
public ref class Query : public System::Windows::Forms::Form
{
private:
public:
Query(void)
{
InitializeComponent();
//
//TODO: Add the constructor code here
//
}
protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~Query()
{
if (components)
{
delete components;
}
}
public: System::Windows::Forms::TextBox^ textBox1;
protected:
private: System::Windows::Forms::Label^ label1;
private: System::Windows::Forms::Button^ button1;
private: System::Windows::Forms::Label^ label2;
public: System::Windows::Forms::TextBox^ textBox2;
private:
private: System::Windows::Forms::Label^ label3;
public: System::Windows::Forms::TextBox^ textBox3;
private:
private: System::Windows::Forms::Button^ button2;
private: System::Windows::Forms::RichTextBox^ richTextBox1;
private:
/// <summary>
/// Required designer variable.
/// </summary>
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent(void)
{
System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(Q uery::typeid));
this->textBox1 = (gcnew System::Windows::Forms::TextBox());
this->label1 = (gcnew System::Windows::Forms::Label());
this->button1 = (gcnew System::Windows::Forms::Button());
this->label2 = (gcnew System::Windows::Forms::Label());
this->textBox2 = (gcnew System::Windows::Forms::TextBox());
this->label3 = (gcnew System::Windows::Forms::Label());
this->textBox3 = (gcnew System::Windows::Forms::TextBox());
this->button2 = (gcnew System::Windows::Forms::Button());
this->richTextBox1 = (gcnew System::Windows::Forms::RichTextBox());
this->SuspendLayout();
//
// textBox1
//
this->textBox1->Location = System::Drawing::Point(12, 25);
this->textBox1->Name = L"textBox1";
this->textBox1->Size = System::Drawing::Size(71, 20);
this->textBox1->TabIndex = 0;
this->textBox1->TextChanged += gcnew System::EventHandler(this, &Query::textBox1_TextChanged);
this->textBox1->KeyPress += gcnew System::Windows::Forms::KeyPressEventHandler(this, &Query::textBox1_KeyPress);
//
// label1
//
this->label1->AutoSize = true;
this->label1->Location = System::Drawing::Point(9, 9);
this->label1->Name = L"label1";
this->label1->Size = System::Drawing::Size(65, 13);
this->label1->TabIndex = 1;
this->label1->Text = L"ScriptName:";
//
// button1
//
this->button1->Location = System::Drawing::Point(128, 25);
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(47, 24);
this->button1->TabIndex = 2;
this->button1->Text = L"Submit";
this->button1->UseVisualStyleBackColor = true;
this->button1->Click += gcnew System::EventHandler(this, &Query::button1_Click);
//
// label2
//
this->label2->AutoSize = true;
this->label2->Location = System::Drawing::Point(13, 92);
this->label2->Name = L"label2";
this->label2->Size = System::Drawing::Size(81, 13);
this->label2->TabIndex = 3;
this->label2->Text = L"HotKey To Exit:";
//
// textBox2
//
this->textBox2->Location = System::Drawing::Point(16, 69);
this->textBox2->Name = L"textBox2";
this->textBox2->Size = System::Drawing::Size(67, 20);
this->textBox2->TabIndex = 4;
this->textBox2->TextChanged += gcnew System::EventHandler(this, &Query::textBox2_TextChanged);
this->textBox2->KeyPress += gcnew System::Windows::Forms::KeyPressEventHandler(this, &Query::textBox2_KeyPress);
//
// label3
//
this->label3->AutoSize = true;
this->label3->Location = System::Drawing::Point(13, 53);
this->label3->Name = L"label3";
this->label3->Size = System::Drawing::Size(91, 13);
this->label3->TabIndex = 5;
this->label3->Text = L"HotKey For Msgs:";
//
// textBox3
//
this->textBox3->Location = System::Drawing::Point(16, 110);
this->textBox3->Name = L"textBox3";
this->textBox3->Size = System::Drawing::Size(67, 20);
this->textBox3->TabIndex = 6;
this->textBox3->TextChanged += gcnew System::EventHandler(this, &Query::textBox3_TextChanged);
this->textBox3->KeyPress += gcnew System::Windows::Forms::KeyPressEventHandler(this, &Query::textBox3_KeyPress);
//
// button2
//
this->button2->Location = System::Drawing::Point(128, 80);
this->button2->Name = L"button2";
this->button2->Size = System::Drawing::Size(38, 30);
this->button2->TabIndex = 7;
this->button2->Text = L"Help";
this->button2->UseVisualStyleBackColor = true;
this->button2->Click += gcnew System::EventHandler(this, &Query::button2_Click);
//
// richTextBox1
//
this->richTextBox1->BackColor = System::Drawing::Color::Gainsboro;
this->richTextBox1->Font = (gcnew System::Drawing::Font(L"Arial", 7.5F, System::Drawing::FontStyle::Italic, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->richTextBox1->ForeColor = System::Drawing::Color::Blue;
this->richTextBox1->Location = System::Drawing::Point(-2, -1);
this->richTextBox1->Name = L"richTextBox1";
this->richTextBox1->ReadOnly = true;
this->richTextBox1->Size = System::Drawing::Size(229, 144);
this->richTextBox1->TabIndex = 8;
this->richTextBox1->Text = resources->GetString(L"richTextBox1.Text");
this->richTextBox1->Visible = false;
this->richTextBox1->Click += gcnew System::EventHandler(this, &Query::richTextBox1_Click);
//
// Query
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(226, 142);
this->Controls->Add(this->richTextBox1);
this->Controls->Add(this->button2);
this->Controls->Add(this->textBox3);
this->Controls->Add(this->label3);
this->Controls->Add(this->textBox2);
this->Controls->Add(this->label2);
this->Controls->Add(this->button1);
this->Controls->Add(this->label1);
this->Controls->Add(this->textBox1);
this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::FixedTool Window;
this->MaximizeBox = false;
this->MinimizeBox = false;
this->Name = L"Query";
this->ShowIcon = false;
this->Text = L"Query";
this->Deactivate += gcnew System::EventHandler(this, &Query::Query_Deactivate);
this->Load += gcnew System::EventHandler(this, &Query::Query_Load);
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
private: System::Void textBox1_TextChanged(System::Object^ sender, System::EventArgs^ e) {
}
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
String^ Script = textBox1->Text;
String^ HotKey1 = textBox2->Text;
String^ HotKey2 = textBox3->Text;
if((Script == "")||(HotKey1 == "")||(HotKey2 == ""))
{
MessageBox::Show("You Have Left A HotKey Field Blank or ScriptName Blank");
}
Query::Close();
}
private: System::Void Query_Load(System::Object^ sender, System::EventArgs^ e) {
IntPtr Qptr = Query::Handle;
HWND hQuery = (HWND)Qptr.ToPointer();
ShowWindow(hQuery, SW_SHOW);
SetWindowPos(hQuery, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE);
Query::Activate();
}
private: System::Void textBox1_KeyPress(System::Object^ sender, System::Windows::Forms::KeyPressEventArgs^ e) {
String^ Script = textBox1->Text;
String^ HotKey1 = textBox2->Text;
String^ HotKey2 = textBox3->Text;
if(e->KeyChar == 0x0D)
{
if((HotKey1 == "")||(HotKey2 == ""))
{
MessageBox::Show("You Have Left A HotKey Field Blank");
}
Query::Close();
}
}
private: System::Void Query_Deactivate(System::Object^ sender, System::EventArgs^ e) {
IntPtr Qptr = Query::Handle;
HWND hQuery = (HWND)Qptr.ToPointer();
ShowWindow(hQuery, SW_SHOW);
SetWindowPos(hQuery, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE);
IntPtr tBoxptr = textBox1->Handle;
HWND hTBoxptr = (HWND)tBoxptr.ToPointer();
RECT rcClient;
GetClientRect(hQuery, &rcClient);
POINT ptClientUL; // client upper left corner
POINT ptClientLR; // client lower right corner
POINT ptClientUR; // client upper right corner
POINT ptClientLL; // client lower left corner
ptClientUR.x = rcClient.right;
ptClientUR.y = rcClient.top;
ptClientLL.x = rcClient.left - 1;
ptClientLL.y = rcClient.bottom - 1;
ptClientUL.x = rcClient.left;
ptClientUL.y = rcClient.top;
ptClientLR.x = rcClient.right + 1;
ptClientLR.y = rcClient.bottom + 1;
ClientToScreen(hQuery, &ptClientUL);
ClientToScreen(hQuery, &ptClientLR);
ClientToScreen(hQuery, &ptClientUR);
ClientToScreen(hQuery, &ptClientLL);
//Clips the cursor to the specified client window..
SetRect(&rcClient, ptClientUL.x, ptClientUL.y,
ptClientLR.x, ptClientLR.y);
ClipCursor(&rcClient);
SetCursorPos(ptClientUR.x - 119 , ptClientUR.y + 38);
POINT cursorPos;
GetCursorPos(&cursorPos);
int h = (int) cursorPos.x;
int k = (int) cursorPos.y;
Sleep(500);
mouse_event(MOUSEEVENTF_LEFTDOWN, h, k, 0, 0);
mouse_event(MOUSEEVENTF_LEFTUP, h, k, 0, 0);
ClipCursor(NULL);
Sleep(500);
}
private: System::Void richTextBox1_Click(System::Object^ sender, System::EventArgs^ e) {
richTextBox1->Visible = false;
}
private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {
richTextBox1->Visible = true;
}
private: System::Void textBox2_TextChanged(System::Object^ sender, System::EventArgs^ e) {
}
private: System::Void textBox3_TextChanged(System::Object^ sender, System::EventArgs^ e) {
}
private: System::Void textBox2_KeyPress(System::Object^ sender, System::Windows::Forms::KeyPressEventArgs^ e) {
String^ Script = textBox1->Text;
String^ HotKey1 = textBox2->Text;
String^ HotKey2 = textBox3->Text;
if(!Char::IsDigit(e->KeyChar) && (e->KeyChar != 0x08) && (e->KeyChar != 0x0D))
{
e->Handled = true;
MessageBox::Show("Enter The Corresponding Key Number Only -- See Help For Details.");
}
else if(e->KeyChar == 0x0D)
{
if((Script == "")||(HotKey2 == ""))
{
MessageBox::Show("You Have Left A HotKey Field Blank or ScriptName Blank");
}
Query::Close();
}
}
private: System::Void textBox3_KeyPress(System::Object^ sender, System::Windows::Forms::KeyPressEventArgs^ e) {
String^ Script = textBox1->Text;
String^ HotKey1 = textBox2->Text;
String^ HotKey2 = textBox3->Text;
if(!Char::IsDigit(e->KeyChar) && (e->KeyChar != 0x08) && (e->KeyChar != 0x0D))
{
e->Handled = true;
MessageBox::Show("Enter The Corresponding Key Number Only -- See Help For Details.");
}
else if(e->KeyChar == 0x0D)
{
if((Script == "")||(HotKey1 == ""))
{
MessageBox::Show("You Have Left A HotKey Field Blank or ScriptName Blank");
}
Query::Close();
}
}
};
}
SmartChat.CPP
// SmartChat.cpp : main project file.
#include "stdafx.h"
#include "Form1.h"
using namespace SmartChat;
using namespace System::Threading;
[STAThreadAttribute]
int main(array<System::String ^> ^args)
{
Mutex^ m = gcnew Mutex( false,"SmartChat" );
bool exists = m->WaitOne(10, true);
Console::WriteLine("Application already running {0}", exists);
if(!exists)
{
MessageBox::Show("An Instance of SmartChat is Already Running, Press F10 to stop SmartChat.");
return 0;
}
Thread::Sleep(5000);
// Enabling Windows XP visual effects before any controls are created
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(fal se);
// Create the main window and run it
Application::Run(gcnew Form1());
GC::KeepAlive(m);
return 0;
}
App.rc
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon placed first or with lowest ID value becomes application icon
LANGUAGE 9, 4
#pragma code_page(1252)
0 ICON "SChat.ico"
1 ICON "app.ico"
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
"\0"
END
2 TEXTINCLUDE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE
BEGIN
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED
Program Alone (v3): http://www.multiupload.com/08I6LOEGM7
(http://www.multiupload.com/08I6LOEGM7)
Program itself (in the Release folder) + The source-code:
Updated As Of: April 4th 2011.
http://www.multiupload.com/L4MNLQ3AFT
OLDER VERSION (v2)
http://www.multiupload.com/ZD4WG24BGH
(http://www.multiupload.com/ZD4WG24BGH)
Source:
http://www.multiupload.com/CPUIV796Y9
MUST DO!:
Go to Sm0k3's thread here to get the latest SmartChat.sex: LINK (http://villavu.com/forum/showthread.php?t=63432&highlight=smartchat)
Next you must Replace all the code in the SmartChat.Simba file with:
procedure WriteSMART;
begin
if StrToBool(ReadINI('Changed', 'Changed', IncludePath+'SRL/SRL/SMARTchat/SMARTchat.INI')) then
begin
WriteINI('Changed', 'Changed', 'False', IncludePath+'SRL/SRL/SMARTchat/SMARTchat.INI');
if((ReadINI('SMART', 'SMART', IncludePath+'SRL/SRL/SMARTchat/SMARTchat.INI') = '[Enter]') or
(ReadINI('SMART', 'SMART', IncludePath+'SRL/SRL/SMARTchat/SMARTchat.INI') = '[E]'))then
begin
TypeSendEx(+Chr(13),False);
end else
if((ReadINI('SMART', 'SMART', IncludePath+'SRL/SRL/SMARTchat/SMARTchat.INI') = '[Tab]') or
(ReadINI('SMART', 'SMART', IncludePath+'SRL/SRL/SMARTchat/SMARTchat.INI') = '[T]'))then
begin
TypeSendEx(+Chr(9), False);
end else
if((ReadINI('SMART', 'SMART', IncludePath+'SRL/SRL/SMARTchat/SMARTchat.INI') = '[Back]') or
(ReadINI('SMART', 'SMART', IncludePath+'SRL/SRL/SMARTchat/SMARTchat.INI') = '[B]')) then
begin
TypeSendEx(+Chr(8), False);
end else
if(ReadINI('SMART', 'SMART', IncludePath+'SRL/SRL/SMARTchat/SMARTchat.INI') = '[Esc]') then
begin
TypeSendEx(+Chr(27), False);
end else
if((ReadINI('SMART', 'SMART', IncludePath+'SRL/SRL/SMARTchat/SMARTchat.INI') = '[Down]') or
(ReadINI('SMART', 'SMART', IncludePath+'SRL/SRL/SMARTchat/SMARTchat.INI') = '[D]'))then
begin
TypeSendEx(+Chr(40), False);
end else
if((ReadINI('SMART', 'SMART', IncludePath+'SRL/SRL/SMARTchat/SMARTchat.INI') = '') or
(ReadINI('SMART', 'SMART', IncludePath+'SRL/SRL/SMARTchat/SMARTchat.INI') = '[U]'))then
begin
TypeSendEx(+Chr(38), False);
end else
if((ReadINI('SMART', 'SMART', IncludePath+'SRL/SRL/SMARTchat/SMARTchat.INI') = '[Left]') or
(ReadINI('SMART', 'SMART', IncludePath+'SRL/SRL/SMARTchat/SMARTchat.INI') = '[L]'))then
begin
TypeSendEx(+Chr(37), False);
end else
if((ReadINI('SMART', 'SMART', IncludePath+'SRL/SRL/SMARTchat/SMARTchat.INI') = '[Right]') or
(ReadINI('SMART', 'SMART', IncludePath+'SRL/SRL/SMARTchat/SMARTchat.INI') = '[R]'))then
begin
TypeSendEx(+Chr(39), False);
end else
TypeSend(ReadINI('SMART', 'SMART', IncludePath+'SRL/SRL/SMARTchat/SMARTchat.INI'));
end;
end;
And the outcome of running it:
Press the SmartChat button (on the game window) to bring up this menu OR Press F9 on the Keyboard.
10934
How To Setup:
Run SmartChat.
10941
This Menu Comes up for you to enter script name.
10942
Enter the Name of the Script your running. AKA the Name of the .Simba file.
Example:
10943
How To Exit Smart Chat (F10 Key to exit):
10944
Enjoy.
Credits:
[U]Thank you Sm0k3 for creating SmartChat extension which got me interested and motivated enough to create this program.