Jump to content
Sign in to follow this  
johnmcloud

Different version of MsgBox

Recommended Posts

johnmcloud

Hi guys, maybe is a stupid question but i don't find anything useful in the guide.

I find on a script this MsgBox:

Posted Image

The script:

MsgBox(270628, "Hey", "I like it!")

I want make a different version of it, like one button, or Stop-sign/Exclamation-point icon, but i don't understand how make a number like 270628, an on the guide there isn't a flag for disable the X button.

Thanks for support

Edited by johnmcloud

Share this post


Link to post
Share on other sites
guinness

Check out the flags in the Help file.

MsgBox(1 + 48, "Hey", "I like it!")

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Share this post


Link to post
Share on other sites
johnmcloud

No guinnes, you don't understand. I want make a version withouth the X botton enabled, like the image and the script. For example, with an Exclamation-point icon, only one button with the X disabled

Thanks

Edited by johnmcloud

Share this post


Link to post
Share on other sites
guinness

No guinnes, you don't understand.

Pardon me? I provided an example with Yes & No buttons and an exclamation mark, what I didn't address was the disabled close button. So I think I did understand. OK, so perhaps I didn't provide one button but I was hoping you would read the Help file. Edited by guinness

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Share this post


Link to post
Share on other sites
johnmcloud

guinnes, maybe my english isn't perfect, sorry for this and I apologize if I offended you. I have read the flag on help file, but don't find anything on close button, and the version posted has the close button disable. I can make a version with close button disable like this?

MsgBox(270628, "Hey", "I like it!")

With, ad example, one button or different icon?

Thanks for your help

Click on casual number, i have make a version with:

Yes-No and information icon

MsgBox(4 + 64, "Hey", "I like it!")

3 buttom ( abort, rentry and ignore ) and information icon

MsgBox(270626, "Hey", "I like it!")

3 button and error icon

MsgBox(270610,"Hey", "I like it!")

Yes-No and error icon

MsgBox(270612,"Hey", "I like it!")

3 button and yellow-mark icon

MsgBox(270642,"Hey", "I like it!")

Yes-No and yellow-mark icon

MsgBox(270644,"Hey", "I like it!")

3 button and exclamation icon

MsgBox(270658,"Hey", "I like it!")

Yes-No and exclamation icon

MsgBox(270660,"Hey", "I like it!")

Yes-No, no icon

MsgBox(270692,"Hey", "I like it!")

3 button, no icon

MsgBox(270674,"Hey", "I like it!")

So there is a way to do this, but i don't know and i can't make random number for ever :)

EDIT I have make number from 270600 to 270699 and i can't find only one button. Please i someone undestand how this number work, post the solution.

Edited by johnmcloud

Share this post


Link to post
Share on other sites
KaFu

It seems like the flags 2 & 4 disable the close button by default.

For $i = 0 To 6
MsgBox($i, "Hey " & $i, "I like it!")
Next

Edit:

Seems like this is what you're looking for:

MsgBox(4 + 32, "Hey", "I like it!")
Edited by KaFu

Share this post


Link to post
Share on other sites
jvanegmond

Given: 270628

In binary: 1000010000100100100

Is:

(2^18)*1 + = 262144 ( Top-most attribute )

(2^17)*0 +

(2^16)*0 +

(2^15)*0 +

(2^14)*0 +

(2^13)*1 + = 8192 ( Task modal )

(2^12)*0 +

(2^11)*0 +

(2^10)*0 +

(2^9)*0 +

(2^8)*1 + = 256 ( Second button default button )

(2^7)*0 +

(2^6)*0 +

(2^5)*1 + = 32 ( Question mark icon )

(2^4)*0 +

(2^3)*0 +

(2^2)*1 + = 4 ( Yes and no )

(2^1)*0 +

(2^0)*0 +

= 270628(decimal)

So don't see anything special there. Then I tried the same as KaFu: Only flag 4 in your example seems to disable close button.

Edited by Manadar

Share this post


Link to post
Share on other sites
KaFu
Mikeman27294

