Jump to content
Sign in to follow this  
caramen

MsgBox 4 return value ?

Recommended Posts

caramen

Hello guy got some trouble in this easy script

 

Case $BoutonWhrite1
                 $Case1 =  MsgBox (4,"Are you sure ?" ,"Reg key gonna be changed." )
                  While 1
                    If $Case1 = "No" Then
                       ConsoleWrite(">Case -1 Started" & @CRLF)
                       ExitLoop
                    EndIf
                        $InputType = InputBox ("Value Type ?", 'Type of key to write: "REG_SZ", "REG_MULTI_SZ", "REG_EXPAND_SZ", "REG_DWORD", "REG_QWORD", or "REG_BINARY".' )
;~                      RegWrite (""&Reg1,""&$RegName1,""&$InputType, ""&$RegValue1)
                        ExitLoop
                  WEnd

I tryed

If $case1 = 1

If $case1 = -1

If $case1 = "No"

 

What is the returned value by the msg box YES or NO ?

 

The script is going wrong about the final purpose (Whrite a Registry key if the Script user unswer YES ) But dont take attention i am gonna corect after get the returned value xD it was for testing. 

Edited by caramen

Share this post


Link to post
Share on other sites
Terenz

On the help of MsgBox there are all the return value:

Yes = 6 = $IDYES

No = 7 = $IDNO

MsgBox

You can see also adding:

MsgBox(0,0,$Case1)

After that MsgBox

  • Like 1

Nothing is so strong as gentleness. Nothing is so gentle as real strength

 

Share this post


Link to post
Share on other sites
caramen

nvm

Edited by caramen

Share this post


Link to post
Share on other sites
caramen

I watched the help file and missed the return value section... :>

Share this post


Link to post
Share on other sites
AutoBert
56 minutes ago, caramen said:

I tryed

If $case1 = 1

If $case1 = -1

If $case1 = "No"

 

What is the returned value by the msg box YES or NO ?

 

Don't use maic numbers use the constansts, its easier to read source:

#include <MsgBoxConstants.au3>

While 1
    $iAnwer = MsgBox($MB_ICONQUESTION + $MB_YESNO, "Title", "Are you sure ?", "Reg key gonna be changed.")
    Switch $iAnwer
        Case $IDYes
            MsgBox(0, 'You clicked:', 'Yes')
            Exit
        Case $IDNo
            MsgBox(0, 'You clicked:', 'No')
    EndSwitch
WEnd

 

Share this post


Link to post
Share on other sites
caramen

It s working anyway so, this is just a preference thing :) Thx for the tips anyway. 

 

Case $BoutonWhrite1
                 $Case1 =  MsgBox (4,"Are you sure ?" ,"Reg key gonna be changed." )
                    If $Case1 = 7 Then
                       ConsoleWrite(">Case -1 Started" & @CRLF)
                    ElseIf $Case1 = 6 Then
                        $InputType1 = InputBox ("Value Type ?", 'Ecrivez le type de clef:'& @CRLF&'"REG_SZ", "REG_MULTI_SZ", "REG_EXPAND_SZ", "REG_DWORD", "REG_QWORD", or "REG_BINARY".' )
                        If $InputType1 = 'REG_SZ' Or 'REG_MULTI_SZ' Or 'REG_EXPAND_SZ' Or 'REG_DWORD' Or 'REG_QWORD' Or 'REG_BINARY' Then
                           MsgBox($MB_SYSTEMMODAL, "", $InputType1&" was entered")
                           ConsoleWrite(">Registre ecri" & @CRLF)
;~                      RegWrite (""&$Reg1,""&$RegName1,""&$InputType1, ""&$RegValue1)
                        Else
                           ConsoleWrite(">Registre non ecri" & @CRLF)
                        MsgBox($MB_SYSTEMMODAL, "Attention", "Le type n'est pa correct")
                        EndIf
                    EndIf

New probleme i use Input box to get the Reg key added but i want to add a security check

If the type is not like in the condition then Msgbox 

 

Why the returned value of the inputbox is activating the first condition always ??? even if i type ALLo or test or lol i want to passe it only in these case : 

'REG_SZ' Or 'REG_MULTI_SZ' Or 'REG_EXPAND_SZ' Or 'REG_DWORD' Or 'REG_QWORD' Or 'REG_BINARY'

 

