Jump to content

NotifyBox UDF


Yashied
 Share

Recommended Posts

Link to comment
Share on other sites

  • 1 year later...

>"C:\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "D:\Documents\Downloads\NotifyBox.au3" /UserParams    
+>01:53:31 Starting AutoIt3Wrapper v.14.801.2025.0 SciTE v.3.4.4.0   Keyboard:00000409  OS:WIN_7/Service Pack 1  CPU:X64 OS:X64    Environment(Language:0409)
+>         SciTEDir => C:\AutoIt3\SciTE   UserDir => C:\AutoIt3\SciTE\AutoIt3Wrapper   SCITE_USERHOME => C:\Users\Trong\AppData\Local\AutoIt v3\SciTE 
>Running AU3Check (3.3.12.0)  from:C:\AutoIt3  input:D:\Documents\Downloads\NotifyBox.au3
+>01:53:31 AU3Check ended.rc:0
>Running:(3.3.12.0):C:\AutoIt3\autoit3.exe "D:\Documents\Downloads\NotifyBox.au3"    
--> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop
"D:\Documents\Downloads\NotifyBox.au3" (179) : ==> Expected a "=" operator in assignment statement.:
$__nbId[0][1] += 1
$__nbId^ ERROR
->01:53:32 AutoIt3.exe ended.rc:1
+>01:53:32 AutoIt3Wrapper Finished.
>Exit code: 1    Time: 0.621

fix plz

Regards,
 

Link to comment
Share on other sites

Link to comment
Share on other sites

;~ #Include "NotifyBox.au3"

Opt('TrayAutoPause', 0)

While 1
    _NotifyBox(16, ':-(', 'One.', 2)
    Sleep(500)
    _NotifyBox(48, ':-|', 'Two.', 2)
    Sleep(500)
    _NotifyBox(64, ':-)', 'Three.', 2)
    Sleep(3000)
WEnd
#Region Header

#cs

    Title:          Management of Message Boxes UDF Library for AutoIt3
    Filename:       NotifyBox.au3
    Description:    Creates a message boxes without pausing a script
    Author:         Yashied
    Version:        1.1
    Requirements:   AutoIt v3.3 +, Developed/Tested on WindowsXP Pro Service Pack 2
    Uses:           None
    Notes:          -

                    http://www.autoitscript.com/forum/index.php?showtopic=121609

    Available functions:

    _NotifyBox

    Example:

        #Include "NotifyBox.au3"

        Opt('TrayAutoPause', 0)

        While 1
            _NotifyBox(16, ':-(', 'One.', 2)
            Sleep(500)
            _NotifyBox(48, ':-|', 'Two.', 2)
            Sleep(500)
            _NotifyBox(64, ':-)', 'Three.', 2)
            Sleep(3000)
        WEnd

#ce

#Include-once

#EndRegion Header

#Region Local Variables and Constants

Dim $__nbId[1][4] = [[0, 1, 0, 0]]

#cs

DO NOT USE THIS ARRAY IN THE SCRIPT, INTERNAL USE ONLY!

$__nbId[0][0] - Number of items in array
       [0][1] - Timer control flag
       [0][2] - Handle to the DLL callback function
       [0][3] - Timer identifier

$__nbId[i][0] - Handle to the message box window
       [i][1] - Timeout, in milliseconds
       [i][2] - TimerInit()
       [i][3] - Reserved

#ce

#EndRegion Local Variables and Constants

#Region Initialization

OnAutoItExitRegister('__NB_AutoItExit')

#EndRegion Initialization

#Region Public Functions

