How to make a struct? |
Author: |
Message: |
-=blu3+3y3s=-
New Member
Posts: 3
Joined: Jul 2006
|
O.P. How to make a struct?
Hi, all!
I need to make Point and Rect structs for using GetWindowRect and GetCursorPos of user32.dll.
I try this:
code: struct Point
{
long x;
long y;
}
but when I apply, MsgPlus says me "Couldn't start script".
|
|
07-31-2006 08:51 PM |
|
|
Ezra
Veteran Member
Forgiveness is between them and God
Posts: 1960 Reputation: 31
37 / /
Joined: Mar 2003
|
RE: How to make a struct?
If I understand what you mean this is want you want
function Point()
{
this.x;
this.y;
}
mypointobj = new Point();
This post was edited on 07-31-2006 at 08:55 PM by Ezra.
|
|
07-31-2006 08:54 PM |
|
|
-=blu3+3y3s=-
New Member
Posts: 3
Joined: Jul 2006
|
O.P. RE: How to make a struct?
I tried what you said but WLM bugges now when I launch the script.
I do this:
code: Interop.Call("user32.dll", "GetCursorPos", mypointobj);
MsgPlus.DisplayToast("Result", mypointobj.x + " - " + mypointobj.y);
How I can do to display the result?
This post was edited on 07-31-2006 at 09:19 PM by -=blu3+3y3s=-.
|
|
07-31-2006 09:19 PM |
|
|
Ezra
Veteran Member
Forgiveness is between them and God
Posts: 1960 Reputation: 31
37 / /
Joined: Mar 2003
|
RE: How to make a struct?
Hmm, I guess you'll have to do that another way.
Here is some code that I think would help you
Color Picker Made By Matty:
code: //Show color picker common dialog (Made By Matty);
//Create our CHOOSECOLOR data block
var CHOOSECOLOR = Interop.Allocate(36);
CHOOSECOLOR.WriteDWORD(0, 36); //DWORD lStructSize
CHOOSECOLOR.WriteDWORD(4, 0); //HWND hwndOwner
CHOOSECOLOR.WriteDWORD(8, 0); //HWND hInstance
CHOOSECOLOR.WriteDWORD(12, 0x000000FF); //COLORREF rgbResult (COLORREF = 0x00bbggrr)
var CustColors = Interop.Allocate(64); //Create an array of 16 COLORREFs for CustColors
CHOOSECOLOR.WriteDWORD(16, CustColors.DataPtr); //COLORREF *lpCustColors (pointer to our array)
CHOOSECOLOR.WriteDWORD(20, 3); //DWORD Flags (3 = 2 (CC_FULLOPEN) + 1 (CC_RGBINIT) )
CHOOSECOLOR.WriteDWORD(24, 0); //LPARAM lCustData
CHOOSECOLOR.WriteDWORD(28, 0); //LPCCHOOKPROC lpfnHook
CHOOSECOLOR.WriteDWORD(32, 0); //LPCTSTR lpTemplateName
//Open the dialog box
var result = Interop.Call('comdlg32.dll', 'ChooseColorA', CHOOSECOLOR);
//If the user pressed ok convert it to hex
if(result == 1){
//Get decimal values
var r = CHOOSECOLOR.ReadDWORD(12) & 0xFF;
var g = (CHOOSECOLOR.ReadDWORD(12) / 0x100) & 0xFF;
var b = (CHOOSECOLOR.ReadDWORD(12) / 0x10000) & 0xFF;
Debug.Trace('RGB: ' + r + ',' + g + ',' + b)
//Get hex values
var hexchars="0123456789ABCDEF";
var r = hexchars.charAt((r >> 4) & 0xf) + hexchars.charAt(r & 0xF);
var g = hexchars.charAt((g >> 4) & 0xf) + hexchars.charAt(g & 0xF);
var b = hexchars.charAt((b >> 4) & 0xf) + hexchars.charAt(b & 0xF);
Debug.Trace('HEX: ' + r + g + b);
}
|
|
07-31-2006 09:25 PM |
|
|
-dt-
Scripting Contest Winner
;o
Posts: 1819 Reputation: 74
36 / /
Joined: Mar 2004
|
RE: How to make a struct?
right well you people dont know what you're talking about you have to recreate the structure in memory and read it from memory, here you dont need to create the structure since it will be passed into point for you by GetCursorPos
code:
var point = Interop.Allocate(8);
Interop.Call("user32.dll", "GetCursorPos", point);
Debug.Trace("x: " + point.ReadDWORD(0));
Debug.Trace("y: " + point.ReadDWORD(4));
This post was edited on 08-01-2006 at 12:05 AM by -dt-.
Happy Birthday, WDZ
|
|
08-01-2006 12:00 AM |
|
|
Eljay
Elite Member
:O
Posts: 2949 Reputation: 77
– / / –
Joined: May 2004
|
RE: How to make a struct?
quote: Originally posted by Ezra
Hmm, I guess you'll have to do that another way.
Here is some code that I think would help you
Color Picker Made By Matty:
code: //Show color picker common dialog (Made By Matty);
//Create our CHOOSECOLOR data block
var CHOOSECOLOR = Interop.Allocate(36);
CHOOSECOLOR.WriteDWORD(0, 36); //DWORD lStructSize
CHOOSECOLOR.WriteDWORD(4, 0); //HWND hwndOwner
CHOOSECOLOR.WriteDWORD(8, 0); //HWND hInstance
CHOOSECOLOR.WriteDWORD(12, 0x000000FF); //COLORREF rgbResult (COLORREF = 0x00bbggrr)
var CustColors = Interop.Allocate(64); //Create an array of 16 COLORREFs for CustColors
CHOOSECOLOR.WriteDWORD(16, CustColors.DataPtr); //COLORREF *lpCustColors (pointer to our array)
CHOOSECOLOR.WriteDWORD(20, 3); //DWORD Flags (3 = 2 (CC_FULLOPEN) + 1 (CC_RGBINIT) )
CHOOSECOLOR.WriteDWORD(24, 0); //LPARAM lCustData
CHOOSECOLOR.WriteDWORD(28, 0); //LPCCHOOKPROC lpfnHook
CHOOSECOLOR.WriteDWORD(32, 0); //LPCTSTR lpTemplateName
//Open the dialog box
var result = Interop.Call('comdlg32.dll', 'ChooseColorA', CHOOSECOLOR);
//If the user pressed ok convert it to hex
if(result == 1){
//Get decimal values
var r = CHOOSECOLOR.ReadDWORD(12) & 0xFF;
var g = (CHOOSECOLOR.ReadDWORD(12) / 0x100) & 0xFF;
var b = (CHOOSECOLOR.ReadDWORD(12) / 0x10000) & 0xFF;
Debug.Trace('RGB: ' + r + ',' + g + ',' + b)
//Get hex values
var hexchars="0123456789ABCDEF";
var r = hexchars.charAt((r >> 4) & 0xf) + hexchars.charAt(r & 0xF);
var g = hexchars.charAt((g >> 4) & 0xf) + hexchars.charAt(g & 0xF);
var b = hexchars.charAt((b >> 4) & 0xf) + hexchars.charAt(b & 0xF);
Debug.Trace('HEX: ' + r + g + b);
}
wtf thats not by matty, i made that
|
|
08-01-2006 07:30 AM |
|
|
Ezra
Veteran Member
Forgiveness is between them and God
Posts: 1960 Reputation: 31
37 / /
Joined: Mar 2003
|
RE: How to make a struct?
quote: Originally posted by eljelly
quote: Originally posted by Ezra
Hmm, I guess you'll have to do that another way.
Here is some code that I think would help you
Color Picker Made By Matty:
code: //Show color picker common dialog (Made By Matty);
//Create our CHOOSECOLOR data block
var CHOOSECOLOR = Interop.Allocate(36);
CHOOSECOLOR.WriteDWORD(0, 36); //DWORD lStructSize
CHOOSECOLOR.WriteDWORD(4, 0); //HWND hwndOwner
CHOOSECOLOR.WriteDWORD(8, 0); //HWND hInstance
CHOOSECOLOR.WriteDWORD(12, 0x000000FF); //COLORREF rgbResult (COLORREF = 0x00bbggrr)
var CustColors = Interop.Allocate(64); //Create an array of 16 COLORREFs for CustColors
CHOOSECOLOR.WriteDWORD(16, CustColors.DataPtr); //COLORREF *lpCustColors (pointer to our array)
CHOOSECOLOR.WriteDWORD(20, 3); //DWORD Flags (3 = 2 (CC_FULLOPEN) + 1 (CC_RGBINIT) )
CHOOSECOLOR.WriteDWORD(24, 0); //LPARAM lCustData
CHOOSECOLOR.WriteDWORD(28, 0); //LPCCHOOKPROC lpfnHook
CHOOSECOLOR.WriteDWORD(32, 0); //LPCTSTR lpTemplateName
//Open the dialog box
var result = Interop.Call('comdlg32.dll', 'ChooseColorA', CHOOSECOLOR);
//If the user pressed ok convert it to hex
if(result == 1){
//Get decimal values
var r = CHOOSECOLOR.ReadDWORD(12) & 0xFF;
var g = (CHOOSECOLOR.ReadDWORD(12) / 0x100) & 0xFF;
var b = (CHOOSECOLOR.ReadDWORD(12) / 0x10000) & 0xFF;
Debug.Trace('RGB: ' + r + ',' + g + ',' + b)
//Get hex values
var hexchars="0123456789ABCDEF";
var r = hexchars.charAt((r >> 4) & 0xf) + hexchars.charAt(r & 0xF);
var g = hexchars.charAt((g >> 4) & 0xf) + hexchars.charAt(g & 0xF);
var b = hexchars.charAt((b >> 4) & 0xf) + hexchars.charAt(b & 0xF);
Debug.Trace('HEX: ' + r + g + b);
}
wtf thats not by matty, i made that
OMG , sorry
|
|
08-01-2006 09:05 AM |
|
|
-=blu3+3y3s=-
New Member
Posts: 3
Joined: Jul 2006
|
O.P. RE: How to make a struct?
Thanks, guys for your answers. That works perfectly.
|
|
08-01-2006 06:17 PM |
|
|
|
|