Maybe you should take a look at the code wizard (Alt+W in scite). That will allow you to do exactly what you want. If you want anything more, you will have to make your own custom message box.

Share this post


Link to post
Share on other sites
johnmcloud

Seems like this is what you're looking for:

MsgBox(4 + 32, "Hey", "I like it!")

You are right, i have make random number for nothing :)

A version only with one buttom? Only OK is = 0, how i can do this?

Because:

Only OK button + icon:

MsgBox(64,"Hey", "I like it!")

Add 4 we have two button instead 1

MsgBox(4 + 64,"Hey", "I like it!")

And seems don't work for all version, ad example:

MsgBox(20, "Hey", "I like it!")

With 4 don't work:

MsgBox(4 + 20, "Hey", "I like it!")

Thanks to all

Edited by johnmcloud

Share this post


Link to post
Share on other sites
KaFu

If you're building a flag combo, you have to add up the numbers. I've you want to do it in reverse, you always have to subtract the largest possible value first (also see Manadar example above).

20 = 16 + 4

24 = 16 + 8 ... and 8 is undefined... or it's a 6 + 2 collision, either way no wonder it does not work :)...

Just add up the numbers you want to define the properties, only one per category.

0 + 64 + 256 + 4096 + 262144

Edited by KaFu

Share this post


Link to post
Share on other sites
jvanegmond

Fun challenge.

Took code from here and here:

; =============================================================================
;  MsgBoxEx And InputBoxEx Examples
;  Purpose: Custom Buttons Of System Dialog
;  Author: Ward
; =============================================================================

#Include <winapi.au3>
#include <guimenu.au3>

MsgBoxEx("Ok", 0, "MsgBoxEx", "Test")

Func MsgBoxEx($CustomButton, $Flag, $Title, $Text, $Timeout = 0, $Hwnd = 0)
    Assign("MsgBoxEx:CustomButton", $CustomButton, 2)
    Local $CBT_ProcCB = DllCallbackRegister("MsgBoxEx_CBT_Proc", "long", "int;hwnd;lparam")
    Local $CBT_Hook = _WinAPI_SetWindowsHookEx($WH_CBT, DllCallbackGetPtr($CBT_ProcCB), 0, _WinAPI_GetCurrentThreadId())
    Local $Ret = MsgBox($Flag, $Title, $Text, $Timeout, $Hwnd)
    Local $Error = @Error
    _WinAPI_UnhookWindowsHookEx($CBT_Hook)
    DllCallbackFree($CBT_ProcCB)
    Assign("MsgBoxEx:CustomButton", 0, 2)
    Return SetError($Error, 0, $Ret)
EndFunc

Func MsgBoxEx_CBT_Proc($nCode, $wParam, $lParam)
    If $nCode = 5 Then ; HCBT_ACTIVATE
_GUICtrlMenu_EnableMenuItem(_GUICtrlMenu_GetSystemMenu($wParam), $SC_CLOSE, 1, False)
        Local $CustomButton = StringSplit(Eval("MsgBoxEx:CustomButton"), "|")
        For $i = 1 To $CustomButton[0]
            ControlSetText($wParam, "", $i, $CustomButton[$i])
        Next
    EndIf
    Return _WinAPI_CallNextHookEx(0, $nCode, $wParam, $lParam)
EndFunc
Edited by Manadar
  • Like 1

Share this post


Link to post
Share on other sites
jvanegmond

"Tidied" a bit ............

#Include <WinAPI.au3>
#include <GuiMenu.au3>

MsgBoxEx(64, "MsgBoxEx", "Test", 0, 0, 1)

