Sign in to follow this  
Followers 0
jp10558

_MsgBoxEx gives different returns on XP and Win7

4 posts in this topic

So I've looked at my problem a bit, and I'm using this autoIT code to get results, but to change the Yes/No to Now/Later:

Local $ChangeText[3] = ['', 'Now', 'Later']
$text = "This update will install Microsoft Office 2007." & @CRLF & @CRLF & "This update will install Outlook." & @CRLF & "This will only update the core Office Products: Word, Excel, and Powerpoint."& @CRLF & "Other products from Office 2003 core will be removed."& @CRLF & @CRLF & "Any other products will need to be requested via RT."& @CRLF & "Please CLOSE ALL Microsoft Office applications. This install will take between 1 and 3 hours to complete."& @CRLF & "Your computer will be slower than normal during this install. DO NOT use any office products until the install is complete."& @CRLF & @CRLF & "Your computer MAY restart at the end of the install."
While 1
    $answer = _MsgBoxEx(4, 'Install Office 2007', $text,0,$ChangeText)
    Sleep (500)
    If $answer = 6 then 
        Sleep (500)
        ExitLoop
    Else
        Sleep (3600000)
    EndIf
    
WEnd


ProcessClose("MSACCESS.EXE")
ProcessClose("EXCEL.EXE")
ProcessClose("INFOPATH.EXE")
ProcessClose("POWERPNT.EXE")
ProcessClose("MSPUB.EXE")
ProcessClose("WINWORD.EXE")

DirRemove("C:\officetemp",1)
DirCopy("officetemp","C:\officetemp",1)
Run("C:\officetemp\setup.exe","C:\officetemp",@SW_HIDE)



Func _MsgBoxEx($iFlag, $sTitle, $sText, $iTime = 0, $sCIDChange = '')
    Local $_MsgBox_ = '"' & "ConsoleWrite(MsgBox(" & $iFlag & ', ""' & $sTitle & '"", ""' & $sText & '"", ' & $iTime & '"))'
    Local $iPID = Run(@AutoItExe & ' /AutoIt3ExecuteLine ' & $_MsgBox_, '', @SW_SHOW, 6)
    Do
        Sleep(10)
    Until WinExists($sTitle)
    If IsArray($sCIDChange) Then
        For $iCC = 1 To UBound($sCIDChange) - 1
            ControlSetText($sTitle, '', 'Button' & $iCC, $sCIDChange[$iCC])
        Next
    Else
        ControlSetText($sTitle, '', 'Button1', $sCIDChange)
    EndIf
    While ProcessExists($iPID)
        Local $iStdOut = StdoutRead($iPID)
        If Number($iStdOut) Then Return $iStdOut
        Sleep(10)
    WEnd
    If IsArray($sCIDChange) Then Return SetError(1, 0, 2)
    Return SetError(1, 0, 1)
EndFunc

What's weird is this works correctly on XP. Selecting Now gives a return of 6 on XP, but 2 on Windows 7 x64... Is this a bug or am I confused somehow?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I'm on Windows 7x32, and running:

Local $ChangeText[3] = ['', 'Now', 'Later']
ConsoleWrite(_MsgBoxEx(4, 'Install Office 2007', "hi",0,$ChangeText)&@CRLF)

Func _MsgBoxEx($iFlag, $sTitle, $sText, $iTime = 0, $sCIDChange = '')
    Local $_MsgBox_ = '"' & "ConsoleWrite(MsgBox(" & $iFlag & ', ""' & $sTitle & '"", ""' & $sText & '"", ' & $iTime & '"))'
    Local $iPID = Run(@AutoItExe & ' /AutoIt3ExecuteLine ' & $_MsgBox_, '', @SW_SHOW, 6)
    Do
        Sleep(10)
    Until WinExists($sTitle)
    If IsArray($sCIDChange) Then
        For $iCC = 1 To UBound($sCIDChange) - 1
            ControlSetText($sTitle, '', 'Button' & $iCC, $sCIDChange[$iCC])
        Next
    Else
        ControlSetText($sTitle, '', 'Button1', $sCIDChange)
    EndIf
    While ProcessExists($iPID)
        Local $iStdOut = StdoutRead($iPID)
        If Number($iStdOut) Then Return $iStdOut
        Sleep(10)
    WEnd
    If IsArray($sCIDChange) Then Return SetError(1, 0, 2)
    Return SetError(1, 0, 1)
EndFunc
and clicking "Now" returns 6 for me. Maybe it's an x64 thing?

What happens on your x64 if you run

ConsoleWrite(MsgBox(4,"hi","test")&@CRLF)
and click "Yes"? Edited by james3mg

"There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110

Share this post


Link to post
Share on other sites

I get 6 on WIN7 X64 with this testscript:

$text = "This update will install Microsoft Office 2007." & @CRLF & @CRLF & "This update will install Outlook." & @CRLF & "This will only update the core Office Products: Word, Excel, and Powerpoint."& @CRLF & "Other products from Office 2003 core will be removed."& @CRLF & @CRLF & "Any other products will need to be requested via RT."& @CRLF & "Please CLOSE ALL Microsoft Office applications. This install will take between 1 and 3 hours to complete."& @CRLF & "Your computer will be slower than normal during this install. DO NOT use any office products until the install is complete."& @CRLF & @CRLF & "Your computer MAY restart at the end of the install."
While 1
    $answer = _MsgBoxEx(4, 'Install Office 2007', $text,0,$ChangeText)
    ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $answer = ' & $answer & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
    Sleep (500)
    If $answer = 6 then
        Sleep (500)
        ExitLoop
    Else
        exit
    EndIf

WEnd


Func _MsgBoxEx($iFlag, $sTitle, $sText, $iTime = 0, $sCIDChange = '')
    Local $_MsgBox_ = '"' & "ConsoleWrite(MsgBox(" & $iFlag & ', ""' & $sTitle & '"", ""' & $sText & '"", ' & $iTime & '"))'
    Local $iPID = Run(@AutoItExe & ' /AutoIt3ExecuteLine ' & $_MsgBox_, '', @SW_SHOW, 6)
    Do
        Sleep(10)
    Until WinExists($sTitle)
    If IsArray($sCIDChange) Then
        For $iCC = 1 To UBound($sCIDChange) - 1
            ControlSetText($sTitle, '', 'Button' & $iCC, $sCIDChange[$iCC])
        Next
    Else
        ControlSetText($sTitle, '', 'Button1', $sCIDChange)
    EndIf
    While ProcessExists($iPID)
        Local $iStdOut = StdoutRead($iPID)
        If Number($iStdOut) Then Return $iStdOut
        Sleep(10)
    WEnd
    If IsArray($sCIDChange) Then Return SetError(1, 0, 2)
    Return SetError(1, 0, 1)
EndFunc

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

I get 6 on WIN7 X64 with this testscript:

<snip>

Weird. When I used

$answer = _MsgBoxEx(4, 'Install Office 2007', $text,0,$ChangeText)
    Sleep (500)
    MsgBox(0,"Status","$answer = " & $answer)

The pop-up shows 2 in Win 7 x64 VM running on RedHat's KVM... I wonder if it's related to the Virtualization platform somehow? Well, my current need has been obviated by different instructions from management, and knowing this isn't strictly an AutoIT bug, I'll hope it's KVM related...

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  
Followers 0