image thumbnail

Matlab loadlibrary user32.dll for windows functions in one class

version 1.3.0.0 (4.11 KB) by Vishnu
Implement topmostmsg, .Net forms, Tray notification, findwindow, showwindow & setforegroundwindow

598 Downloads

Updated 18 Oct 2017

View License

[UPDATE]
Guess what I just ran it in new MAT LAB R2017b in Windows 10 (x64 October 2017 Updated version) and there were errors.
[Bug Fixed]
1. Error in <Obj>.waitforuser() - waitfor() requires a valid Matlab handle - Fixed
2. Loadlibrary STDCALL not supported - Fixed
I have just tested it, it worked fine. at least all the examples work. if there are more errors just let me know.
This submission is an implementation of .Net functions like the t
opmostmsg, .Net forms, Tray notification along with my technique to successfully load user32.dll in matlab without a userproto function. Windows functions findwindow, showwindow and setforegroundwindow are currently implemented.
SysObj = SystemTools; SysObj.help;
waitforuser Function:
Syntax: <ClassObj>.waitforuser or <ClassObj>.waitforuser('Short Message')
View General Help.
TopmostMsg Function:
Syntax: <ClassObj>.TopmostMsg('Message goes here...', 'title', System.Windows.Forms.MessageBoxButtons.YesNo)
View General Help.
Notify Function:
Syntax: <ClassObj>.Notify('Balloon Tool Tip', 'Balloon Title', 'Notification App', [pwd '\icon.ico']);

Make sure the icon.ico file is present in current folder to use this syntax.
To remove tray icon use <NotificationIconObj>.Visible = false; followed by <NotificationIconObj>.Dispose();.

StartProcess Function:

Syntax: Stats = <ClassObj>.StartProcess() or <ClassObj>.StartProcess(<Full Path with Ext as String>)

View General Help.

AppSelect Function:

Syntax: Stats = <ClassObj>.AppSelect('Process Name', 'Window State')

Run the demo code below to see it in action.

...Demo Code...

SysObj = SystemTools;
SysObj.NETFramework();
ProcCred = SysObj.StartProcess;
if ~ProcCred.HasExited
AppSelStats = SysObj.AppSelect(char(ProcCred.MainWindowTitle), 'SW_SHOWMAXIMIZED');
if AppSelStats>0, disp('Operation Successfull');
else disp('Operation Failed'); end
else msgbox('The Process has exited');
end
<<<<<<<<<>>>>>>>>>

General Help:
Every function in this class requires .NET support.
So make sure to call <Class Obj>.NETFramework() at least once before any function calls.

Cite As

Vishnu (2021). Matlab loadlibrary user32.dll for windows functions in one class (https://www.mathworks.com/matlabcentral/fileexchange/49149-matlab-loadlibrary-user32-dll-for-windows-functions-in-one-class), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2017b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Acknowledgements

Inspired by: WindowAPI

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!