but seem like it s totaly ignoring them 

 

Rofl i dont get it... So easy syntax but not working LOL ...........:'(

 

Edited by caramen

Share this post


Link to post
Share on other sites
caramen

ops i got it : 

If $InputType1 = 'REG_SZ' Or $InputType1 = 'REG_MULTI_SZ' Or $InputType1 ='REG_EXPAND_SZ' Or $InputType1 ='REG_DWORD' Or $InputType1 ='REG_QWORD' Or $InputType1 ='REG_BINARY' Then

@Synapsee

True... I am gonna do that

 

Edited by caramen

Share this post


Link to post
Share on other sites
VIP

my bad:
 

$Case1 = MsgBox(4, "Are you sure ?", "Reg key gonna be changed.")
If $Case1 = 7 Then
    ConsoleWrite(">Case -1 Started" & @CRLF)
Else
    $InputType1 = InputBox("Value Type ?", 'Ecrivez le type de clef:' & @CRLF & '"REG_SZ", "REG_MULTI_SZ", "REG_EXPAND_SZ", "REG_DWORD", "REG_QWORD", or "REG_BINARY".')
    If StringInStr('REG_SZ|REG_MULTI_SZ|REG_EXPAND_SZ|REG_DWORD|REG_QWORD|REG_BINARY', $InputType1, 1) Then
        MsgBox(64, "", $InputType1 & " was entered")
        ConsoleWrite(">Registre ecri" & @CRLF)
;~                      RegWrite (""&$Reg1,""&$RegName1,""&$InputType1, ""&$RegValue1)
    Else
        ConsoleWrite(">Registre non ecri" & @CRLF)
        MsgBox(48, "Attention", "Le type n'est pa correct")
    EndIf
EndIf

 


Regards,
 

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

    • fenhanxue
      By fenhanxue
      in msdn :https://msdn.microsoft.com/en-us/library/windows/desktop/aa384045(v=vs.85).aspx
      it says:

       
      I want to how how can i get the Return value (S_OK  or  error value )
      here is my codes as follow:
      Local $post_data = '123' Local $post_url = 'http://127.0.0.1/test.php' Local $oHTTP = ObjCreate("WinHttp.WinHttpRequest.5.1") $oHTTP.Open("POST", $post_url, True) Local $Return_Value = $oHTTP.Send($post_data) $oHTTP.WaitForResponse(-1) Local $res = $oHTTP.responsetext MsgBox(0,'$Return_Value',$Return_Value);IT shows nothing ;why ? how can i get S_OK or error value ?  
    • 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
    • Verssuss
      By Verssuss
      hi guys i want avoid to multiple MsgBox by hold Hotkey "]" in my script
       
      #include <GuiConstantsEx.au3> #include <Windowsconstants.au3> #include <SendMessage.au3> #include <WinAPI.au3> ;~ HotKeySet("{[}", "_boxminus") HotKeySet("{]}", "_boxplus") HotKeySet("{ESC}", "On_Exit") $hGUI = GUICreate("", 100, 100, -1, -1, $WS_POPUP, BitOr($WS_EX_LAYERED, $WS_EX_COMPOSITED, $WS_EX_TOPMOST)) GUISetBkColor(0x00FF00) GuiCtrlCreateLabel("", 3, 3, 94, 94) GUICtrlSetBkColor(-1, 0xABCDEF) GUICtrlSetResizing(-1, $GUI_DOCKBORDERS) GUISetState() _WinAPI_SetLayeredWindowAttributes($hGui, 0xABCDEF) $box_range = 100 While 1 $pos = MouseGetPos() WinMove($hGUI, "", $pos[0] - ($box_range / 2), $pos[1] - ($box_range / 2), $box_range, $box_range) WEnd ;~ Func _boxminus() ;~ If $box_range >= 30 Then $box_range = $box_range - 10 ;~ If $box_range < 30 Then $box_range = $box_range - 1 ;~ EndFunc Func _boxplus() If $box_range < 200 Then $box_range = $box_range + 10 Else MsgBox(0,"ERROR", "Maximum size already exist") EndIf EndFunc Func On_Exit() Exit EndFunc i wish after i get first MsgBox another gonna replaced with first one or just cancel in and apeear again
      how can i make it right ???
×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.