Func MsgBoxEx($Flag, $Title, $Text, $Timeout = 0, $Hwnd = 0, $DisableX = 0)
    Assign("MsgBoxEx:DisableX", $DisableX, 2)
    Local $CBT_ProcCB = DllCallbackRegister("MsgBoxEx_CBT_Proc", "long", "int;hwnd;lparam")
    Local $CBT_Hook = _WinAPI_SetWindowsHookEx($WH_CBT, DllCallbackGetPtr($CBT_ProcCB), 0, _WinAPI_GetCurrentThreadId())
    Local $Ret = MsgBox($Flag, $Title, $Text, $Timeout, $Hwnd)
    Local $Error = @Error
    _WinAPI_UnhookWindowsHookEx($CBT_Hook)
    DllCallbackFree($CBT_ProcCB)
    Assign("MsgBoxEx:CustomButton", 0, 2)
    Return SetError($Error, 0, $Ret)
EndFunc

Func MsgBoxEx_CBT_Proc($nCode, $wParam, $lParam)
    If $nCode = 5 And Eval("MsgBoxEx:DisableX") Then ; HCBT_ACTIVATE
_GUICtrlMenu_EnableMenuItem(_GUICtrlMenu_GetSystemMenu($wParam), $SC_CLOSE, 1, False)
    EndIf
    Return _WinAPI_CallNextHookEx(0, $nCode, $wParam, $lParam)
EndFunc
  • Like 1

Share this post


Link to post
Share on other sites
KaFu

Share this post


Link to post
Share on other sites
johnmcloud

I have check it out over 10000 combination of MsgBox with this script:

While 1
    For $i = 10000 to 00001 Step -1
        MsgBox($i, $i, $i)
        Sleep(10)
    Next
    ExitLoop
WEnd

The result is:

; Question-mark icon
MsgBox(270628, "MsgBox", "Test"); Yes - No
MsgBox(97828, "MsgBox", "Test") ; Yes - No - ?
MsgBox(3618, "MsgBox", "Test")  ; Abort - Retry - Ignore
MsgBox(97826, "MsgBox", "Test") ; Abort - Retry - Ignore - ?
;No Icon
MsgBox(270692, "MsgBox", "Test"); Yes - No
MsgBox(98052, "MsgBox", "Test") ; Yes - No - ?
MsgBox(27066, "MsgBox", "Test") ; Abort - Retry - Ignore
MsgBox(98050, "MsgBox", "Test") ; Abort - Retry - Ignore - ?
; Exclamation-point icon
MsgBox(270660, "MsgBox", "Test"); Yes - No
MsgBox(97860, "MsgBox", "Test") ; Yes - No - ?
MsgBox(270658, "MsgBox", "Test"); Abort - Retry - Ignore
MsgBox(98114, "MsgBox", "Test") ; Abort - Retry - Ignore - ?
; Exclamation-point yellow icon
MsgBox(270644, "MsgBox", "Test"); Yes - No
MsgBox(97844, "MsgBox", "Test") ; Yes - No - ?
MsgBox(270642, "MsgBox", "Test"); Abort - Retry - Ignore
MsgBox(97842, "MsgBox", "Test") ; Abort - Retry - Ignore - ?
; Stop-sign icon
MsgBox(270612, "MsgBox", "Test"); Yes - No
MsgBox(98068, "MsgBox", "Test") ; Yes - No - ?
MsgBox(270610, "MsgBox", "Test"); Abort - Retry - Ignore
MsgBox(98066, "MsgBox", "Test") ; Abort - Retry - Ignore - ?

So seems there isn't a way to have a single button or the OK-Cancel combination by the MsgBox of Autoit with the X disabled ( excluding UDF or the solution by Manadar ). It's right?

Edited by johnmcloud

Share this post


Link to post
Share on other sites
JohnQSmith

So seems there isn't a way to have a single button or the OK-Cancel combination by the MsgBox of Autoit with the X disabled ( excluding UDF or the solution by Manadar ). It's right?

There is no mention of disabling the X button in the MsgBox documentation. Also, instead of creating 10E3 message boxes to find what you're looking for, try adding the values in the first column of the table shown below together in a way to create combinations of the desired effects listed in the second column. It's called the help file and it is your friend.

