Jump to content

Recommended Posts

Posted (edited)

First off I want to say thanks for what an awesome community this is. I have created a few programs and taught myself a decent amount using everything I found in this forum, and I really appreciate it.

However, I haven't really seen anything related to my current problem, which is:

I'm having a problem using ControlSend() to send the ENTER key to Ventrilo.

I set up "Q" as a hotkey, so when I press it, its supposed to select the casually afk channel, which it successfully does.

Then it is supposed to hit the enter key to join the channel, which it doesn't successfully perform.

I've tested other keys, such as letters and the up/down keys, and they all work when Ventrilo is in the background, but enter doesnt. I've tried using controlsendplus() as well...

Is there any way to send the ENTER key to Vent? Or since it's a treeview, does it have to be an active window?

Thanks.

Heres my current code:

#include <GuiTreeView.au3>
HotKeySet("q", "test")
$in1 = "Ventrilo"
$htree = ControlGetHandle($in1, "", "SysTreeView321")
$node = _GUICtrlTreeView_FindItem($htree, "casually afk")
If $node Then
    While 1
        Sleep(2000)
        _GUICtrlTreeView_SelectItem($htree, $node)
    WEnd
Else
    MsgBox(0, 'Error', 'Channel not found')
EndIf



Func test()
    ControlSend("Ventrilo", "", "SysTreeView321", "{enter}")
EndFunc   ;==>test

Ive also tried using ControlTreeView() to use ControlSend()...still only works when its the active window.

Edited by arktikk
Posted

Im also curious if I should maybe use postmessage or sendmessage? Im very unfamilar with the functions, though, and sorry to bump this...

Posted (edited)

This should work, I`m not very sure because I don't have any node in Ventrilo for test. In case that this not work and you want just to expand one node [named:casually afk]you can try instead of send enter key to use _GUICtrlTreeView_ClickItem(). or better _GUICtrlTreeView_SetState()

#include <GuiTreeView.au3>

HotKeySet("q","SendEnter")
HotKeySet("{ESC}","Quit")

Global $HWND = WinGetHandle("Ventrilo")
$CTRL = ControlGetHandle($HWND,"","SysTreeView321") 
$ITEM = _GUICtrlTreeView_FindItem($CTRL,"casually afk")
If $ITEM <> 0 Then _GUICtrlTreeView_SelectItem($CTRL,$ITEM)

While True
    Sleep(10)
WEnd

Func SendEnter()
    ControlSend($HWND,"","SysTreeView321","{ENTER}")
EndFunc

Func Quit()
    Exit
EndFunc
Edited by Andreik
Posted

This should work, I`m not very sure because I don't have any node in Ventrilo for test. In case that this not work and you want just to expand one node [named:casually afk]you can try instead of send enter key to use _GUICtrlTreeView_ClickItem(). or better _GUICtrlTreeView_SetState()

#include <GuiTreeView.au3>

HotKeySet("q","SendEnter")
HotKeySet("{ESC}","Quit")

Global $HWND = WinGetHandle("Ventrilo")
$CTRL = ControlGetHandle($HWND,"","SysTreeView321") 
$ITEM = _GUICtrlTreeView_FindItem($CTRL,"casually afk")
If $ITEM <> 0 Then _GUICtrlTreeView_SelectItem($CTRL,$ITEM)

While True
    Sleep(10)
WEnd

Func SendEnter()
    ControlSend($HWND,"","SysTreeView321","{ENTER}")
EndFunc

Func Quit()
    Exit
EndFunc

i appreciate your attempt and help :) but this method doesnt work.

I want it to work when the window is NOT active, and for some reason the enter key only sends when it IS active.

I tried _GUICtrlTreeView_SetState($CTRL,$item,$TVIS_EXPANDED ,true) as well, no effect. ;)

  • 11 years later...
Posted

Hey All, Sorry to resurrect a dead thread, but I had the same issue and found a simple solution.

In my case, ControlSend doesn't seem to pass {ENTER} like other functions and actually sends the literal text {ENTER}, in cmd.exe windows at least (Win 10).

The trick is to use a carriage return instead, so:

 ControlSend ( "[CLASS:ConsoleWindowClass]", "", "", @CR,1)

Done!

Posted

I wouldn't assume that the docs infer that. It mentions special characters to indicate SHIFT and ALT presses.
Hitting enter is neither a special character nor does it involve SHIFT/ALT.

Perhaps the RAW method would help OP, wherever they are now.
 

FYI

https://www.autoitscript.com/autoit3/docs/functions/ControlSend.htm

   $SEND_DEFAULT (0) = Text contains special characters like + and ! to indicate SHIFT and ALT key-presses (default).
    $SEND_RAW (1) = keys are sent raw.

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...