Jump to content

_SendMessage Failing


Skrip
 Share

Recommended Posts

In two seperate scripts,

Run this:

#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
#include <SendMessage.au3>
$hGUI = GUICreate("Test", 500, 50)
$hEdit = GUICtrlCreateInput("TEST", 10, 10, 400, 20, $ES_PASSWORD)
GUISetState()

;~ ConsoleWrite(_SendMessage(GUICtrlGetHandle($hEdit), $EM_SETPASSWORDCHAR, 0, 0))
Do
    Sleep(100)
Until GUIGetMsg() = -3

Then this:

ConsoleWrite(ControlGetHandle("Test", "", "[CLASS:Edit]") & @CRLF)
If _SendMessage(ControlGetHandle("Test", "", "[CLASS:Edit]"), $EM_SETPASSWORDCHAR, 0) = @error Then ConsoleWriteError("The saddening error was: " & @error)

Why does _SendMessage fail? Is this a security feature of an input box or what is the issue?

Edited by Skrip

[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Link to comment
Share on other sites

I suspect you are simply not allowed to have one process screw around with that parameter in another process' GUI (with default permissions, any way). It works fine within the same script:

#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
#include <SendMessage.au3>

$iPWChar = 0
$hGUI = GUICreate("Test", 500, 110)
$idEdit = GUICtrlCreateInput("TEST", 20, 20, 460, 20, $ES_PASSWORD)
$hEdit = GUICtrlGetHandle(-1)
$idButton = GUICtrlCreateButton("CHANGE", 200, 60, 100, 30)
GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $idButton
            If $iPWChar Then
                $iPWChar = 0
            Else
                $iPWChar = 35 ; # char
            EndIf
            ConsoleWrite("$hEdit = " & $hEdit & "; $iPWChar = " & $iPWChar & @CRLF)
            $iRet = _SendMessage($hEdit, $EM_SETPASSWORDCHAR, $iPWChar)
            $iErrSav = @error
            ControlFocus($hGUI, "", $hEdit)
            ConsoleWrite("$iRet = " & $iRet & "; $iErrSav = " & $iErrSav & @LF)
    EndSwitch
WEnd

:graduated:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

If _SendMessage(ControlGetHandle("Test", "", "[CLASS:Edit]"), $EM_SETPASSWORDCHAR, 0) = @error Then ConsoleWriteError("The saddening error was: " & @error)
is horrible usage of that function call coupled with error checking. The odds of the return from _SendMessage() equaling the error level are pretty slim I think so you should be doing error checking separately.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

If _SendMessage(ControlGetHandle("Test", "", "[CLASS:Edit]"), $EM_SETPASSWORDCHAR, 0) = @error Then ConsoleWriteError("The saddening error was: " & @error)
is horrible usage of that function call coupled with error checking. The odds of the return from _SendMessage() equaling the error level are pretty slim I think so you should be doing error checking separately.

I know. I just threw it together because it was after midnight and I was trying to get to bed.

I understand the issue though.

[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

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