PDA

View Full Version : Added Button to Smart :)



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.

cycrosism
03-30-2011, 12:14 PM
I wonder if a fix has been made yet to fix the error where the keyboard doesn't work when you disable smart

Rich
03-30-2011, 03:08 PM
I wonder if a fix has been made yet to fix the error where the keyboard doesn't work when you disable smartBen said that couldn't be fixed iirc.

Zyt3x
03-30-2011, 03:27 PM
Ben said that couldn't be fixed iirc.That's because there is no bug.

It works perfectly well, but not with ALL systems

Flight
03-30-2011, 03:41 PM
Yeah I don't really think it's much of an issue. It doesn't work for me, so I simply minimize Smart and bring it back up after I've disabled Smart and I can use keyboard functions again, it's no problem IMO.

Brandon
03-30-2011, 03:51 PM
Yeah I don't really think it's much of an issue. It doesn't work for me, so I simply minimize Smart and bring it back up after I've disabled Smart and I can use keyboard functions again, it's no problem IMO.

Yeah but who wants to have to do that every single time.. I personally dont like stopping my script or minimizing smart as it loses focus and then messes up my script if its doing a mouse procedure..

Yes this fixes that problem keypresses... U can easily put something to detect every keypress but that would be quite stupid so instead I just put a button.. U click it, it activates an extension in simba and u can type :)

As for whoever said it cant be fixed... it can, I've looked at eventNazi and the blockingqueue and it checks if nazi.. != null then allows keypresses..

IMO not sure why he has that but it shouldnt even need to check.. it should just send it straight through.

Also Iunno why there is a wait procedure between the key presses for keeping/losing focus but thats what gives the "you have no messages to reply to". I replaced the wait() in on my own with an && below.. Just needa get it to compile :( but I keep getting buildmain error 1 even if I compile the original :S



private synchronized void looseFocus(boolean tabbed) {
if (focused) {
if (tabbed) {
(BlockingEventQueue.sendUnblocked(new KeyEvent(comp, KeyEvent.KEY_PRESSED,System.currentTimeMillis(),Ke yEvent.ALT_DOWN_MASK,KeyEvent.VK_ALT,KeyEvent.CHAR _UNDEFINED,KeyEvent.KEY_LOCATION_LEFT))
&& //<----- Notice the && operator?? why have a wait?
BlockingEventQueue.sendUnblocked(new KeyEvent(comp, KeyEvent.KEY_PRESSED,System.currentTimeMillis(),Ke yEvent.ALT_DOWN_MASK,KeyEvent.VK_TAB,'\t',KeyEvent .KEY_LOCATION_STANDARD)));
wait(100,200);
BlockingEventQueue.sendUnblocked(new KeyEvent(comp, KeyEvent.KEY_RELEASED,System.currentTimeMillis(),0 ,KeyEvent.VK_ALT,KeyEvent.CHAR_UNDEFINED,KeyEvent. KEY_LOCATION_LEFT));
wait(10,50);
}
BlockingEventQueue.sendUnblocked(new FocusEvent(comp, FocusEvent.FOCUS_LOST, false, null));
BlockingEventQueue.sendUnblocked(new FocusEvent(comp, FocusEvent.FOCUS_LOST, false, null));
focused = false;
wait(100,200);
}
}

//Also here:

public void sendKeys(String string) {
nazi.sendKeys(string); <-- Changed that.. instead of waiting for nazi != null..
}

tofurocks
03-30-2011, 11:36 PM
This appears to be managed C++ correct?

Harry
03-30-2011, 11:40 PM
Do you think the floating object would effect CPU/FPS (for the worse)? I think it could. But looks nice.

YoHoJo
03-31-2011, 12:56 AM
I wonder if a fix has been made yet to fix the error where the keyboard doesn't work when you disable smart

If you just enable/disable two times (or maybe more) it works, for me at least.

NCDS
03-31-2011, 01:12 AM
If you just enable/disable two times (or maybe more) it works, for me at least.

That's what I generally do.

@ggzz, Nice little feature. :)

Brandon
03-31-2011, 01:54 AM
That's what I generally do.

@ggzz, Nice little feature. :)

Thanx :)

@toforucks, Yes its managed c++. VisualStudio Ultimate 2010 and Professional 2008.

I just updated it on my computer, added hotkeys so when u press a button, an input box comes up, u type and it sends it immediately to the client. Might upload it later.

I added stuff like:

If the user types: "[Enter]", [Tab], [Esc], [Back], it presses the corresponding keys.. Made shortcuts for it too like if u enter: [E], [T]. [Esc], [B].. itll do the same thing..

TODO: Figure out a way to Find the simba window more accurate.. Right now it finds the window using:

