Jump to content

An alternative to MsgBox() function


kcvinu
 Share

Recommended Posts

Hi all,

I have made a simple script to use instead of MsgBox function. This function takes only one parameter as message text. It will display your script name as message title. Here is the code. You can include this in your script.

#cs
Function name = Alert($msg)
Creater = kcvinu
Example = Alert("Hello World!")

This function is an alternative for MsgBox.
It only takes one parameter as message text
And it will display the script name as title

#ce

Func Alert($msg)
    Local $title = StringSplit(@ScriptName,".")     ; Splitting the script name into two piece.
    MsgBox(0,$title[1],$msg)                        ; Using the first piece as title. 2nd piece is the extension.
EndFunc

Here is the file

Alert.au3

Edited by kcvinu
Spoiler

My Contributions

Glance GUI Library - A gui library based on Windows api functions. Written in Nim programming language.

UDF Link Viewer   --- A tool to visit the links of some most important UDFs 

 Includer_2  ----- A tool to type the #include statement automatically 

 Digits To Date  ----- date from 3 integer values

PrintList ----- prints arrays into console for testing.

 Alert  ------ An alternative for MsgBox 

 MousePosition ------- A simple tooltip display of mouse position

GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function

Access_UDF  -------- An UDF for working with access database files. (.*accdb only)

 

Link to comment
Share on other sites

What is the advantage compared to MsgBox?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Hi 

water, Sometimes we need to use the MsgBox function rapidly. I mean for test purposes. Mostly, when we learning something. Then we don't need to type the flag and title.  Just use this function with your msg. 

 

@

wakillon, Commonly people don't uses dots in filenames. Most programmers uses underscore in filenames. If you want to use two or more dots in your filename, then i need to use another function to strip the extension. :)
Spoiler

My Contributions

Glance GUI Library - A gui library based on Windows api functions. Written in Nim programming language.

UDF Link Viewer   --- A tool to visit the links of some most important UDFs 

 Includer_2  ----- A tool to type the #include statement automatically 

 Digits To Date  ----- date from 3 integer values

PrintList ----- prints arrays into console for testing.

 Alert  ------ An alternative for MsgBox 

 MousePosition ------- A simple tooltip display of mouse position

GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function

Access_UDF  -------- An UDF for working with access database files. (.*accdb only)

 

Link to comment
Share on other sites

 If so, you still needed to use it.  

@

kjsisco, This function is for instant use. And what do you mean by this comment.

 

@

JohnOne, Thank you for that code 
Spoiler

My Contributions

Glance GUI Library - A gui library based on Windows api functions. Written in Nim programming language.

UDF Link Viewer   --- A tool to visit the links of some most important UDFs 

 Includer_2  ----- A tool to type the #include statement automatically 

 Digits To Date  ----- date from 3 integer values

PrintList ----- prints arrays into console for testing.

 Alert  ------ An alternative for MsgBox 

 MousePosition ------- A simple tooltip display of mouse position

GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function

Access_UDF  -------- An UDF for working with access database files. (.*accdb only)

 

Link to comment
Share on other sites

@scriptlinenumber or a timerdiff or just about anything else would be more useful than the script name as the hard coded title, imho.

 

and i believe he means that you can't call it a "msgbox alternative", because it uses msgbox.  It is more a thread discussing your "msgbox presets".

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

boththose OK. got it. :)
Spoiler

My Contributions

Glance GUI Library - A gui library based on Windows api functions. Written in Nim programming language.

UDF Link Viewer   --- A tool to visit the links of some most important UDFs 

 Includer_2  ----- A tool to type the #include statement automatically 

 Digits To Date  ----- date from 3 integer values

PrintList ----- prints arrays into console for testing.

 Alert  ------ An alternative for MsgBox 

 MousePosition ------- A simple tooltip display of mouse position

GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function

Access_UDF  -------- An UDF for working with access database files. (.*accdb only)

 

Link to comment
Share on other sites

...  Sometimes we need to use the MsgBox function rapidly ....

 

 

I would add a default parameter so you can call the function even more quickly (that is even without parameters at all....)

Func Alert($msg = "Pause")
    Local $title = StringSplit(@ScriptName,".")     ; Splitting the script name into two piece.
    MsgBox(0,$title[1],$msg)                        ; Using the first piece as title. 2nd piece is the extension.
EndFunc

 

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

