Jump to content

is controlsend not support with winlist ??


 Share

Recommended Posts

hii all i know that's may be an old question ( winlist ) _ but i cant find my purpose at the search

> i have now 2 windows of (NOTEPAD) i wann from my script to send to the first one "123" then switch to the other one and type "456" >> all that at minimized state

#include <GUIConstantsEx.au3>
#Include <GuiListView.au3>

HotKeySet("{f9}","bb") 

Global $Client[1][1], $Array[1]

$Form1 = GUICreate("text Manager", 260, 170, 50, 50)
$listview = GUICtrlCreateListView("text", 8, 8, 250, 150, BitOR($LVS_SORTDESCENDING, $LVS_LIST, $LVS_SHOWSELALWAYS))

_Refresh()

Func _Refresh()
    _GUICtrlListView_BeginUpdate($listview)
    _GUICtrlListView_DeleteAllItems($listview)
    $Client = WinList("Untitled - Notepad")
    If $Client[0][0] > 0 Then
        For $X = 1 To $Client[0][0]
            GUICtrlCreateListViewItem($Client[$X][0], $listview)
        Next
    Else
        GUICtrlCreateListViewItem("NOTEPAD No Found", $listview)
    EndIf
    _GUICtrlListView_EndUpdate($listview)
EndFunc
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
WEnd
Func bb()
  For $X = 1 To $Client[0][0]
ControlSend("","",_GUICtrlListView_GetSelectedIndices $Client[$x][0],"123")
Next
For $X = 2 To $Client[0][0]
    ControlSend("","",_GUICtrlListView_GetSelectedIndices $Client[$x][0],"456")
    Next
    EndFunc

> i didn't wann to make it by winactive i just wann to make it by the selection from winlist

--- select the notepad then push _f9_

----------- can some one help me by scripts or any idea ??

Link to comment
Share on other sites

#include <GUIConstantsEx.au3>
#Include <GuiListView.au3>
HotKeySet("{f9}","bb") 
$handle = WinGetHandle("Untitled - Notepad", "")
If @error Then
    MsgBox(0, "Error", "Could not find window")
EndIf
Global $Client[1][1], $Array[1]
$Form1 = GUICreate("text Manager", 260, 170, 50, 50)
$listview = GUICtrlCreateListView("text", 8, 8, 250, 150, BitOR($LVS_SORTDESCENDING, $LVS_LIST, $LVS_SHOWSELALWAYS))
_Refresh()
Func _Refresh()
    _GUICtrlListView_BeginUpdate($listview)
    _GUICtrlListView_DeleteAllItems($listview)
    $Client = WinList($handle)
    If $Client[0][0] > 0 Then
        For $X = 1 To $Client[0][0]
            GUICtrlCreateListViewItem($Client[$X][0], $listview)
        Next
    Else
        GUICtrlCreateListViewItem("NOTEPAD No Found", $listview)
    EndIf
    _GUICtrlListView_EndUpdate($listview)
EndFunc
GUISetState(@SW_SHOW)
While 1
    $nMsg = GUIGetMsg()
WEnd
Func bb()
  For $X = 1 To $Client[0][0]
ControlSend("","",_GUICtrlListView_GetSelectedIndices $Client[$x][0],"123")
Next
For $X = 2 To $Client[0][0]
    ControlSend("","",_GUICtrlListView_GetSelectedIndices $Client[$x][0],"456")
    Next
    EndFunc

doesn't work >>>> can u upload example about how to send keys to a same multiplier windows ??!

Link to comment
Share on other sites

#include <GUIConstantsEx.au3>
#Include <GuiListView.au3>
HotKeySet("{f9}","bb") 
$handle = WinGetHandle("Untitled - Notepad", "")
If @error Then
    MsgBox(0, "Error", "Could not find window")
EndIf
Global $Client[1][1], $Array[1]
$Form1 = GUICreate("text Manager", 260, 170, 50, 50)
$listview = GUICtrlCreateListView("text", 8, 8, 250, 150, BitOR($LVS_SORTDESCENDING, $LVS_LIST, $LVS_SHOWSELALWAYS))
_Refresh()
Func _Refresh()
    _GUICtrlListView_BeginUpdate($listview)
    _GUICtrlListView_DeleteAllItems($listview)
    $Client = WinList($handle)
    If $Client[0][0] > 0 Then
        For $X = 1 To $Client[0][0]
            GUICtrlCreateListViewItem($Client[$X][0], $listview)
        Next
    Else
        GUICtrlCreateListViewItem("NOTEPAD No Found", $listview)
    EndIf
    _GUICtrlListView_EndUpdate($listview)
EndFunc
GUISetState(@SW_SHOW)
While 1
    $nMsg = GUIGetMsg()
WEnd
Func bb()
  For $X = 1 To $Client[0][0]
ControlSend("","",_GUICtrlListView_GetSelectedIndices $Client[$x][0],"123")
Next
For $X = 2 To $Client[0][0]
    ControlSend("","",_GUICtrlListView_GetSelectedIndices $Client[$x][0],"456")
    Next
    EndFunc