FindWindow(NULL, L"Simba - ScriptNameHere", 0);
Thats a problem because of the script name which will be different for whatever script your using.. I needa make a function to find parts of the window text.

cycrosism
03-31-2011, 05:24 AM
Ben said that couldn't be fixed iirc.

Why doesn't he just look at what RSbot did? They seem to have done it right.

sm0k3
03-31-2011, 08:05 AM
great idea .. makes things much easier..




TODO: Figure out a way to Find the simba window more accurate.. Right now it finds the window using:

FindWindow(NULL, L"Simba - ScriptNameHere", 0);
Thats a problem because of the script name which will be different for whatever script your using.. I needa make a function to find parts of the window text.


why not get the names of all windows that are open into an array then search the array for the title containing simba tha array wouuld then also contain the exact window title for the simba in question you could also work with multiple simbas then i think ..



EDIT:

Had any luck with the proggy finding simba with the simba bit ... lol

if so can pascal / simba load an exe if so can we include it in the plugin .. when the plugin loads so does the app . i know a way to raise to admin rights via vbscript and Cscript.exe .. < you cant run SMARTchat,exe on Vista / WIN7 without admin rights ..
well you can but i need admin rights for sps / simba .. and the button dosent appear in SMART unless SMARTchat.exe is admin rights aswell
..

Brandon
04-03-2011, 05:13 PM
great idea .. makes things much easier..



why not get the names of all windows that are open into an array then search the array for the title containing simba tha array wouuld then also contain the exact window title for the simba in question you could also work with multiple simbas then i think ..



EDIT:

Had any luck with the proggy finding simba with the simba bit ... lol

if so can pascal / simba load an exe if so can we include it in the plugin .. when the plugin loads so does the app . i know a way to raise to admin rights via vbscript and Cscript.exe .. < you cant run SMARTchat,exe on Vista / WIN7 without admin rights ..
well you can but i need admin rights for sps / simba .. and the button dosent appear in SMART unless SMARTchat.exe is admin rights aswell
..


Hmmm I just updated it, Im not sure why but SmartChat on my computer runs without admin rights, I tried transferring it to a different PC and it runs without it :S

I haven't put any code in there to modify any files on the system at all so it shouldn't give that behavior, nor should it ask for User Account Control. You can always try renaming the File to something else and see.. I've noticed that renaming is sometimes a workaround for UAC.. Or you can try compiling it without the ICON image as I've also noticed that in my previous programs - when I include an Icon, it asks for admin rights when I try to run it.

Anyway the new source code is up with the new program aswell, and the new smartchat.simba file.. I've heard that running an external program in Simba on 64bit doesn't work? Have you clarified this?

I also tried adding a textbox overlay ontop of smart so that when u type in the textbox, it sends the keys to smart directly! But it only works sometimes as Smart still blocks input sometimes unless I directly hook into it which will definitely need admin rights.

And Yes I had a lot of progress finding simba now, I let the user type the script name and it works perfectly.. it even detects if simba is running already or not, if smartchat is running already or not and if smart is running.
Example:

QueryMessageBox - "Enter script name: "
User will have to type in: "ScriptName"... Do not type in "Simba - ScriptName".
You can find the script name by opening the script and looking at the titlebar at the very top.

sm0k3
04-03-2011, 05:23 PM
I've heard that running an external program in Simba on 64bit doesn't work? Have you clarified this?

WORKS FINE FOR ME .. ( WITH ADMIN RIGHTS )


I also tried adding a textbox overlay ontop of smart so that when u type in the textbox, it sends the keys to smart directly! But it only works sometimes as Smart still blocks input sometimes unless I directly hook into it which will definitely need admin rights.

I have a way to start SMARTchat as admin we can include . uses VBscript so peeps can check it if they need to know its safe.


And Yes I had a lot of progress finding simba now, I let the user type the script name and it works perfectly.. it even detects if simba is running already or not, if smartchat is running already or not and if smart is running.


need to check for the little * in filename .. i edited a file ran it with SMARTchat but it complianed .. couldnt simba and exited...
saved the file .. the * went away and SMARTchat was happy

Brandon
04-03-2011, 05:39 PM
WORKS FINE FOR ME .. ( WITH ADMIN RIGHTS )



I have a way to start SMARTchat as admin we can include . uses VBscript so peeps can check it if they need to know its safe.



need to check for the little * in filename .. i edited a file ran it with SMARTchat but it complianed .. couldnt simba and exited...
saved the file .. the * went away and SMARTchat was happy

LOL oohhh I know what u mean lol thats when ur editing a script while its running.. Yeah you will get that error, I haven't found a "true" way of finding scripts by partial name because when u edit the script, the window title will also change and c++ is a language that is picky about Lower case vs Upper case, String 1 vs String 2 with a *... I tried Enum all windows and then find title with partial name but it works only 70% of the time..

