View Full Version : FormGUI (Form on Smart) Works.. buggy though
Brandon
07-26-2011, 07:31 PM
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):
11469
11475
Simba Script!!! Yes the form works.. But I get these stupid access violation errors :c
11476
NEW:
http://i.imgur.com/LW9Rj.png
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:
http://i.imgur.com/mbsnu.png
http://i.imgur.com/kRQ6D.png
http://i.imgur.com/K1ctP.png
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):
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:
16540
Actual Form by itself:
{$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.
I was thinking of creating something like this too :)
But it kinda died :P
~Home
Brandon
07-26-2011, 08:14 PM
U see the problem in the screenshot right?? I can't move the form because there is no titlebar now which I figured out how to remove :D
Is it cuz I made the form with Scar form editor?
But I need to find a way to move the form :c Maybe at runtime a user can choose where to put it.. in the parent window aka smart.. But i still have a problem of getting user input..
Another thing is to hide the form when the debug button is pressed.. I was thinking and its not as easy as I thought :c
MylesMadness
07-26-2011, 08:31 PM
Completely offtopic: @ggzz The link in your signature is either wrong, or some joke that went over my head.
Completely offtopic: @ggzz The link in your signature is either wrong, or some joke that went over my head.
It's wrong :) Not a joke.
~Home
Brandon
07-26-2011, 08:33 PM
Completely offtopic: @ggzz The link in your signature is either wrong, or some joke that went over my head.
Opps.. it wasn't supposed to be a link.. its just everytime I put a signature.. it won't somehow turns into a link :S.. its just supposed to be plain text.. but its on powerbot and timer said it himself.
Coh3n
07-27-2011, 10:29 PM
This would be awesome if you can get it completely working. You can make plugins in any language you want as an alternative to extensions. If a plugin could be made that exports a function like "ShowSMARTForm(form: TForm);" that would be epic. As for moving the form without a title bar, you can use this (just take the procedures that are used for moving, not the safeCall stuff):
var
Form : TForm;
procedure Form_OnMouseDown(Sender : TObject; Button : TMouseButton; Shift : TShiftState; X, Y : Integer);
var
mX, mY, fX, fY, sX, sY : Integer;
begin
fX := Form.Left;
fY := Form.Top;
GetMousePos(sX, sY);
IsMouseButtonDown(Mouse_Left); // Free the buffer
case Sender of
Form:
while IsMouseButtonDown(Mouse_Left) do
begin
GetMousePos(mX, mY);
Form.Left := fX - (sX - mX);
Form.Top := fY - (sY - mY);
Wait(1);
end;
end;
end;
procedure InitForm;
begin
Form := TForm.Create(nil);
with Form do
begin
SetBounds(100, 100, 100, 100);
BorderStyle := bsNone;
OnMouseDown := @Form_OnMouseDown;
end;
end;
procedure SafeInitForm;
var
v: TVariantArray;
begin
SetArrayLength(v, 0);
ThreadSafeCall('InitForm', v);
end;
procedure ShowFormModal;
begin
Form.ShowModal;
end;
procedure SafeShowFormModal;
var
v: TVariantArray;
begin
SetArrayLength(v, 0);
ThreadSafeCall('ShowFormModal', v);
end;
begin
try
SafeInitForm;
SafeShowFormModal;
except
finally
Form.Free;
end;
end.
Zyt3x posted that on another thread.
Nava2
07-30-2011, 05:37 AM
Also, I'm pretty sure X has these functions as well, thus it could be abstracted into Linux too! :)
Dgby714
07-30-2011, 06:10 AM
pretty cool
program new;
function SetParent(Child, Parent: HWND): HWND; external 'SetParent@User32.dll stdcall';
function GetSimba(): TSysProc;
var
Arr: TSysProcArr;
I, H: LongInt;
begin
Arr := GetProcesses();
H := High(Arr);
for I := 0 to H do
if (Pos('Simba', Arr[I].Title) > 0) then
begin
Result := Arr[I];
Exit;
end;
end;
var
Form: TForm;
procedure _InitForm();
begin
Form := TForm.Create(nil);
with Form do
begin
SetParent(Handle, GetSimba().Handle);
Position := poOwnerFormCenter;
Caption := 'test';
end;
end;
procedure InitForm(); var V: TVariantArray; begin ThreadSafeCall('_InitForm', V); end;
procedure _ShowForm();
begin
Form.Show;
end;
procedure ShowForm(); var V: TVariantArray; begin ThreadSafeCall('_ShowForm', V); end;
procedure _RefreshForm();
begin
Form.Refresh;
end;
procedure RefreshForm(); var V: TVariantArray; begin ThreadSafeCall('_RefreshForm', V); end;
function _IsShowingForm(): Boolean;
begin
Result := Form.Showing;
end;
function IsShowingForm(): Boolean; var V: TVariantArray; begin Result := ThreadSafeCall('_IsShowingForm', V); end;
procedure _FreeForm();
begin
Form.Free;
end;
procedure FreeForm(); var V: TVariantArray; begin ThreadSafeCall('_FreeForm', V); end;
begin
InitForm();
try
ShowForm();
while IsShowingForm() do
begin
try
RefreshForm();
except end;
Wait(500);
end;
finally
FreeForm();
end;
end.
bevardis
08-09-2011, 10:06 AM
This is very nice.
But what about if you painted on screen and checked if those coordinates were clicked?
It would be lame for non fixed mode tho.
Brandon
08-09-2011, 01:49 PM
This is very nice.
But what about if you painted on screen and checked if those coordinates were clicked?
It would be lame for non fixed mode tho.
Cannot be done.. already tried it. Problem: The bot doesn't have threading so u'd have to program the clicks in.. meaning u'd have to make a loop for click checking and u'd have to run that loop ever so often.. by the time ur script gets to that loop, the click msg will be cleaned out of the messagequeue..
Second (Probably possible): Smart may click one of those co-ordinates and then the GUI's click msg may trigger the reaction in the script..
I haven't given up on this yet.. but I'm at the point where I just might because I can't get the form to stay and show on the screen unless I use Form.ShowModal() instead of Form.Show();
No point of Simba having Form.Show() if it doesn't even work the way it should.. shows then disappears when clicked..
Flight
08-09-2011, 03:11 PM
This would sure be nice. I think soon I'll get back to trying to make a dynamic "progress report", minus all the user-interaction, just something simple and stylish to make the script a little more attractive. (Considering how ugly SMART is...) [Maybe Ben won't mind this post]
doom0791
08-10-2011, 06:50 AM
I actually love this idea. I haven't scripted in a couple of months, but I'm willing to try to help.
I actually don't have Simba installed so I can't test any of these theories:
Form1_1.Form1_1.SetBounds(7, 345, 505, 128);
Are these the parameters for SetBounds(LLx, LLy, URx, URy):
Lower-Left-x
Lower-Left-y
Upper-Right-x
Upper-Right-y
?
If so then you should be able to adjust the SetBounds parameters to wherever you want the form to span.
As for getting rid of the title bar, I think you should remove this and the lines that point to it:
with GroupBox1 do
begin
Parent := Form1_1;
Left := 7;
Top := 8;
Width := 491;
Height := 111;
Caption := 'GUI TEST SCRIPT';
TabOrder := 0;
end;
If I remember right, the TGroupBox is just there to group form options together.
As for getting the user input I'm not entirely sure.
Coh3n
08-10-2011, 01:09 PM
SetBounds works like this:
TForm.SetBounds(left, top, width, height);
Zyt3x
08-16-2011, 11:23 AM
Why didn't I see this until now?! This is really cool!
Brandon
06-23-2012, 09:50 PM
Hey guys.. After all these years, I've figured it out. I just thought I'd bring light to my thread.
You can now have GUI's on Smart AND Change the flow of a script in real-time via the Extension I uploaded on the First post. There are some limitations though. While attached to smart, you cannot MOVE the GUI. You can minimize it and show it again, you can close it and what not but you cannot MOVE it at all or else your entire script will crash. The next thing you cannot do is interupt Simba's thread prematurely. Meaning you cannot have a button that says "Terminate Script" and actually attempt to terminate it. That will just crash it. I do not know how to implement pausing but I'm sure that it will work.
You can test it with either the Script OR via this small demonstration to show that the options change in real time without stopping/pausing your script:
{$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.
VERY nice work.
Exiting stuff Brandon! Will test later on.
Awesome job, Brandom.
+Rep
Brandon
06-24-2012, 12:46 AM
Awesome job, Brandom.
+Rep
:D I just added Virtual Multi-threading to it via TTimers so that it auto attaches to Smart when the script Starts. Works quite well. Going to make it so that I can hide and show the form. Basically right now I have two forms on Smart.. one just acts as a button and the other is teh actual control panel..
I click teh button, it hides the control panel. Click it again, it shows it. Exactly like how RSBot has those GUI's on it. Just happy that I can change script parameters and variables without actually stopping the script :)
putonajonny
06-24-2012, 12:49 AM
Great Stuff, you could have a button that says TerminateScript and really just sets all players to inactive, then as long as you have somewhere in your script Repeat Until(AllPlayersInacive); then it will end, also for pausing you could just have a RunScript boolean, which would be set to false on pausing, then just have a while(not RunScript)do Wait(200); and it will effectively pause it
Wow! I was needing this SO bad! Changing variables while the script was running, I thought it wasn't possible!
Master BAW
06-24-2012, 01:03 AM
This is very nice :D
Will try it sometime :D
Sir Ducksworthy
06-27-2012, 12:47 PM
Seriously Brandon Rep+! this is brilliant
This is amazing Brandon, Just wondering would it be possible to have multiple tabs on the form?
Brandon
07-01-2012, 01:56 PM
This is amazing Brandon, Just wondering would it be possible to have multiple tabs on the form?
Yes it is possible see:
Extension:
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', '');
Result:= Smart;
end;
Procedure SetParentSmart(Sender: TObject);
var
FormHandle, SmartHandle: HWND;
begin
FormTitleBarName:= 'FormGUI';
FormHandle:= FindWindow('', FormTitleBarName);
SmartHandle:= FindSmart;
If ((SmartHandle <> 0) and (FormHandle <> 0)) then
begin
SetParent(FormHandle, SmartHandle);
SetWindowPos(FormHandle, 0, 6, 345, 505, 128, 1);
end;
FormTitleBarName:= 'FormBTN';
FormHandle:= FindWindow('', FormTitleBarName);
If ((SmartHandle <> 0) and (FormHandle <> 0)) then
begin
SetParent(FormHandle, SmartHandle);
SetWindowPos(FormHandle, 0, 476, 324, 505, 128, 1);
end;
end;
var
Thread: TTimer;
Procedure Thread_Init;
begin
Thread:= TTimer.Create(nil);
Thread.ONTIMER:= @SetParentSmart;
Thread.INTERVAL:= 10000;
Thread.ENABLED:= True;
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);
Thread_Init;
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 ');
Writeln('# FormGUI Simba Extension #');
end;
Procedure Detach;
begin
writeln('FormGUI: GoodBye!');
end;
begin
end.
{$DEFINE SMART}
{$I SRL/SRL.Simba}
type
TFormGUI = record
FormGUI: TForm;
FormBTN: TForm;
pVisible: TButton;
pTabButton: TButton;
pControls: TGroupBox;
pControlsTab: TGroupBox;
pReports: TCheckBox;
pExcalibur: TCheckBox;
pSuperHeat: TCheckBox;
pJustInCase: TCheckBox;
pDownloadMaps: TCheckBox;
pDeveloperControls: TPanel;
pDeveloperLabel: TLabel;
pDebug: TCheckBox;
pSPSPosDebug: TCheckBox;
pAnimationDebug: TCheckBox;
pStatsUserLabel: TLabel;
pStatsPassLabel: TLabel;
pPlayerUserLabel: TLabel;
pPlayerPassLabel: TLabel;
pMethodsLabel: TLabel;
pPouchSummonLabel: TLabel;
pStatsUserEdit: TEdit;
pStatsPassEdit: TEdit;
pPlayerUserEdit: TEdit;
pPlayerPassEdit: TEdit;
pMethodsEdit: TEdit;
pPouchSummonEdit: TEdit;
pStart: TButton;
pPause: TButton;
pClose: TButton;
end;
var
XFormGUI: TFormGUI;
Procedure Form_ControlClicked(Sender: TObject);
begin
Case Sender Of
XFormGUI.pClose:
begin
XFormGUI.FormGUI.Close;
XFormGUI.pVisible.Caption := 'Show';
end;
XFormGUI.pVisible:
begin
XFormGUI.FormGUI.Visible := (Not XFormGUI.FormGUI.Visible);
if (XFormGUI.pVisible.Caption = 'Show') then
XFormGUI.pVisible.Caption := 'Hide'
else
XFormGUI.pVisible.Caption := 'Show';
end;
XFormGUI.pTabButton:
begin
XFormGUI.pControls.Visible := (Not XFormGUI.pControls.Visible);
XFormGUI.pControlsTab.Visible := (Not XFormGUI.pControlsTab.Visible);
end;
{
XFormGUI.pReports: OnScreenProggy := XFormGUI.pReports.Checked;
XFormGUI.pExcalibur: EnhancedExcalibur := XFormGUI.pExcalibur.Checked;
XFormGUI.pSuperHeat: SFS := XFormGUI.pSuperHeat.Checked;
XFormGUI.pJustInCase: JIC := XFormGUI.pJustInCase.Checked;
XFormGUI.pDownloadMaps: DMP := XFormGUI.pDownloadMaps.Checked;
XFormGUI.pDebug: Debug := XFormGUI.pDebug.Checked;
XFormGUI.pAnimationDebug: AnimationDebug := XFormGUI.pAnimationDebug.Checked;
XFormGUI.pSPSPosDebug: POSDebug := XFormGUI.pSPSPosDebug.Checked;
XFormGUI.pStatsUserEdit: SRLStats_Username := XFormGUI.pStatsUserEdit.Text;
XFormGUI.pStatsPassEdit: SRLStats_Password := XFormGUI.pStatsPassEdit.Text;
XFormGUI.pPlayerUserEdit: Players[CurrentPlayer].Name := XFormGUI.pPlayerUserEdit.Text;
XFormGUI.pPlayerPassEdit: Players[CurrentPlayer].Pass := XFormGUI.pPlayerPassEdit.Text;
}
end;
end;
procedure Form_EditControlKeyPressed(Sender: TObject; var Key: Char);
begin
{
Case Sender Of
XFormGUI.pMethodsEdit:
If (Key <> #8) and (Key <> '0') and (Key <> '1') and (Key <> '2') and (Key <> '3') and (Key <> '4') then
Key := #0
else
Method := StrToIntDef(XFormGUI.pMethodsEdit.Text, 0);
XFormGUI.pPouchSummonEdit:
If (Key <> #8) and (Key <> '0') and (Key <> '1') and (Key <> '2') then
Key := #0
else
Method := StrToIntDef(XFormGUI.pPouchSummonEdit.Text, 0);
end;
}
end;
procedure FormGUI_Init;
begin
with XFormGUI do
begin
FormGUI := CreateForm;
FormBTN := CreateForm;
pVisible := TButton.Create(FormBTN);
pTabButton := TButton.Create(FormGUI);
pControls := TGroupBox.Create(FormGUI);
pControlsTab := TGroupBox.Create(FormGUI);
pReports := TCheckBox.Create(pControls);
pExcalibur := TCheckBox.Create(pControls);
pSuperHeat := TCheckBox.Create(pControls);
pJustInCase := TCheckBox.Create(pControls);
pDownloadMaps := TCheckBox.Create(pControls);
pDeveloperControls := TPanel.Create(pControls);
pDeveloperLabel := TLabel.Create(pDeveloperControls);
pDebug := TCheckBox.Create(pDeveloperControls);
pSPSPosDebug := TCheckBox.Create(pDeveloperControls);
pAnimationDebug := TCheckBox.Create(pDeveloperControls);
pStatsUserLabel := TLabel.Create(pControlsTab);
pStatsPassLabel := TLabel.Create(pControlsTab);
pPlayerUserLabel := TLabel.Create(pControlsTab);
pPlayerPassLabel := TLabel.Create(pControlsTab);
pMethodsLabel := TLabel.Create(pControlsTab);
pPouchSummonLabel := TLabel.Create(pControlsTab);
pStatsUserEdit := TEdit.Create(pControlsTab);
pStatsPassEdit := TEdit.Create(pControlsTab);
pPlayerUserEdit := TEdit.Create(pControlsTab);
pPlayerPassEdit := TEdit.Create(pControlsTab);
pMethodsEdit := TEdit.Create(pControlsTab);
pPouchSummonEdit := TEdit.Create(pControlsTab);
pStart := TButton.Create(pControls);
pPause := TButton.Create(pControls);
pClose := TButton.Create(FormGUI);
with FormBTN do
begin
Left := 824;
Top := 175;
ActiveControl := pVisible;
BorderStyle := bsNone;
Caption := 'FormBTN';
Name := 'FormBTN';
ClientHeight := 14;
ClientWidth := 35;
Color := 15780518; //clSkyBlue;
DoubleBuffered := True;
Font.Color := clWindowText;
Font.Height := -11;
Font.Name := 'Tahoma';
Font.Style := [];
Position := poDesigned;
PixelsPerInch := 96;
end;
with pVisible do
begin
Parent := FormBTN;
Left := 0;
Top := 0;
Width := 35;
Height := 14;
Hint := 'Show/Hide';
Caption := 'Hide';
Font.Color := clBlack;
Font.Height := -11;
Font.Name := 'Courier New';
Font.Style := [fsBold];
ParentFont := False;
ParentShowHint := False;
ShowHint := True;
TabOrder := 1;
OnClick := @Form_ControlClicked;
end;
with FormGUI do
begin
Left := 376;
Top := 175;
ActiveControl := pClose;
BorderStyle := bsNone;
Caption := 'FormGUI';
ClientHeight := 128;
ClientWidth := 505;
Color := 15780518; //clSkyBlue;
DoubleBuffered := True;
Font.Color := clWindowText;
Font.Height := -11;
Font.Name := 'Tahoma';
Font.Style := [];
Position := poDesigned;
PixelsPerInch := 96;
end;
with pControls do
begin
Parent := FormGUI;
Left := 5;
Top := 1;
Width := 496;
Height := 120;
Caption := 'Control Panel';
Font.Color := clPurple;
Font.Height := -12;
Font.Name := 'Courier New';
Font.Style := [fsBold];
ParentFont := False;
ParentShowHint := False;
ShowHint := True;
TabOrder := 0;
end;
with pControlsTab do
begin
Parent := FormGUI;
Left := 5;
Top := 1;
Width := 496;
Height := 120;
Caption := 'Control Panel';
Font.Color := clPurple;
Font.Height := -12;
Font.Name := 'Courier New';
Font.Style := [fsBold];
ParentFont := False;
ParentShowHint := False;
ShowHint := True;
TabOrder := 8;
end;
with pTabButton do
begin
Parent := FormGUI;
Left := 234;
Top := 0;
Width := 75;
Height := 14;
Hint := 'Switch Tabs';
Caption := 'Switch Tab';
Font.Color := clBlack;
Font.Height := -11;
Font.Name := 'Courier New';
Font.Style := [fsBold];
ParentFont := False;
ParentShowHint := False;
ShowHint := True;
TabOrder := 2;
OnClick := @Form_ControlClicked;
end;
with pReports do
begin
Parent := pControls;
Left := 20;
Top := 4;
Width := 145;
Height := 17;
AllowGrayed := True;
Caption := 'On Screen Reports';
Hint := 'Show''s Reports On Screen';
Color := clOlive;
Font.Color := clWindowText;
Font.Height := -11;
Font.Name := 'Courier New';
Font.Style := [];
ShowHint := True;
ParentColor := False;
ParentFont := False;
TabOrder := 0;
OnClick := @Form_ControlClicked;
end;
with pExcalibur do
begin
Parent := pControls;
Left := 195;
Top := 4;
Width := 147;
Height := 17;
Caption := 'Enhanced Excalibur';
Hint := 'Uses Enhanced Excalibur To Heal';
Font.Color := clWindowText;
Font.Height := -11;
Font.Name := 'Courier New';
Font.Style := [];
ShowHint := True;
ParentFont := False;
TabOrder := 1;
OnClick := @Form_ControlClicked;
end;
with pSuperHeat do
begin
Parent := pControls;
Left := 369;
Top := 4;
Width := 117;
Height := 17;
Caption := 'SuperHeat Ores';
Hint := 'Super Heat Ores Using a Firestaff/Runes';
Font.Color := clWindowText;
Font.Height := -11;
Font.Name := 'Courier New';
Font.Style := [];
ShowHint := True;
ParentFont := False;
TabOrder := 2;
OnClick := @Form_ControlClicked;
end;
with pJustInCase do
begin
Parent := pControls;
Left := 20;
Top := 29;
Width := 137;
Height := 17;
Caption := 'Drop Ores (J.I.C)';
Hint := 'Drop Ores If Out Of Runes Or No FireStaff Found';
Font.Color := clWindowText;
Font.Height := -11;
Font.Name := 'Courier New';
Font.Style := [];
ShowHint := True;
ParentFont := False;
TabOrder := 3;
OnClick := @Form_ControlClicked;
end;
with pDownloadMaps do
begin
Parent := pControls;
Left := 195;
Top := 29;
Width := 140;
Height := 17;
Caption := 'Download SPS Maps';
Hint := 'Downloads Required SPS Maps If Not Found';
Checked := True;
Font.Color := clWindowText;
Font.Height := -11;
Font.Name := 'Courier New';
Font.Style := [];
ShowHint := True;
ParentFont := False;
TabOrder := 4;
OnClick := @Form_ControlClicked;
end;
with pDeveloperControls do
begin
Parent := pControls;
Left := 3;
Top := 52;
Width := 339;
Height := 47;
TabOrder := 5;
end;
with pDeveloperLabel do
begin
Parent := pDeveloperControls;
Left := 8;
Top := 0;
Width := 126;
Height := 16;
Caption := 'Developer Controls';
Font.Color := clMaroon;
Font.Height := -12;
Font.Name := 'Courier New';
Font.Style := [fsBold];
ParentFont := False;
end;
with pDebug do
begin
Parent := pDeveloperControls;
Left := 17;
Top := 20;
Width := 61;
Height := 17;
Caption := 'Debug';
Hint := 'Display Debug Messages';
Font.Color := clRed;
Font.Height := -11;
Font.Name := 'Courier New';
Font.Style := [];
ShowHint := True;
ParentFont := False;
TabOrder := 0;
OnClick := @Form_ControlClicked;
end;
with pSPSPosDebug do
begin
Parent := pDeveloperControls;
Left := 86;
Top := 20;
Width := 113;
Height := 17;
Caption := 'SPS-Pos Debug';
Hint := 'Debug SPS Your Position';
Font.Color := clRed;
Font.Height := -11;
Font.Name := 'Courier New';
Font.Style := [];
ShowHint := True;
ParentFont := False;
TabOrder := 1;
OnClick := @Form_ControlClicked;
end;
with pAnimationDebug do
begin
Parent := pDeveloperControls;
Left := 208;
Top := 20;
Width := 124;
Height := 17;
Caption := 'Animation Debug';
Hint := 'Debug Player Animation';
Font.Color := clRed;
Font.Height := -11;
Font.Name := 'Courier New';
Font.Style := [];
ShowHint := True;
ParentFont := False;
TabOrder := 2;
OnClick := @Form_ControlClicked;
end;
with pStatsUserLabel do
begin
Parent := pControlsTab;
Left := 18;
Top := 5;
Width := 133;
Height := 16;
Caption := 'SRL-Stats UserName:';
end;
with pStatsPassLabel do
begin
Parent := pControlsTab;
Left := 18;
Top := 53;
Width := 133;
Height := 16;
Caption := 'SRL-Stats Password:';
end;
with pPlayerUserLabel do
begin
Parent := pControlsTab;
Left := 183;
Top := 5;
Width := 112;
Height := 16;
Caption := 'Player UserName:';
end;
with pPlayerPassLabel do
begin
Parent := pControlsTab;
Left := 183;
Top := 53;
Width := 112;
Height := 16;
Caption := 'Player Password:';
end;
with pMethodsLabel do
begin
Parent := pControlsTab;
Left := 344;
Top := 5;
Width := 112;
Height := 16;
Caption := 'Mining Method:';
end;
with pPouchSummonLabel do
begin
Parent := pControlsTab;
Left := 344;
Top := 53;
Width := 112;
Height := 16;
Caption := 'Pouch To Summon:';
end;
with pStatsUserEdit do
begin
Parent := pControlsTab;
Left := 18;
Top := 21;
Width := 133;
Height := 20;
PasswordChar := '*';
Font.Color := clWindowText;
TabOrder := 0;
OnChange := @Form_ControlClicked;
end;
with pStatsPassEdit do
begin
Parent := pControlsTab;
Left := 18;
Top := 68;
Width := 133;
Height := 20;
PasswordChar := '*';
Font.Color := clWindowText;
TabOrder := 1;
OnChange := @Form_ControlClicked;
end;
with pPlayerUserEdit do
begin
Parent := pControlsTab;
Left := 183;
Top := 21;
Width := 133;
Height := 20;
PasswordChar := '*';
Font.Color := clWindowText;
TabOrder := 2;
OnChange := @Form_ControlClicked;
end;
with pPlayerPassEdit do
begin
Parent := pControlsTab;
Left := 183;
Top := 68;
Width := 133;
Height := 20;
PasswordChar := '*';
Font.Color := clWindowText;
TabOrder := 3;
OnChange := @Form_ControlClicked;
end;
with pMethodsEdit do
begin
Parent := pControlsTab;
Left := 344;
Top := 21;
Width := 133;
Font.Color := clWindowText;
TabOrder := 4;
OnKeyPress := @Form_EditControlKeyPressed;
end;
with pPouchSummonEdit do
begin
Parent := pControlsTab;
Left := 344;
Top := 68;
Width := 133;
Height := 20;
Font.Color := clWindowText;
TabOrder := 5;
OnKeyPress := @Form_EditControlKeyPressed;
end;
with pStart do
begin
Parent := pControls;
Left := 350;
Top := 63;
Width := 59;
Height := 25;
Caption := 'Start';
Hint := 'Continue/UnPause The Script';
ShowHint := True;
TabOrder := 6;
end;
with pPause do
begin
Parent := pControls;
Left := 425;
Top := 63;
Width := 59;
Height := 25;
Caption := 'Pause';
Hint := 'Pauses The Script';
ShowHint := True;
TabOrder := 7;
end;
with pClose do
begin
Parent := FormGUI;
Left := 482;
Top := 0;
Width := 23;
Height := 21;
Hint := 'Close';
Caption := 'X';
Font.Color := clBlack;
Font.Height := -11;
Font.Name := 'Courier New';
Font.Style := [fsBold];
ParentFont := False;
ParentShowHint := False;
ShowHint := True;
TabOrder := 1;
OnClick := @Form_ControlClicked;
end;
end;
end;
procedure FormGUI_SafeInit;
var
v: TVariantArray;
begin
SetLength(v, 0);
ThreadSafeCall('FormGUI_Init', v);
end;
function FormGUI_Show: Boolean;
begin
//Result := XFormGUI.FormGUI.ShowModal = mrOk;
XFormGUI.FormGUI.Show;
XFormGUI.FormBTN.Show;
XFormGUI.pControlsTab.Visible := False;
Result:= XFormGUI.FormGUI.Showing and XFormGUI.FormBTN.Showing;
end;
function FormGUI_SafeShow: Boolean;
var
v: TVariantArray;
begin
SetLength(v, 0);
Result := ThreadSafeCall('FormGUI_Show', v);
end;
Procedure FreeFormGUI;
begin
FreeForm(XFormGUI.FormGUI);
FreeForm(XFormGUI.FormBTN);
end;
begin
Smart_Server:= 72;
Smart_Members:= True;
Smart_Signed:= True;
Smart_SuperDetail:= True;
SetupSRL;
FormGUI_SafeInit;
FormGUI_SafeShow;
AddOnTerminate('FreeFormGUI');
Wait(25000);
end.
How do you get it on smart? mine always spawns on simba?
Shatterhand
01-17-2013, 08:58 PM
Brandon you still working on this? Tested it but it doesnt show up on smart.
Smart:= FindWindow('SunAwtFrame', 'Public SMARTv6.9 - SMART Minimizing Autoing Resource Thing - By BenLand100');
result:= Smart;
What window it looks for... I tried adding mine and it didnt find it im pretty sure if Brandon picks this back up he knows more advanced ways of targeting a window now :p
Brandon Any chance you'll make this into a plugin?
Brandon
08-16-2014, 04:01 PM
Brandon Any chance you'll make this into a plugin?
I never realised anyone was replying to this thread.. Uh I would but it'd only work for PascalScript afaik. IIRC, Lape doesn't support forms. Unless something changed that I don't know about, PS would be the only way.
And yeah, there are much better ways to attach it to SMART now. Especially now that SMART has its own plugin system!
Powered by vBulletin® Version 4.2.1 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.