@

Valuater, This is my fist step in the UDF world. I know, i need to learn more. Thanks for the suggestion. :)

 

@

gil900, Actually, This is the first time i met  _WinAPI_ShowMsg. I don't know anything about it.
Spoiler

My Contributions

Glance GUI Library - A gui library based on Windows api functions. Written in Nim programming language.

UDF Link Viewer   --- A tool to visit the links of some most important UDFs 

 Includer_2  ----- A tool to type the #include statement automatically 

 Digits To Date  ----- date from 3 integer values

PrintList ----- prints arrays into console for testing.

 Alert  ------ An alternative for MsgBox 

 MousePosition ------- A simple tooltip display of mouse position

GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function

Access_UDF  -------- An UDF for working with access database files. (.*accdb only)

 

Link to comment
Share on other sites

If you are going to use something like this you should make the other parameters optional.

_MsgBox("Hello")
_MsgBox("Hello", "Title")
_MsgBox("Hello", "Title", 4096)

Func _MsgBox($msg, $title = StringSplit(@ScriptName,".")[1], $flag = 0)
    Return MsgBox($flag, $title, $msg)
EndFunc

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

@

wakillon, Here is the code.
#cs
Function name = Alert($msg)
Creater = kcvinu
Example = Alert("Hello World!")

This function is an alternative for MsgBox.
It only takes one parameter as message text
And it will display the script name as title

#ce

Func Alert($msg)
    Local $Length = StringLen(@ScriptName)
    Local $title = StringMid(@ScriptName,1,$Length-4)       ; Stripping the script name without extension.
    MsgBox(0,$title,$msg)
EndFunc
Spoiler

My Contributions

Glance GUI Library - A gui library based on Windows api functions. Written in Nim programming language.

UDF Link Viewer   --- A tool to visit the links of some most important UDFs 

 Includer_2  ----- A tool to type the #include statement automatically 

 Digits To Date  ----- date from 3 integer values

PrintList ----- prints arrays into console for testing.

 Alert  ------ An alternative for MsgBox 

 MousePosition ------- A simple tooltip display of mouse position

GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function

Access_UDF  -------- An UDF for working with access database files. (.*accdb only)

 

Link to comment
Share on other sites

 

@

wakillon, Here is the code.
#cs
Function name = Alert($msg)
Creater = kcvinu
Example = Alert("Hello World!")

This function is an alternative for MsgBox.
It only takes one parameter as message text
And it will display the script name as title

#ce

Func Alert($msg)
    Local $Length = StringLen(@ScriptName)
    Local $title = StringMid(@ScriptName,1,$Length-4)       ; Stripping the script name without extension.
    MsgBox(0,$title,$msg)
EndFunc

 

what happens if your script name has no extension.....

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

what happens if your script name has no extension.....

You can't run a script without save it in SciTe. If you save your script, then your script name must have an extension. 

Spoiler

My Contributions

Glance GUI Library - A gui library based on Windows api functions. Written in Nim programming language.

UDF Link Viewer   --- A tool to visit the links of some most important UDFs 

 Includer_2  ----- A tool to type the #include statement automatically 

 Digits To Date  ----- date from 3 integer values

PrintList ----- prints arrays into console for testing.

 Alert  ------ An alternative for MsgBox 

 MousePosition ------- A simple tooltip display of mouse position

GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function

Access_UDF  -------- An UDF for working with access database files. (.*accdb only)

 

Link to comment
Share on other sites

You can't run a script without save it in SciTe. If you save your script, then your script name must have an extension. 

 

yes, but you can compile it, remove the .exe extension and run it from another script by the run() function.... :geek:

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

yes, but you can compile it, remove the .exe extension and run it from another script by the run() function.... :geek:

If so, i need to include an if statement to check if the script name has an extension.

Edited by kcvinu
Spoiler

My Contributions

Glance GUI Library - A gui library based on Windows api functions. Written in Nim programming language.

UDF Link Viewer   --- A tool to visit the links of some most important UDFs 

 Includer_2  ----- A tool to type the #include statement automatically 

 Digits To Date  ----- date from 3 integer values

PrintList ----- prints arrays into console for testing.

 Alert  ------ An alternative for MsgBox 

 MousePosition ------- A simple tooltip display of mouse position

GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function

Access_UDF  -------- An UDF for working with access database files. (.*accdb only)

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...