PDA

View Full Version : The "Ex" Plugins


Centauri Soldier
06-30-2009, 05:02 PM
Now that reteset has released his plugin creator I'm sure we all have code itching to be compiled into plugins.

This topic is specifically regarding all of our Ex addition to AMS. ListBoxEx, ParagraphEx etc. It is likely that many of us have developed many different additional function for the standard objects and will share them with others. Since these Ex scripts are so common I thought it might be good for us all (who have made any Ex scripts) to post them here and when we have everyone's scripts, a few of us can edit and compile all of them (the useful bits) into one Ex plugin for each object represented instead of us each releasing our own Ex plugin version. I have a TeamSpeak server if, at the end, the compilers need to communicate.

ComboBoxEx


ComboBoxEx = {};

function ComboBoxEx.Clear(AFcombobox)

for AFx = 1, ComboBox.GetCount(AFcombobox) do

ComboBox.DeleteItem(AFcombobox, 1);

end

end



function ComboBoxEx.EnsureSelection(AFcomboboxobject)

--ensure an item is selected...if not exit the script
local itemselected = ComboBox.GetSelected(AFcomboboxobject);

--if no item is selected then exit the current script
if itemselected == nil then
Application.ExitScript();
end

--end function
end


function ComboBoxEx.GetSelectedItemText(AFcomboboxobject)

--get the selected listbox item
local AFitemindex = ComboBox.GetSelected(AFcomboboxobject);

--ensure an item has been selected
if AFitemindex ~= nil then

--get the text associated with the selected item
AFnewitemdata = ComboBox.GetItemData(AFcomboboxobject, AFitemindex);

return AFnewitemdata;

end

--end function
end


function ComboBoxEx.GetSelectedItemText(AFcomboboxobject)

--get the selected listbox item
local AFitemindex = ComboBox.GetSelected(AFcomboboxobject);

--ensure an item has been selected
if AFitemindex ~= nil then

--get the text associated with the selected item
AFnewitemtext = ComboBox.GetItemText(AFcomboboxobject, AFitemindex);

return AFnewitemtext;

end

--end function
end


FolderEx


FolderEx = {};
--======================>>>>>>>>>>>>>>>>>>>>>>
function FolderEx.Clear(sAFFolderName) --[[>>
<< >>
<< >>
<<<<<<<<<<<<<<<<<<<<<=====================--]]
Folder.DeleteTree(sAFFolderName, nil);
Folder.Create(sAFFolderName);
-->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
end--|||||||||||||END FUNCTION|||||||||||||||||
-->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>


--THIS IS SOMEONE ELSE'S CODE
--======================>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
function FolderEx.Copy(sSource, sDestination, bShowStatus) --[[>>
<< >>
<< >>
<<<<<<<<<<<<<<<<<<<<<===============================================--]]
--Enter global declarations and functions here...

local m_sFolder;
local m_FoundFolder;
local error;

--Find all the folders and sub-Folders
--results are stored in the table m_tblFolders
m_tblFolders = Folder.Find(sSource, "*", true, nil);

--if our destination folder does not have the
--backslash as the last character, add it
if String.Right(sDestination, 1) ~= "\\" then
sDestination = sDestination .. "\\";
end

--m_tblFolders will be nil if there are no folders
if m_tblFolders ~= nil then
--enumerate through the found folders
for n, m_FoundFolder in m_tblFolders do
--replace the source's path with the destination's path
m_sFolder = String.Replace(m_FoundFolder, sSource, sDestination, false);
--create the folder
Folder.Create(m_sFolder);
error = Application.GetLastError();
if (error ~= 0) then
--set n to value to exit FOR loop
n = Table.Count(m_tblFolders)
end
end
end

--if no errors occurred, copy the files
if (error == 0) then

if bShowStatus == true then
--show the status dialog
StatusDlg.Show(MB_ICONNONE, false);
end

--copy all files from the source folder, with recurse.
File.Copy(sSource .. "\\*.*", sDestination, true, true, false, true, nil);

if bShowStatus == true then
--hide the status dialog
StatusDlg.Hide();
end

error = Application.GetLastError();
end

--clean up
m_tblFolders = nil;
return error;
-->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
end--|||||||||||||END FUNCTION|||||||||||||||||
-->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>


--by RizlaUK

function FolderEx.GetParent(strPath)
local sRet=""
if Folder.DoesExist(strPath) then
local sBase=String.Mid(strPath, String.ReverseFind(strPath, "\\") + 1, -1);
local sParent = String.Replace(strPath, "\\"..sBase, "", false);
sRet=sParent
end
return sRet
end


Well that's a sample of some of the code I have built as well as some code I've got from some other people on the forums. If this idea works out I'll post the rest of mine.

