SRL Archive - S.M.A.R.T.

Get SMART window size/position?


Bixby Sayz

2012-11-11 12:46:28

Trying to figure out how to get the size/position of the currently paired SMART client.

Brandon

2012-11-11 12:48:52

GetClientDimensions(W, H).

Bixby Sayz

2012-11-11 17:57:09

From: Brandon
GetClientDimensions(W, H).
That gives the dimensions. It does not give me the position of the window on the desktop. I could search for the SMART window by title, but if there are more than one open this is error prone.

Brandon

2012-11-11 20:37:18

From: Bixby Sayz
That gives the dimensions. It does not give me the position of the window on the desktop. I could search for the SMART window by title, but if there are more than one open this is error prone.



Hmm so why does a person need such a thing?

This is a lot of work to go through for just dimensions.. I'd probably edit Smart and add an export to do this if I were you.

var
Thread: TTimer;
SimbaMenu, Sub: TMenuItem;

Function FindWindow(ClassName, WindowName: PChar): HWND; External 'FindWindowA@User32.dll';
Function GetWindowRect(WindowHandle: HWND; var Rect: TBox): Boolean; External 'GetWindowRect@User32.dll';

Function FindSmart(SmartPID: String): HWND;
var
Data: PChar;
Begin
Data := 'SMARTv8.0 - SMART Minimizing Autoing Resource Thing - By BenLand100 [' + SmartPID + ']';
Result := FindWindow('SunAwtFrame', Data);
End;

Procedure GetSmartDimensions;
var
Rect: TBox;
SmartPID: String;
Begin
SmartPID := ReadINI('Changed', 'Changed', IncludePath + 'SmartPosition.INI');
GetWindowRect(FindSmart(SmartPID), Rect);
WriteINI('Changed', 'Changed', ToStr(Rect), IncludePath + 'SmartPosition.INI');
End;

Procedure Thread_Init;
begin
Thread:= TTimer.Create(nil);
Thread.ONTIMER:= @GetSmartDimensions;
Thread.INTERVAL:= 1000;
Thread.ENABLED:= True;
end;

procedure Init;
begin
SimbaMenu := TMenuItem.Create(Simba_MainMenu);
SimbaMenu.Caption := 'SmartPosition';
Simba_MainMenu.Items.Add(SimbaMenu);
Sub := TMenuItem.Create(SimbaMenu);
Sub.Caption := 'SmartPosition';
Sub.ShortCut := 123;
Sub.OnClick := @PositionCall;
SimbaMenu.Add(FormGUI);
Thread_Init;
end;

function GetName : string;
begin;
result := 'SmartPosition';
end;

function GetVersion : string;
begin;
result := '1.0';
end;

procedure Free;
begin

end;

procedure Attach;
begin
end;

Procedure Detach;
begin
end;

begin
end.

Procedure SmartPID;
var
BoxInfo: String;
Begin
WriteINI('Changed', 'Changed', ToStr(SmartCurrentID), IncludePath + 'SmartPosition.INI');
Wait(1000);
BoxInfo := ReadINI('Changed', 'Changed', IncludePath + 'SmartPosition.INI');
End;

begin
end.

Bixby Sayz

2012-11-11 21:14:42

What could work. Thanks.

Was trying to workaround the inability to read from the client in certain modes simply using the built-in tools. Have it working *except* for with SMART. So was trying to come up with something clever to work with SMART.

Brandon

2012-11-11 21:30:51

From: Bixby Sayz
What could work. Thanks.

Was trying to workaround the inability to read from the client in certain modes simply using the built-in tools. Have it working *except* for with SMART. So was trying to come up with something clever to work with SMART.


Smart can work in all modes.. Well specifically GL and Safemode. I have not tried the others but I heard they do indeed work.

I'm not sure how getting the client position would help you in any way.

BenLand100

2012-11-21 10:53:59

From: Bixby Sayz
That gives the dimensions. It does not give me the position of the window on the desktop. I could search for the SMART window by title, but if there are more than one open this is error prone.


The title has the pairing process ID in it, which is the same as the ID of the client you're currently paired to, so searching for the window title will indeed work.

E: I see that's what Brandon did. Disregard :3