; #FUNCTION# ====================================================================================================================
; Name...........: _NotifyBox
; Description....: Creates, displays, and operates a message box.
; Syntax.........: _NotifyBox ( $iFlags, $sTitle, $sText [, $iTimeOut [, $hParent [, $hInstance [, $iIcon]]]] )
; Parameters.....: $iFlags    - The flag indicates the type of message box and the possible button combinations (see MsgBox()).
;                  $sTitle    - The title of the message box.
;                  $sText     - The text of the message box.
;                  $iTimeOut  - Timeout in seconds. After the timeout has elapsed the message box will be automatically closed.
;                               The default is 0, which is no timeout.
;                  $hParent   - The window handle to use as the parent for this dialog.
;                  $hInstance - Handle to the module that contains the icon resource identified by the $iIcon parameter.
;                               If this parameter is 0, a handle of the file used to create the calling process.
;                  $iIcon     - Identifies an icon resource. $iIcon can be either a string or an integer resource identifier.
;                               $iIcon is ignored if the $iFlags parameter does not specify the MB_USERICON (128) flag.
; Return values..: Success    - Handle to the created message box.
;                  Failure    - 0.
; Author.........: Yashied
; Modified.......:
; Remarks........: None
; Related........:
; Link...........:
; Example........: Yes
; ===============================================================================================================================

Func _NotifyBox($iFlags, $sTitle, $sText, $iTimeOut = 0, $hParent = 0, $hInstance = 0, $iIcon = 0)

    Local $Opt = Opt('WinTitleMatchMode', 3)
    Local $tMBP = DllStructCreate('uint Size;hwnd hOwner;ptr hInstance;ptr Text;ptr Caption;dword Style;ptr Icon;dword_ptr ContextHelpId;ptr MsgBoxCallback;dword LanguageId')
    Local $tTitle = DllStructCreate('wchar[' & (StringLen($sTitle) + 1) & ']')
    Local $tText = DllStructCreate('wchar[' & (StringLen($sText) + 1) & ']')
    Local $aList1, $aList2 = WinList($sTitle)
    Local $tIcon, $hWnd = 0, $Error = 0
    Local $Ret

    If ($iIcon) And (BitAND($iFlags, 0x80)) Then
        If Not IsString($iIcon) Then
            $iIcon = '#' & $iIcon
        EndIf
        $tIcon = DllStructCreate('wchar[' & (StringLen($iIcon) + 1) & ']')
        If Not $hInstance Then
            $Ret = DllCall('kernel32.dll', 'ptr', 'GetModuleHandleW', 'ptr', 0)
            If Not @error Then
                $hInstance = $Ret[0]
            EndIf
        EndIf
    Else
        $tIcon = 0
    EndIf

    DllStructSetData($tTitle, 1, $sTitle)
    DllStructSetData($tText, 1, $sText)
    DllStructSetData($tIcon, 1, $iIcon)
    DllStructSetData($tMBP, 'Size', DllStructGetSize($tMBP))
    DllStructSetData($tMBP, 'hOwner', $hParent)
    DllStructSetData($tMBP, 'hInstance', $hInstance)
    DllStructSetData($tMBP, 'Text', DllStructGetPtr($tText))
    DllStructSetData($tMBP, 'Caption', DllStructGetPtr($tTitle))
    DllStructSetData($tMBP, 'Style', BitAND($iFlags, 0xFFFFBFF8))
    DllStructSetData($tMBP, 'Icon', DllStructGetPtr($tIcon))
    DllStructSetData($tMBP, 'ContextHelpId', 0)
    DllStructSetData($tMBP, 'MsgBoxCallback', 0)
    DllStructSetData($tMBP, 'LanguageId', 0)

    Do
        $Ret = DllCall('kernel32.dll', 'ptr', 'GetModuleHandleW', 'wstr', 'user32.dll')
        If (@error) Or (Not $Ret[0]) Then
            ExitLoop
        EndIf
        $Ret = DllCall('kernel32.dll', 'ptr', 'GetProcAddress', 'ptr', $Ret[0], 'str', 'MessageBoxIndirectW')
        If (@error) Or (Not $Ret[0]) Then
            ExitLoop
        EndIf
        $Ret = DllCall('kernel32.dll', 'ptr', 'CreateThread', 'ptr', 0, 'dword_ptr', 0, 'ptr', $Ret[0], 'ptr', DllStructGetPtr($tMBP), 'dword', 0, 'dword*', 0)
        If (@error) Or (Not $Ret[0]) Then
            ExitLoop
        EndIf
        While 1
            Sleep(10)
            $aList1 = WinList($sTitle)
            For $i = 1 To $aList1[0][0]
                For $j = 1 To $aList2[0][0]
                    If $aList1[$i][1] = $aList2[$j][1] Then
                        ContinueLoop 2
                    EndIf
                Next
                $hWnd = $aList1[$i][1]
                ExitLoop 2
            Next
        WEnd
    Until 1
    Opt('WinTitleMatchMode', $Opt)
    If Not $hWnd Then
        Return SetError(1, 0, 0)
    EndIf
    If $iTimeOut Then
        $__nbId[0][1] += 1
        $__nbId[0][0] += 1
        ReDim $__nbId[$__nbId[0][0] + 1][4]
        $__nbId[$__nbId[0][0]][0] = $hWnd
        $__nbId[$__nbId[0][0]][1] = 1000 * $iTimeOut
        $__nbId[$__nbId[0][0]][2] = TimerInit()
        $__nbId[$__nbId[0][0]][3] = 0
        If Not $__nbId[0][3] Then
            $__nbId[0][2] = DllCallbackRegister('__NB_TimerProc', 'none', '')
            $Ret = DllCall('user32.dll', 'uint_ptr', 'SetTimer', 'hwnd', 0, 'uint_ptr', 0, 'uint', 200, 'ptr', DllCallBackGetPtr($__nbId[0][2]))
            If (@error) Or (Not $Ret[0]) Then
                DllCallbackFree($__nbId[0][2])
                $Error = 1
            Else
                $__nbId[0][3] = $Ret[0]
                $__nbId[0][1] -= 1
            EndIf
        EndIf
        $__nbId[0][1] -= 1
    EndIf
    Return SetError($Error, 0, $hWnd)