MicroByte
07-01-2009, 05:37 AM
i see no reason to why this could not work, if someone is willing to take on the task then fine, although i think its a good idea, im not sure how AMS will respond to having different action tables in a single xml file, i know it can handle 2 or 3 sets of actions but that's as far as iv ever gone, also, wouldn't the action editor list just be too big.

i guess users would (a=use the plugin, b=dont use the plugin), its still a worth while venture.

MenuEx (not sure where this came from)

MenuEX={}

local function AdjustSubMenuProperties(tSubMenu, tItemProperties)
for nIndex, tItem in tSubMenu do
if tItem.ID == tItemProperties.ID then
for sKey, vValue in tItem do
if tItemProperties[sKey] == nil then
tItemProperties[sKey] = vValue;
end
end
tSubMenu[nIndex] = tItemProperties;
break;
elseif type(tItem.SubMenu) == 'table' and tItem.ID == -1 then
tSubMenu[nIndex].SubMenu = AdjustSubMenuProperties(tSubMenu[nIndex].SubMenu, tItemProperties);
end
end
return tSubMenu;
end

--
function MenuEX.SetChecked(nID, bChecked)
tMenu = Application.GetMenu();
tMenu = AdjustSubMenuProperties(tMenu, {ID=nID, Checked=bChecked});
Application.SetMenu(tMenu);
end

function MenuEX.SetEnabled(nID, bEnabled)
tMenu = Application.GetMenu();
tMenu = AdjustSubMenuProperties(tMenu, {ID=nID, Enabled=bEnabled});
Application.SetMenu(tMenu);
end

function MenuEX.SetText(nID, sText)
tMenu = Application.GetMenu();
tMenu = AdjustSubMenuProperties(tMenu, {ID=nID, Text=sText});
Application.SetMenu(tMenu);
end

function MenuEX.SetIconID(nID, nIconID)
tMenu = Application.GetMenu();
tMenu = AdjustSubMenuProperties(tMenu, {ID=nID, IconID=nIconID});
Application.SetMenu(tMenu);
end

TaskBarEX
TaskBarEX={}

function TaskBarEX.GetSize()
local hTrayWnd = DLL.CallFunction(_SystemFolder.."\\User32.dll", "FindWindowA", "\"Shell_trayWnd\",\"\"", DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL)
return Window.GetSize(hTrayWnd)
end

function TaskBarEX.GetPos()
local hTrayWnd = DLL.CallFunction(_SystemFolder.."\\User32.dll", "FindWindowA", "\"Shell_trayWnd\",\"\"", DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL)
return Window.GetPos(hTrayWnd)
end


--Test
--Dialog.Message("Notice", "Taskbar Size: "..GetTaskBarSize().Width.." x "..GetTaskBarSize().Height);
--Dialog.Message("Notice", "Taskbar Pos: "..GetTaskBarPos().X.." x "..GetTaskBarPos().Y);

ListBoxEX
ListBoxEX={}

-- gets a listbox items data
function ListBoxEX.GetItemData(sObject)
local tbSel = ListBox.GetSelected(sObject);
if tbSel then
return ListBox.GetItemData(sObject, tbSel[1]);
else
return ""
end
end

-- gets a listbox items text
function ListBoxEX.GetItemText(sObject)
local tbSel = ListBox.GetSelected(sObject);
if tbSel then
return ListBox.GetItemText(sObject, tbSel[1]);
else
return ""
end
end

-- sets a listbox items data
function ListBoxEX.SetItemData(sObject,sData)
local tbSel = ListBox.GetSelected(sObject);
if tbSel then
ListBox.SetItemData(sObject, tbSel[1], sData);
local err = Application.GetLastError();
if err == 0 then
return 0
else
return -1
end
else
return -1
end
end

-- sets a listbox items text
function ListBoxEX.SetItemText(sObject,sText)
local tbSel = ListBox.GetSelected(sObject);
if tbSel then
ListBox.SetItemText(sObject, tbSel[1], sText);
local err = Application.GetLastError();
if err == 0 then
return 0;
else
return -1;
end
else
return -1;
end
end

-- returns a tabel of a listbox items
function ListBoxEX.GetData(sObject)
local tbTmp={}
local nCount = ListBox.GetCount(sObject);
if nCount > 0 then
for i=1, nCount do
local nIndex = Table.Count(tbTmp) + 1;
Table.Insert(tbTmp, nIndex, {})
tbTmp[nIndex].Text = ListBox.GetItemText(sObject,i);
tbTmp[nIndex].Data = ListBox.GetItemData(sObject,i);
end
return tbTmp
end
end

-- returns a tabel of a listbox items
function ListBoxEX.SetData(sObject,tbTable)
if Table.Count(tbTable) > 0 then
for i,k in tbTable do
ListBox.AddItem(sObject, tbTable[i].Text, tbTable[i].Data);
end
end
end


