Kk so if anyone remembers, a while back I was asking if its possible to attach forms to Smart inorder to have "Gui's and Bot setup" On smart itself...
I was told I can't do that because there is no way to get the Handle to the two windows to do SetParent(Child, Parent).. because that's windows API or it would have to be built in.. something like that..
Well below I have code that indeed does grab the handle to smart and set child windows to it using Simba and no extra programs. Its an extension.
Anyway I need help.. I need to know how to get user input and convert the string they enter into a PCHAR... Next I need to know how to get rid of the Form TitleBar and how to Position the form where I want it or where the user wants it.. I don't know Pascal at all really.. well just a bit but not enough to do this buy myself..
So I need help from anyone who can figure out what I want to do..
Question: Why is there no support for writing extensions in c++ or other languages? Unless its not really possible I guess..
I FIGURED IT OUT!!
After all these years, I figured it out. You can now have GUI's On Smart! You cannot change Constant your GUI to change values then it must be Variables!
Check out the below:
Screenshots of it in action (OLD):
Attachment 11469
Attachment 11475
Simba Script!!! Yes the form works.. But I get these stupid access violation errors :c
Attachment 11476
NEW:
That's the LRC mining. Changing while the script is running works! I can enable and disable options without stopping the script.
Here's Another Two:
Now of course I didn't implement it into Mine/Asha's LRC but this is a real GUI that I spent an hr coding!
ToDo:
Figure out how to move the Form. Impossible while On Smart..
Figure out how to remove Form Titlebar. Impossible while On Smart..
Figure out how to make this work only when the debug button on smart is pressed. (HARDER than I thought :c) Needs Multi-Threading.
FormGui.Sex (Extension):
PHP Code:
program WindowHandles;
type
TCharArray = Array of Char;
var
SimbaMenu, FormGUI: TMenuItem;
Extensions: String;
FormTitleBarName: PChar;
function FindWindow(ClassName, WindowName: PChar): HWND; external 'FindWindowA@User32.dll stdcall';
function SetParent(Child, Parent: HWND): HWND; external 'SetParent@User32.dll stdcall';
function SetWindowPos(Handle, HandleAfter: HWND; X, Y, CX, CY: Integer; Flags: Word) : Boolean; external 'SetWindowPos@User32.dll stdcall';
function FindSmart: HWND;
var
Smart: HWND;
begin
Smart:= FindWindow('SunAwtFrame', 'Public SMARTv6.9 - SMART Minimizing Autoing Resource Thing - By BenLand100');
result:= Smart;
end;
Procedure SetParentSmart(Sender: TObject);
var
FormHandle: HWND;
Line: PCHAR;
begin
//inputQuery('FormGUI', 'FormTitleBarName', Line); Someone help... iunno how to do this part.. GET USER INPUT!!
FormTitleBarName:= 'FormGUI'; //INPUT WOULD GO HERE..
FormHandle:= FindWindow('', FormTitleBarName);
SetParent(FormHandle, FindSmart);
//NEED TO REMOVE THE TITLEBAR FROM THE FORM!!
SetWindowPos(FormHandle, 0, 14, 344, 505, 128, 1);
end;
procedure Init;
var
Line: TCharArray;
begin
SimbaMenu := TMenuItem.Create(Simba_MainMenu);
SimbaMenu.Caption := 'FormGUI';
Simba_MainMenu.Items.Add(SimbaMenu);
FormGUI := TMenuItem.Create(SimbaMenu);
FormGUI.Caption := 'FormGUI';
FormGUI.ShortCut := 123;
FormGUI.OnClick := @SetParentSmart;
SimbaMenu.Add(FormGUI);
end;
function GetName : string;
begin;
result := 'FormGUI';
end;
function GetVersion : string;
begin;
result := '1.0';
end;
procedure Free;
begin
end;
procedure Attach;
begin
writeln(' FormGUI By Ggzz/Brandon ');
Writeln('# FormGUI Simba Extension #');
end;
Procedure Detach;
begin
writeln('FormGUI: GoodBye!');
end;
begin
end.
Test Script:
Attachment 16540
Actual Form by itself:
PHP Code:
{$I SRL/SRL.Simba}
var
GoldOption, CoalOption: Boolean;
type
TFormGUI = record
XFormGUI: TForm;
pControls: TGroupBox;
pAttach: TCheckBox;
pGold: TCheckBox;
pStart: TButton;
pPause: TButton;
pStop: TButton;
pCoal: TCheckBox;
pSFS: TCheckBox;
pJIC: TCheckBox;
pDMP: TCheckBox;
pClose: TButton;
end;
var
FormGUI: TFormGUI;
Procedure Control_Click(Sender: TObject);
begin
Case Sender Of
FormGUI.pClose: FormGUI.XFormGUI.CLOSE;
FormGUI.pCoal: CoalOption:= (Not CoalOption);
FormGUI.pGold: GoldOption:= (Not GoldOption);
end;
end;
procedure Form_OnControlMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
mX, mY, fX, fY, sX, sY : Integer;
begin
fX := FormGUI.XFormGUI.Left;
fY := FormGUI.XFormGUI.Top;
GetMousePos(sX, sY);
IsMouseButtonDown(Mouse_Left);
case Sender of
FormGUI.XFormGUI:
while IsMouseButtonDown(Mouse_Left) do
begin
GetMousePos(mX, mY);
FormGUI.XFormGUI.Left := fX - (sX - mX);
FormGUI.XFormGUI.Top := fY - (sY - mY);
FormGUI.XFormGUI.Refresh;
Wait(1);
end;
end;
end;
procedure FormGUI_Init;
begin
with FormGUI do
begin
XFormGUI := CreateForm;
pControls := TGroupBox.Create(XFormGUI);
pAttach := TCheckBox.Create(pControls);
pGold := TCheckBox.Create(pControls);
pStart := TButton.Create(pControls);
pPause := TButton.Create(pControls);
pStop := TButton.Create(pControls);
pCoal := TCheckBox.Create(pControls);
pSFS := TCheckBox.Create(pControls);
pJIC := TCheckBox.Create(pControls);
pDMP := TCheckBox.Create(pControls);
pClose := TButton.Create(XFormGUI);
with XFormGUI do
begin
Left := 376;
Top := 175;
BorderStyle := bsNone;
Caption := 'FormGUI';
ClientHeight := 128;
ClientWidth := 505;
Color := clBtnFace;
Font.Color := clWindowText;
Font.Height := -11;
Font.Name := 'Tahoma';
Font.Style := [];
PixelsPerInch := 96;
//OnMouseDown := @Form_OnControlMouseDown;
end;
with pControls do
begin
Parent := XFormGUI;
Left := 8;
Top := 5;
Width := 489;
Height := 117;
Caption := 'Control Panel';
TabOrder := 1;
end;
with pAttach do
begin
Parent := pControls;
Left := 15;
Top := 5;
Width := 105;
Height := 17;
Caption := 'Attach GUI Smart';
TabOrder := 0;
OnClick := @Control_Click;
end;
with pGold do
begin
Parent := pControls;
Left := 219;
Top := 5;
Width := 97;
Height := 17;
Caption := 'Mine Gold';
TabOrder := 1;
OnClick := @Control_Click;
end;
with pStart do
begin
Parent := pControls;
Left := 15;
Top := 65;
Width := 75;
Height := 25;
Caption := 'Start';
TabOrder := 2;
OnClick := @Control_Click;
end;
with pPause do
begin
Parent := pControls;
Left := 219;
Top := 65;
Width := 75;
Height := 25;
Caption := 'Pause';
TabOrder := 3;
OnClick := @Control_Click;
end;
with pStop do
begin
Parent := pControls;
Left := 403;
Top := 65;
Width := 75;
Height := 25;
Caption := 'Stop';
TabOrder := 4;
OnClick := @Control_Click;
end;
with pCoal do
begin
Parent := pControls;
Left := 403;
Top := 5;
Width := 97;
Height := 17;
Caption := 'Mine Coal';
TabOrder := 5;
OnClick := @Control_Click;
end;
with pSFS do
begin
Parent := pControls;
Left := 219;
Top := 35;
Width := 97;
Height := 17;
Caption := 'Use Fire Staff';
TabOrder := 6;
OnClick := @Control_Click;
end;
with pJIC do
begin
Parent := pControls;
Left := 403;
Top := 35;
Width := 97;
Height := 17;
Caption := 'Just In Case';
TabOrder := 7;
OnClick := @Control_Click;
end;
with pDMP do
begin
Parent := pControls;
Left := 15;
Top := 35;
Width := 121;
Height := 17;
Caption := 'Download SPS Maps';
TabOrder := 8;
OnClick := @Control_Click;
end;
with pClose do
begin
Parent := XFormGUI;
Left := 483;
Top := 0;
Width := 19;
Height := 21;
Caption := 'X';
TabOrder := 0;
ONCLICK := @Control_Click;
end;
end;
end;
procedure FormGUI_SafeInit;
var
v: TVariantArray;
begin
SetLength(v, 0);
ThreadSafeCall('FormGUI_Init', v);
end;
function FormGUI_ShowModal: Boolean;
begin
//Result := FormGUI.XFormGUI.ShowModal = mrOk;
FormGUI.XFormGUI.SHOW;
Result:= FormGUI.XFormGUI.Showing;
end;
function FormGUI_SafeShowModal: Boolean;
var
v: TVariantArray;
begin
SetLength(v, 0);
Result := ThreadSafeCall('FormGUI_ShowModal', v);
WriteINI('Changed', 'Changed', 'True', IncludePath + 'FormGUI.INI');
WriteINI('SMART', 'SMART', 'y', IncludePath + 'FormGUI.INI');
end;
Procedure FreeFormGUI;
begin
FreeForm(FormGUI.XFormGUI);
end;
begin
SetupSRL;
FormGUI_SafeInit;
FormGUI_SafeShowModal;
AddOnTerminate('FreeFormGUI');
Repeat
writeln('Gold: ' + ToStr(GoldOption));
writeln('Coal: ' + ToStr(CoalOption));
Wait(1000);
Until(False);
end.