EndFunc   ;==>_NotifyBox

#EndRegion Public Functions

#Region Windows DLL Functions

Func __NB_TimerProc()

    If $__nbId[0][1] Then
        Return
    EndIf

    $__nbId[0][1] += 1

    Local $Ret, $Start = 1

    While 1
        For $i = $Start To $__nbId[0][0]
            If TimerDiff($__nbId[$i][2]) >= $__nbId[$i][1] Then
                If WinExists($__nbId[$i][0]) Then
                    DllCall('user32.dll', 'lresult', 'SendMessage', 'hwnd', $__nbId[$i][0], 'uint', 0x0010, 'wparam', 0, 'lparam', 0)
                EndIf
                $Start = $i
                For $j = $i To $__nbId[0][0] - 1
                    For $k = 0 To 3
                        $__nbId[$j][$k] = $__nbId[$j + 1][$k]
                    Next
                Next
                ReDim $__nbId[$__nbId[0][0]][4]
                $__nbId[0][0] -= 1
                If Not $__nbId[0][0] Then
                    $Ret = DllCall('user32.dll', 'int', 'KillTimer', 'hwnd', 0, 'uint_ptr', $__nbId[0][3])
                    If (Not @error) And ($Ret[0]) Then
                        $__nbId[0][3] = 0
                        DllCallbackFree($__nbId[0][2])
                        Return
                    EndIf

                EndIf
                ContinueLoop 2
            EndIf
        Next
        ExitLoop
    WEnd

    $__nbId[0][1] -= 1

EndFunc   ;==>__NB_TimerProc

#EndRegion Windows DLL Functions

#Region AutoIt Exit Functions

Func __NB_AutoItExit()
    $__nbId[0][1] += 1
    If $__nbId[0][3] Then
        DllCall('user32.dll', 'int', 'KillTimer', 'hwnd', 0, 'uint_ptr', $__nbId[0][3])
        DllCallbackFree($__nbId[0][2])
    EndIf
EndFunc   ;==>__NB_AutoItExit

#EndRegion AutoIt Exit Functions

Not Edit

Regards,
 

Link to comment
Share on other sites

Declare $__nbId before your code.

 
This is not my code, it is your code.
I just downloaded and tested, do not modify the original code.
 