InputEX


InputEX={}

function InputEX.SetWordWrap(sObject,bWrap)
Input.SetProperties(sObject,{HScrollbar = bWrap});
return Application.GetLastError();
end

function InputEX.GetWordWrap(sObject)
return Input.GetProperties(sObject).HScrollbar;
end

function InputEX.SaveToFile(sObject,sFile,bAppend)
local sText = Input.GetText(sObject);
TextFile.WriteFromString(sFile, sText, bAppend);
return Application.GetLastError();
end

function InputEX.LoadFromFile(sObject,sFile)
local sText = TextFile.ReadToString(sFile);
Input.SetText(sObject,sText);
return Application.GetLastError();
end

function InputEX.AlignText(sObject,cAlign)
Input.SetProperties(sObject,{Alignment = cAlign});
return Application.GetLastError();
end

function InputEX.SetFont(sObject,sFontName.nFontSize,bFontW eight,bFontItalic,bFontStrikeout,bFontUnderline,nF ontColor)
local tbFont={}
tbFont.FontName=sFontName
tbFont.FontSize=nFontSize
tbFont.FontWeight=bFontWeight
tbFont.FontItalic=bFontItalic
tbFont.FontStrikeout=bFontStrikeout
tbFont.FontUnderline=bFontUnderline
tbFont.FontColor=nFontColor
Input.SetProperties(sObject, tbFont);
return Application.GetLastError();
end

function InputEX.GetFont(sObject)
local tbFont=Input.GetProperties(sObject);
local tbRet={}
tbFont.FontName=tbRet.FontName
tbFont.FontSize=tbRet.FontSize
tbFont.FontWeight=tbRet.FontWeight
tbFont.FontItalic=tbRet.FontItalic
tbFont.FontStrikeout=tbRet.FontStrikeout
tbFont.FontUnderline=tbRet.FontUnderline
tbFont.FontColor=tbRet.FontColor
return tbRet
end

SystemEX
SystemEX={}

function SystemEX.ProcessIdleTasks(bWaitForReturn)
return File.Run(_SystemFolder.."\\rundll32.exe", "advapi32.dll,ProcessIdleTasks", "", SW_SHOWNORMAL, bWaitForReturn);



end

-- wow, need more functions

Dermot
07-01-2009, 10:23 AM
Bad idea in my opinion. These joint venture projects never work. They have been tried over and over and nothing comes of them. Even if it was created, who would keep it updated when someone makes changes to their contribution. Plus it would be one big messy table.

By the way there is already a ListBoxEx object plugin, so you are going to have to be very carefull. Lets not get carried away with this plugin compiler. Creating a plugin to clear the contents of a combobox is just crazy when I can do it with one simple action.

This is bad:
function ComboBoxEx.EnsureSelection(AFcomboboxobject)

--ensure an item is selected...if not exit the script
local itemselected = ComboBox.GetSelected(AFcomboboxobject);

--if no item is selected then exit the current script
if itemselected == nil then
Application.ExitScript();
end

--end function
end
It should return true or false and not just exit script, that way you can decide what to do, like popup a message telling the user to select an item or what ever. The caller should decide what to do based on the outcome.

Some of these are definitely useful, especially the Input and Taskbar ones. I think they should be kept as separate plugins named appropriately. That way people can use what they need. If you create a plugin, release it and let people decide if they want to use it or not.

That's my opinion.

ShadowUK
07-01-2009, 10:45 AM
This is a great idea and I fully condone it, It will work.

Creating a plugin to clear the contents of a combobox is just crazy when I can do it with one simple action.

Go you, some of us can't.

These joint venture projects never work. They have been tried over and over and nothing comes of them.

What do you mean, People just posted above. Something came from it..

Dermot
07-01-2009, 10:58 AM
This is a great idea and I fully condone it, It will work.

Go you, some of us can't.

ComboBox.ResetContent("YourComboBox")

What do you mean, People just posted above. Something came from it..
Talking about them is as far as they ever go, that's what I mean.

Dermot
07-01-2009, 11:07 AM
Plus if people start creating some useful plugins, they can release them right away and people can start using them if they need them, instead of waiting for some monster plugin that contains everyones. People can pick and choose what they want. If someone updates their plugin, they can post the new version and people can download it. Instead of waiting for someone else to update the monster plugin with their changes. Then there is the issue of bugs and mistakes.

MicroByte
07-01-2009, 01:06 PM
you know, Dermot does have some very good points.

either way i will make and release my own plugins.

Imagine Programming
07-01-2009, 02:12 PM
Dermot does have good points, nice thinking though guys :)

