Jump to content

Recommended Posts

Posted (edited)

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
  Reveal hidden contents

 

Posted

What is the advantage compared to MsgBox?

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted

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. :)
  Reveal hidden contents

 

Posted
  On 2/24/2015 at 5:26 PM, kjsisco said:

 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 
  Reveal hidden contents

 

Posted

@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".

  Reveal hidden contents

Posted

boththose OK. got it. :)
  Reveal hidden contents

 

Posted

  On 2/24/2015 at 5:38 PM, kcvinu said:
...  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....

Posted

@

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.
  Reveal hidden contents

 

Posted (edited)
  On 2/24/2015 at 5:38 PM, kcvinu said:

 

i need to use another function to strip the extension. :)

 

This is what I wanted hear you say.

Take a look to the _PathSplit function.

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Posted

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.

Posted

@

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
  Reveal hidden contents

 

Posted
  On 2/24/2015 at 6:10 PM, kcvinu said:

 

@

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....

Posted
  On 2/24/2015 at 6:16 PM, Chimp said:

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. 

  Reveal hidden contents

 

Posted
  On 2/24/2015 at 6:20 PM, kcvinu said:

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....

Posted (edited)
  On 2/24/2015 at 6:42 PM, Chimp said:

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
  Reveal hidden contents

 

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
×
×
  • Create New...