For instance, if you want the "Yes and No" button, the question mark icon, the NO button highlighted, and the MsgBox set to appear on top of all other windows, then you take the 4 from the Button-related Result, the 32 from the Icon-related Result, the 256 from the Default-related Result, and 262144 from the Miscellaneous-related Result and add them together. 4 + 32 + 256 + 262144 = 262436. Which is what you put into the flag position of the MsgBox command.

The flag parameter can be a combination of the following values:

The flag parameter can be a combination of the following values:

decimal flag    Button-related Result
0              OK button
1              OK and Cancel
2              Abort, Retry, and Ignore
3              Yes, No, and Cancel
4              Yes and No
5              Retry and Cancel
6              ** Cancel, Try Again, Continue

decimal flag    Icon-related Result
0              (No icon)
16            Stop-sign icon
32            Question-mark icon
48            Exclamation-point icon
64            Information-sign icon consisting of an 'i' in a circle

decimal flag    Default-related Result
0              First button is default button
256          Second button is default button
512          Third button is default button

decimal flag    Modality-related Result
0              Application
4096            System modal (dialog has an icon)
8192            Task modal

decimal flag    Miscellaneous-related Result
0              (nothing else special)
262144        MsgBox has top-most attribute set
524288        title and text are right-justified


Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes".

Share this post


Link to post
Share on other sites
johnmcloud

Yes JohnQSmith, i see the help and i see there is no mention to disable the X flag, but there is a possibility to do that.

Your example work in this case ( for the X flag disable ):

MsgBox(4+32+256+262144, "Test", "Test")

But not in this case

MsgBox(1+32+256+262144, "Test", "Test")

I think there isn't another possibilty for disabled flag.

However, have make this thread only for academic purpose :)

Edited by johnmcloud

Share this post


Link to post
Share on other sites
jvanegmond

Yes JohnQSmith, i see the help and i see there is no mention to disable the X flag, but there is a possibility to do that.

Your example work in this case ( for the X flag ):

MsgBox(4+32+256+262144, "Test", "Test")

But not in this case

MsgBox(1+32+256+262144, "Test", "Test")

However, have make this thread only for academic purpose

johnmcloud, you have been presented the answer to your question in several posts by several different people.

The disabling of the X button is the result of codes 2 and 4.

Share this post


Link to post
Share on other sites
johnmcloud

johnmcloud, you have been presented the answer to your question in several posts by several different people.

The disabling of the X button is the result of codes 2 and 4.

Understood, so you can confirm there isn't other way to do the X disabled for other MsgBox, in addition to those I have already posted ( by "normal" autoit, obviously )

Edited by johnmcloud

Share this post


Link to post
Share on other sites
JLogan3o13