Centauri Soldier
07-02-2009, 12:23 AM
Yes, Dermot does make some good points; However Dermot, I think you may have missed what I was trying to say. If we work together to make a single Ex plugin we can minimize the amount of Ex plugins out there and keep the confusion and clutter to a minimum. I am not suggesting that all Ex functions be ported to s single plugin, I am saying that it may be more convenient for all of us to combine our Ex functions into various Ex plugins. So now we would have ListBoxEx, ComboBoxEx, ApplicationEx etc. If someone did want a single plugin though we could make that too.

As to your comments regarding my combobox code, I think that kind of input is excellent...don't look now but you were just contributing to the project by offering criticism of the code.

Don't let the naysayers get you down folks, they don't mean anything by it...just keep posting and most of the work will be done. When we have enough for a complete Ex plugin, it gets compiled...easy peezy.

ShadowUK
07-02-2009, 08:47 AM
Yes, Dermot does make some good points; However Dermot, I think you may have missed what I was trying to say. If we work together to make a single Ex plugin we can minimize the amount of Ex plugins out there and keep the confusion and clutter to a minimum. I am not suggesting that all Ex functions be ported to s single plugin, I am saying that it may be more convenient for all of us to combine our Ex functions into various Ex plugins. So now we would have ListBoxEx, ComboBoxEx, ApplicationEx etc. If someone did want a single plugin though we could make that too.

As to your comments regarding my combobox code, I think that kind of input is excellent...don't look now but you were just contributing to the project by offering criticism of the code.

Don't let the naysayers get you down folks, they don't mean anything by it...just keep posting and most of the work will be done. When we have enough for a complete Ex plugin, it gets compiled...easy peezy.

Need a subversion repository? It would be an efficient way of getting new versions to people. I can set one up on svn.shadiku.com. :P

Worm
07-02-2009, 10:22 AM
also, having to walk my way down through a bunch of actions I don't want to get to the needed action doesn't sound appealing.

Does anyone else find it humorous that one of the complaints I hear most about AMS is that the EXE is too big, and here talking about making the mother of all plugins. Load what you need, leave the rest on the disk I say.

my 2 pennies

Centauri Soldier
07-02-2009, 12:19 PM
That sounds good Shadow. I'm in.

also, having to walk my way down through a bunch of actions I don't want to get to the needed action doesn't sound appealing.

Does anyone else find it humorous that one of the complaints I hear most about AMS is that the EXE is too big, and here talking about making the mother of all plugins. Load what you need, leave the rest on the disk I say.

my 2 pennies

Please read below...

...I am not suggesting that all Ex functions be ported to s single plugin, I am saying that it may be more convenient for all of us to combine our Ex functions into various Ex plugins. So now we would have ListBoxEx, ComboBoxEx, ApplicationEx etc...

Imagine Programming
07-02-2009, 12:38 PM
also, having to walk my way down through a bunch of actions I don't want to get to the needed action doesn't sound appealing.

Does anyone else find it humorous that one of the complaints I hear most about AMS is that the EXE is too big, and here talking about making the mother of all plugins. Load what you need, leave the rest on the disk I say.

my 2 pennies

I actually agree with Worm here, why not share the sources and let people copypaste the functions they need? It's nice to have them as plugin for easy including the functions but I don't see much other benefits.

MicroByte
07-02-2009, 03:42 PM
also, having to walk my way down through a bunch of actions I don't want to get to the needed action doesn't sound appealing.

sounds a bit like the grid, lol

...I am not suggesting that all Ex functions be ported to s single plugin, I am saying that it may be more convenient for all of us to combine our Ex functions into various Ex plugins. So now we would have ListBoxEx, ComboBoxEx, ApplicationEx etc...

so, you mean,(now correct me if im wrong here) i make say "InputEx" and you have a bunch of functions you think would improve "InputEx", so you post the functions and i add them to the plugin and re-release it ?

if so, then that sounds more workable.

Centauri Soldier
07-02-2009, 05:23 PM
so, you mean,(now correct me if im wrong here) i make say "InputEx" and you have a bunch of functions you think would improve "InputEx", so you post the functions and i add them to the plugin and re-release it ?

if so, then that sounds more workable.

Exactly! That's all there is to it...

Centauri Soldier
07-06-2009, 03:31 AM
Any more Ex code you guys wanna share? The more the merrier...:D

MicroByte
07-06-2009, 04:10 AM
i'll be waiting for the stable release of retesets tool and i'll be making and releasing my own plugins

i have been instructed to put together a online portfolio, i dont have to many finished projects right now so i will fill it with plugins and extensions until i can get some real programs finished.

once the plugin compiler is ready i will release some of my "Ex" plugins and users can add functions from that post, but i really need to build up some *stock* for my future expansion.

ButtonMaker
07-07-2009, 04:58 AM
is it possible to disable mouse scrool with comboboxex ?