Jump to content
Sign in to follow this  
greendragon

why do i get return value "0" of the controlsend function?

Recommended Posts

greendragon

#include <SendMessage.au3>
#include <MsgBoxConstants.au3>

ShellExecute("C:\Users\drake\Desktop\toggle.lnk")
Local $hw = WinWait("toggle", "", 2)
Local $result = ControlSend($hw, "", "TEdit2", "sewsfd")
MsgBox($MB_OK, "", $result)
WinClose($hw) 

why do i get return value "0" of the controlsend function?

 

i used the controlsend function on notepad

at that time i succeed

 

but on some application 

when i used the controlsend function 

it returned value "0"

 

how i can get retrun value "1"?

 

help me ~

Edited by greendragon

Share this post


Link to post
Share on other sites
somdcomputerguy

From the Help file / ControlSend

Success: 1.

Failure: 0 if window/control is not found.

pay attention to the cause of return code 0. Edited by somdcomputerguy

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites
jdelaney

There are too many potential fail points for us to speculate, especially because there is no error checking, except for when you output the $result...do it like this, so you know what's wrong...it's more code, but explicit...there are still some check steps you should do, like waiting for the window to be a state of enabled, verifing the control is enabled, etc:

$bContinue = ShellExecute("C:\Users\drake\Desktop\toggle.lnk")
If $bContinue Then
    ConsoleWrite("Shell execute returned true")
Else
    ConsoleWrite("Shell execute returned false")
EndIf

If $bContinue Then
    Local $hw = WinWait("toggle", "", 2)
    If IsHWnd($hw) Then
        ConsoleWrite("Able to find toggle window handle")
    Else
        ConsoleWrite("Unable to find toggle window handle")
        $bContinue = False
    EndIf
EndIf

If $bContinue Then
    Local $hc = ControlGetHandle("toggle", "", "TEdit2")
    If IsHWnd($hc) Then
        ConsoleWrite("Able to find TEdit2 control handle")
    Else
        ConsoleWrite("Unable to find TEdit2 control handle")
        $bContinue = False
    EndIf
EndIf

If $bContinue Then
    If ControlSend($hw, "", $hc, "sewsfd") Then
        ConsoleWrite("Able to send sewsfd")
    Else
        ConsoleWrite("Unable to send sewsfd")
        $bContinue = False
    EndIf
EndIf

edit: wrong number of nested endif's

Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

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  

×