Why do you need some "other way" when you've clearly been presented the answer?


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
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
Sign in to follow this  

  • Similar Content

    • xtcislove
      By xtcislove
      Hello,
      as a start in Autoit i tried something i was missing since im using Autoit. 

      I build a custom MessageBox which has a large amount of custom options and which scales its size on the parameters you set. 

      Aviable Settings:
      -Title
      -Unlimited Buttons
      -Text Color (Buttons, Text)

      -Background Color (Msgbox, Buttons, Label) 

      -Button Timeout
      -Autoclose Timeout
      -Icon (Default, No Icon, Custom)

      -Label/ Button Style. 
      -Transparency

      I tried to keep this as close as i could to a Msgbox i was used too on my batch times.

      After i was ready i realised, @Melba23 probably build a way better msgbox which would have suit my needs enterly, anyway thanks to @Melba23 because i use his Stringsize UDF. 

       
       
      local $Message = _sMsgBox("Test", 6, "Continue?") if @extended <> -1 Then MsgBox(0, @extended, $Message&" Button pressed")  
      ScalingMessageBox.au3
    • SkysLastChance
      By SkysLastChance
      I am having a hard time understanding why this is not working. I was hoping some one could help explain it to me. 
      $tags = $oIE.document.GetElementsByTagName("input") For $tag in $tags $class_value = $tag.GetAttribute("class") If string($class_value) = "fTs-p3298-l0 wplEditControl" Then $target = $tag ExitLoop EndIF Next MsgBox(0,"",$target) If $target = "fTs-p3298-l0 wplEditControl" THEN MsgBox(0,"","itworked") I have tried 
       MsgBox(0,"",$target.Attribute)  MsgBox(0,"",$target.Value)  MsgBox(0,"",$target.InnerText) I would expect to see this in the msgbox
      fTs-p3298-l0 wplEditControl  
    • funkey
      By funkey
      Hello,
      it's quite often, that someone asks how to change the texts of the MsgBox buttons or the InputBox buttons or how to change the position of ta MsgBox. Since years I use CBT hooks for that, but now I made a small UDF out of it for the ease of use. Of course you can build your own GUI or use already existing UDFs to do the same, but I like this way and you can hack (hook) the inbuild InputBox.
       
      HookDlgBox.au3
      #include-once #include <WinAPI.au3> Global Const $tagCBT_CREATEWND = "ptr lpcs;HWND tagCBT_CREATEWND" Global Const $tagCREATESTRUCT = "ptr lpCreateParams;handle hInstance;HWND hMenu;HWND hwndParent;int cy;int cx;int y;int x;LONG style;ptr lpszName;ptr lpszClass;DWORD dwExStyle" Global $g__hProcDlgBox = DllCallbackRegister("__DlgBox_CbtHookProc", "int", "int;int;int") Global $g__TIdDlgBox = _WinAPI_GetCurrentThreadId() Global $g__hHookDlgBox = _WinAPI_SetWindowsHookEx($WH_CBT, DllCallbackGetPtr($g__hProcDlgBox), 0, $g__TIdDlgBox) Global Const $g__MaxDlgBtns = 5 ; maximum of 5 buttons to rename text Global Const $g__MaxDlgItemId = 11 ; maximun ID of buttons to search is 11 as this is the maximun used in Messagebox Global $g__DlgBoxPosX, $g__DlgBoxPosY, $g__DlgBoxWidth, $g__DlgBoxHeight Global $g__aDlgBoxBtnText[$g__MaxDlgBtns] Global $g__DlgBtnCount = 0 _DlgBox_SetDefaults() OnAutoItExitRegister("__DlgBox_UnregisterHook") Func _DlgBox_SetButtonNames($TxtBtn1 = Default, $TxtBtn2 = Default, $TxtBtn3 = Default, $TxtBtn4 = Default, $TxtBtn5 = Default) $g__aDlgBoxBtnText[0] = $TxtBtn1 $g__aDlgBoxBtnText[1] = $TxtBtn2 $g__aDlgBoxBtnText[2] = $TxtBtn3 $g__aDlgBoxBtnText[3] = $TxtBtn4 $g__aDlgBoxBtnText[4] = $TxtBtn5 $g__DlgBtnCount = @NumParams EndFunc ;==>_DlgBox_SetButtonNames Func _DlgBox_SetPosition($x = Default, $y = Default) ;only for MsgBox, not working and not needed for InputBox $g__DlgBoxPosX = $x $g__DlgBoxPosY = $y EndFunc ;==>_DlgBox_SetPosition Func _DlgBox_SetSize($w = Default, $h = Default) $g__DlgBoxWidth = $w $g__DlgBoxHeight = $h EndFunc ;==>_DlgBox_SetSize Func _DlgBox_SetDefaults() $g__DlgBoxPosX = Default $g__DlgBoxPosY = Default $g__DlgBoxWidth = Default $g__DlgBoxHeight = Default For $i = 0 To UBound($g__aDlgBoxBtnText) - 1 $g__aDlgBoxBtnText[$i] = Default Next EndFunc ;==>_DlgBox_SetDefaults Func __DlgBox_CbtHookProc($nCode, $wParam, $lParam) Local $tcw, $tcs Local $iSearch = 0 Local $ahBtn[$g__DlgBtnCount] If $nCode < 0 Then Return _WinAPI_CallNextHookEx($g__hHookDlgBox, $nCode, $wParam, $lParam) EndIf Switch $nCode Case 3 ;5=HCBT_CREATEWND If _WinAPI_GetClassName(HWnd($wParam)) = "#32770" Then ;Dialoig window class $tcw = DllStructCreate($tagCBT_CREATEWND, $lParam) $tcs = DllStructCreate($tagCREATESTRUCT, DllStructGetData($tcw, "lpcs")) If $g__DlgBoxPosX <> Default Then DllStructSetData($tcs, "x", $g__DlgBoxPosX) If $g__DlgBoxPosY <> Default Then DllStructSetData($tcs, "y", $g__DlgBoxPosY) If $g__DlgBoxWidth <> Default Then DllStructSetData($tcs, "cx", $g__DlgBoxWidth) If $g__DlgBoxHeight <> Default Then DllStructSetData($tcs, "cy", $g__DlgBoxHeight) EndIf Case 5 ;5=HCBT_ACTIVATE For $i = 1 To $g__MaxDlgItemId If IsHWnd(_WinAPI_GetDlgItem($wParam, $i)) Then If $g__aDlgBoxBtnText[$iSearch] <> Default Then _WinAPI_SetDlgItemText($wParam, $i, $g__aDlgBoxBtnText[$iSearch]) $iSearch += 1 If $iSearch >= UBound($ahBtn) Then ExitLoop EndIf Next EndSwitch Return _WinAPI_CallNextHookEx($g__hHookDlgBox, $nCode, $wParam, $lParam) EndFunc ;==>__DlgBox_CbtHookProc Func __DlgBox_UnregisterHook() _WinAPI_UnhookWindowsHookEx($g__hHookDlgBox) DllCallbackFree($g__hProcDlgBox) EndFunc ;==>__DlgBox_UnregisterHook Func _WinAPI_SetDlgItemText($hDlg, $nIDDlgItem, $lpString) Local $aRet = DllCall('user32.dll', "int", "SetDlgItemText", _ "hwnd", $hDlg, _ "int", $nIDDlgItem, _ "str", $lpString) Return $aRet[0] EndFunc ;==>_WinAPI_SetDlgItemText  
      Simple example to see how to use it
      #include "HookDlgBox.au3" _DlgBox_SetButtonNames("1", "two", "3") MsgBox(4, "Test 1", "Custom button texts") _DlgBox_SetPosition(20, 20) MsgBox(66, "Test 2", "Custom position and button texts") _DlgBox_SetButtonNames("Submit", "Don't submit", "Don't know") InputBox("Test 3", "Where were you born?", "Planet Earth") _DlgBox_SetSize(800, 800) InputBox("Test 4", "Where were you born?", "Planet Earth") _DlgBox_SetSize(Default, 800) MsgBox(66, "Test 5", "Strange but working") _DlgBox_SetButtonNames(Default, "Wait", "What?") _DlgBox_SetSize(Default, Default) _DlgBox_SetPosition(500, 500) MsgBox(66, "Test 6", "So far so good!") _DlgBox_SetDefaults() MsgBox(6, "Test 7", "Default position and button texts") Hope you like it.
       
      Best regards
      funkey
      HookDlgBox Example.au3
      HookDlgBox.au3
    • Shirdish_chakravarthi
      By Shirdish_chakravarthi
      Hello Guys i am working on automating a flashing tool..When flashing is started if there is any error in connection it pops's up a error window...(as shown below)

       whenever this popup appears i need a msgbox to appear saying "error occured" how can i do this?
      Thanks

    • Nareshm
      By Nareshm
      I have autoit script like this :
      winActivate ("BillReceipt") ControlClick ( "BillReceipt", "", "[NAME:winviewer]", "right") Send ( "{ENTER}") WinWait ("Print") ControlClick ("Print", "", "[CLASS:Button; INSTANCE:13]") Winwait ("Save As") WinActivate ("Save As") Send ("{TAB 5} {Backspace} ^v {Enter}") I need Saved successfully msgbox with file name as i saved like Filename.extension (Example = test.pdf is saved successfull)

      Please Help
×