I tried FindWindowEx to find the TAB of the script inside simba but that only worked 50% of the time all because a Lowercase vs Uppercase or a * for unsaved scripts, etc was there.. Same with finding smart.. but I solved that one like so:

Finding smart running was hard because as u probably already know, smart doesnt have its own process and when it gets updated the title will change.. if another instance is running, the program will attach itself only to the first instance..

Solved by: FindWindow("Sun Awt Java", "SmartNameHere")
Then FindWindowEx(Smart, .....) Using that classname Sun awt Java was the only way for me to find any instance of smart. Unfortunately simba doesnt have this, and the window title changes every single time a script is edited.

Lowercase n stuff isnt the problem but rather having an extra character in the title will definitely be a problem.

sm0k3
04-03-2011, 05:54 PM
for partial window finding i dont know if this helps ..


BOOL CALLBACK WorkerProc(HWND hwnd, LPARAM lParam) {
static TCHAR buffer[50];

GetWindowText(hwnd, buffer, 50);
if(_tcsstr(buffer, "window name goes here")) {
// do something with hwnd here
return FALSE;
}

return TRUE;
}

then call it with


EnumWindows(WorkerProc, NULL);

Brandon
04-03-2011, 06:43 PM
for partial window finding i dont know if this helps ..


BOOL CALLBACK WorkerProc(HWND hwnd, LPARAM lParam) {
static TCHAR buffer[50];

GetWindowText(hwnd, buffer, 50);
if(_tcsstr(buffer, "window name goes here")) {
// do something with hwnd here
return FALSE;
}

return TRUE;
}

then call it with


EnumWindows(WorkerProc, NULL);

I have already tried that.. besides that isnt managed code so you will get an _clr call instead of _std call.. I already got some code working in a console but implementing it in managed c++ isnt as easy as it is in a console.
I will implement it when I find a way to.

Yago
04-04-2011, 12:42 AM
Mines says that another program is using f9... How should I get it to work then?

Brandon
04-04-2011, 01:24 AM
Mines says that another program is using f9... How should I get it to work then?

Well you can press F9 and see what program is using it.. if a menu comes up with smartchat, then u already have smartchat running.. if not and another program comes up, then u can either exit it or u can recompile smartchat to not exit(0) if another key is already binded..

If u dont want to do that then recompile it to a different key.

0x76 = F7
0x77 = F8
0x78 = F9
0x78 = F10

When I get time that is something I will fix.. To allow the user to choose key combinations themselves.

Yago
04-04-2011, 03:05 AM
I pressed f9 and nothing came up so... I have no idea how to do what you just said...

Brandon
04-04-2011, 05:38 AM
I pressed f9 and nothing came up so... I have no idea how to do what you just said...

There I just did what you requested. Added the ability to choose hotkeys and a bit more features like a help menu and stuff so it can get you started. Completely New interface for the input. Hope you like it. Most of all Hope it works for u, I play Tested it for 1.5 hrs and it worked fine :)

sm0k3
04-04-2011, 09:19 AM
If its ok with you .. im going to update SMARTchats SMARTchat.simba to include your modifications ..

make everyones life a little easier ... lol no editing the includes .. all ready to run lol .

Yago
04-04-2011, 09:07 PM
With the button we do not need to call smartchat or we still do?

Brandon
04-04-2011, 11:20 PM
With the button we do not need to call smartchat or we still do?

Umm if I understand your question correctly, your asking if u still need to use the button.. the answer is no..

You press the hotkey to bring up the chat.. or you press teh button... either one works. I left the button because there are some people that may not always want to set a hotkey.

Yago
04-05-2011, 08:48 PM
Ok cool ill try the new version in a few days

Yago
04-07-2011, 02:13 AM
I Downloaded the new program alone. I got to choose my hotkeys and stuff but everytime I choose f7 and f8 I get the same message:

F9 is currently in use by another program. Even though I didn't choose f9.

Edit: After I ran this... I tried to log on using one of my scripts and the keyboard wasn't working on SMART. This is a serious bug...

Edit: Great no I can't login in to any script even after disabling the extensions and stuff. Ima do a restart!

Brandon
04-07-2011, 02:36 AM
:o The F9 thing is a spelling error in my message box.. I forgot to change it to show which key is bound.. so basically its telling u the key u bound is already bound.

Im not exactly sure what has your keyboard locked like that :S My friend has the same error and he downloaded the older version and it worked for him.. but seeing as the old and new doesnt work for u, hmmm I'll look into this and check msdn to see if there is a way to check what program is binding your keys.

Yago
04-07-2011, 02:58 AM
The old doesn't work cause of the f9 already being used the new you said was an error but now my keyboard is locked only for smart.