Fix it, I can not edit it.  :imwithstupid:
Or I'll find another function.

Regards,
 

Link to comment
Share on other sites

  • Developers

 

 
Fix it, I can not edit it.  :imwithstupid:
Or I'll find another function.

 

Hope this is the result of your lack of English skills as this surely is pretty rude and won't make too many friends.

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Moderators

Trong,

Firstly, mind your manners:

Fix it, I can not edit it. :imwithstupid:

Or I'll find another function

is not the way to speak to a respected member of this community whose coding skills are well-known and far surpass yours. :naughty:

If you were to write your script like this:

#include "NotifyBox.au3"

; Your code
you would not have this problem as the variable would be declared inside the UDF before your code ran. So you have 3 choices:

 

- 1. Place your code after the UDF code - I have tested this and it works.

- 2. Write your script as I suggested above rather than adding the UDF code after your test code.

- 3. Do as Yashied has suggested and predeclare the variable.

All 3 of those will work - No 2 is the best solution. ;)

M23

Edited by Melba23
Fixed BB tags

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

First, I want to apologize for my rudeness.
UDF is required at the top of the code, to be able to run. (Like #include) 
If my speech are not welcome, I'll just look and say no more.

End, I want to apologize for my rudeness.

Jos,
You can see my avatar, I think you understand.

 

Regards,
 

Link to comment
Share on other sites

  • Moderators

Trong,

Thank you for that - all is forgotten. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Very nice lib, i think its very usefull (by example debug and more).

But i think it crash often with present verion of Autoit, in your example

Opt('TrayAutoPause',0)
    While 1
        _NotifyBox(16,':-(','One.',2)
        Sleep(500)
        _NotifyBox(48,':-|','Two.',2)
        Sleep(500)
        _NotifyBox(64,':-)','Three.',2)
        Sleep(3000)
    WEnd

crash to me before show the first dialog again by the second time of the loop.

I see this was a old post, may be things have changed. Thanks a lot anyway, warn us if you have new versions :)

Edited by zalomalo

My english shucks, i know it.

Link to comment
Share on other sites

  • 5 years later...

Hello,

I have a question regarding the function WinList, which is used in NotifyBox.au3 on line 149:

$TITLE_1 = "[STRING_1] STRING_2 [STRING_3"
$TITLE_2 = "[STRING_1] STRING_2 [STRING_3]"

$RETVAL = WinList($TITLE_1)
$RETVAL = WinList($TITLE_2)
Using $TITLE_2 is producing an error code = 1, using $TITLE_1 is creating an array. This is according to the documentation

The problem seems to be the last bracket "]"

I found this error (?) using the NotifyBox.au3 library, so I put my question to this topic. 

I am using latest version of AutoIt and Version 1.1 of NotifyBox.au3

Thanks for your help

Link to comment
Share on other sites

Since the author is not here anymore, I would suggest you make your own modification.  If you prefer you could use the following streamlined version of _NotifyBox :

#pragma compile(AutoItExecuteAllowed, True)
#include <MsgBoxConstants.au3>

HotKeySet("{ESC}", _Exit)
While 1
  _NotifyBox($MB_ICONERROR, ':-(', 'One.', 2)
  Sleep(500)
  _NotifyBox($MB_ICONWARNING, ':-|', 'Two.', 2)
  Sleep(500)
  _NotifyBox($MB_ICONINFORMATION, ':-)', 'Three.', 2)
  Sleep(3000)
WEnd

Func _NotifyBox($iFlag, $sTitle, $sText, $iTimeout = 0, $hWnd = 0)
  If $iTimeout = Default Then $iTimeout = 0
  If $hWnd = Default Then $hWnd = 0
  Run(@AutoItExe & ' /AutoIt3ExecuteLine "MsgBox(' & $iFlag & ',''' & $sTitle & ''',''' & $sText & ''',' & $iTimeout & ',' & $hWnd & ')"')
EndFunc   ;==>_NotifyBox

Func _Exit()
  Exit
EndFunc   ;==>_Exit

 

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...