doesn't work >>>> can u upload example about how to send keys to a same multiplier windows ??!

Hi,

1) It seems that your array $Client isn't fill with values or your posted code is only a partitial view.

2) You missed some brackets: _GuiCtrlListView_GetSelectedIndices ($Client[$x] [0], "456") e.g

;-))

Stefan

Link to comment
Share on other sites

Hi,

1) It seems that your array $Client isn't fill with values or your posted code is only a partitial view.

2) You missed some brackets: _GuiCtrlListView_GetSelectedIndices ($Client[$x] [0], "456") e.g

;-))

Stefan

thx for replay _

but i still had prblem at sending keys i can't Combine both of controlsend %_GuiCtrlListView_GetSelectedIndices

i make search but there's nothing :)

Link to comment
Share on other sites

You should wait 24 hours before bumping a post.

Try using _SendMessage to directly communicate with the control. Don't know if it will work, but it is another direction to search in.

the problem isn't which way use to send but the real problem is how to recognize the windows / client ( it's had the same title & name)
Link to comment
Share on other sites

the problem isn't which way use to send but the real problem is how to recognize the windows / client ( it's had the same title & name)

You need to use the window handle, not the window title! See WinList() in the helpfile :)
Link to comment
Share on other sites

You need to use the window handle, not the window title! See WinList() in the helpfile B)

i know that ( i have to use handle coz there's two title ) but how to get the handle and include it with the right code to make the script work fine ??? i upload code but all what i get for now is just a suggestion :) _ i need some one to share his knowledge ;)
Link to comment
Share on other sites

If I've understood your requirements correctly, this should demonstrate how to do what you want.

#include <GuiListView.au3>
#include <GUIConstants.au3>


HotKeySet("{F9}", "bb")

Global $Client[1][1], $Array[1]

$Form1 = GUICreate("text Manager", 260, 170, 50, 50)
$listview = GUICtrlCreateListView("text", 8, 8, 250, 150, BitOR($LVS_SORTDESCENDING, $LVS_LIST, $LVS_SHOWSELALWAYS))
_Refresh()
GUISetState(@SW_SHOW)

Func _Refresh()
    _GUICtrlListView_BeginUpdate($listview)
    _GUICtrlListView_DeleteAllItems($listview)
    $Client = WinList("Untitled - Notepad")
    If $Client[0][0] > 0 Then
        For $X = 1 To $Client[0][0]
            GUICtrlCreateListViewItem($Client[$X][0], $listview)
        Next
    Else
        GUICtrlCreateListViewItem("NOTEPAD No Found", $listview)
    EndIf
    _GUICtrlListView_EndUpdate($listview)
EndFunc   ;==>_Refresh

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Func bb()
    ;Get array of selected items in listview
    Local $aSelected = _GUICtrlListView_GetSelectedIndices(ControlGetHandle("text Manager","",$listview),True)
    For $X = 1 To $aSelected[0]
        ;Send text to selected windows
        ;Add 1 to listview index as it starts at 0 and $client index starts at 1
        ControlSend($Client[$aSelected[$X]+1][1],"","Edit1", "This is Window " & $aSelected[$X]+1 & @LF)
    Next
EndFunc   ;==>bb
Edited by Bowmore

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

Link to comment
Share on other sites

use winlist then search for notepad, this will return two elements. element 1 is your first instance, element 2 is your second. With each element you get get the handles. It will be like classNN but with windows, Notepad1, Notepad2.

Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

Link to comment
Share on other sites

If I've understood your requirements correctly, this should demonstrate how to do what you want.

#include <GuiListView.au3>
#include <GUIConstants.au3>


HotKeySet("{F9}", "bb")

Global $Client[1][1], $Array[1]

$Form1 = GUICreate("text Manager", 260, 170, 50, 50)
$listview = GUICtrlCreateListView("text", 8, 8, 250, 150, BitOR($LVS_SORTDESCENDING, $LVS_LIST, $LVS_SHOWSELALWAYS))
_Refresh()
GUISetState(@SW_SHOW)

Func _Refresh()
    _GUICtrlListView_BeginUpdate($listview)
    _GUICtrlListView_DeleteAllItems($listview)
    $Client = WinList("Untitled - Notepad")
    If $Client[0][0] > 0 Then
        For $X = 1 To $Client[0][0]
            GUICtrlCreateListViewItem($Client[$X][0], $listview)
        Next
    Else
        GUICtrlCreateListViewItem("NOTEPAD No Found", $listview)
    EndIf
    _GUICtrlListView_EndUpdate($listview)
EndFunc   ;==>_Refresh

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Func bb()
    ;Get array of selected items in listview
    Local $aSelected = _GUICtrlListView_GetSelectedIndices(ControlGetHandle("text Manager","",$listview),True)
    For $X = 1 To $aSelected[0]
        ;Send text to selected windows
        ;Add 1 to listview index as it starts at 0 and $client index starts at 1
        ControlSend($Client[$aSelected[$X]+1][1],"","Edit1", "This is Window " & $aSelected[$X]+1 & @LF)
    Next
EndFunc   ;==>bb

it's work ty :)
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...