Need to use ControlSend instead ControlClick

Ask gaming related questions (AHK v1.1 and older)
fenomen63
Posts: 7
Joined: 12 Nov 2023, 06:12

Need to use ControlSend instead ControlClick

20 Jan 2024, 02:56

Hi!
Right now im using something like this for my multiwindowed mmorpg

Code: Select all

#IfWinActive, druid

$F5::Reload


#Persistent

1::
DesiredWindowTitle := "druid"
WinGet, hWndList, List, %DesiredWindowTitle%
if (hWndList) {
    Loop, % hWndList {
        hWnd := hWndList%A_Index%

        
        ControlClick, x1120 y1042, tank, , left
        ControlClick, x1120 y1042, mag, , left
        ControlClick, x1120 y1042, var, , left
        ControlClick, x1120 y1042, prist, , left
        ControlClick, x1120 y1042, luk, , left

        Sleep, 100

        ControlClick, x649 y1045, druid, , left
        ControlClick, x649 y1045, tank, , left
        ControlClick, x649 y1045, mag, , left
        ControlClick, x649 y1045, var, , left
        ControlClick, x649 y1045, prist, , left
        ControlClick, x649 y1045, luk, , left


        
    }
}
Return
But I was faced with the need to switch to СontrolSend or Send in order to be able to click not with the mouse on a coordinate, but for example using the TAB key and etc, but I just can’t find a workable option that would work on several windows of my game at once, please help :crazy:

[Mod edit: Moved from AHK v2 help since this is v1 code.]
User avatar
mikeyww
Posts: 27137
Joined: 09 Sep 2014, 18:38

Re: Need to use ControlSend instead ControlClick

20 Jan 2024, 07:27

Hello,

Nothing will work on several windows at once, because the actions would need to occur sequentially, just as with all actions in a script.

I generally troubleshoot as follows.

1. See if a new two-line test script works. First, activate your window. Second, use Send to send your text.

2. If #1 works, test a new one-line script where you use ControlSend to send your text. Include a target control if possible.

Some windows do not respond to ControlSend. Some windows or program require elevated scripts. Some programs block scripting.

Searching the forum to see how others have solved the same problem with the same program is often fruitful.
fenomen63
Posts: 7
Joined: 12 Nov 2023, 06:12

Re: Need to use ControlSend instead ControlClick

20 Jan 2024, 10:43

Right now rightclick is working and i’ve seen that on other server other player using

Code: Select all

 $F5::Reload


#Persistent


2::
DesiredWindowTitle := "Avangard Season"
WinGet, hWndList, List, %DesiredWindowTitle%
if (hWndList) {
    Loop, % hWndList {
        hWnd := hWndList%A_Index%

        ControlSend, , 2, ahk_id %hWnd% ; Отправляем клавишу "7" в фоновое окно ; атака
        Sleep, 100
    }
}
Return

F6::
DesiredWindowTitle := "Avangard Season"
WinGet, hWndList, List, %DesiredWindowTitle%
if (hWndList) {
    Loop, % hWndList {
        hWnd := hWndList%A_Index%
        ControlSend, , {F6}, ahk_id %hWnd% ; Отправляем клавишу "7" в фоновое окно ; джин
        Sleep, 100
    }
}
Return



1::
DesiredWindowTitle := "Avangard Season"
WinGet, hWndList, List, %DesiredWindowTitle%
if (hWndList) {
    Loop, % hWndList {
        hWnd := hWndList%A_Index%
        ControlSend, , 1, ahk_id %hWnd% ; Отправляем клавишу "7" в фоновое окно ; шоты
        Sleep, 100
    }
}
Return








F3::
DesiredWindowTitle := "Avangard Season"
WinGet, hWndList, List, %DesiredWindowTitle%
if (hWndList) {
    Loop, % hWndList {
        hWnd := hWndList%A_Index%
        
        ; Отправляем клавишу Shift
        ControlSend, , {F3}, ahk_id %hWnd%
        Sleep, 50 ; медитация
       

    }
}
Return


 


counter := 1 ; Инициализация счетчика

XButton1:: ; При нажатии на правую боковую кнопку мыши (~ означает, что оригинальное действие кнопки тоже будет выполнено)
{
    if (counter = 10) ; Если счетчик достиг максимального значения, сбрасываем его
        counter := 0
    Send, #{%counter%} ; Отправляем сочетание Win + текущий номер счетчика
    counter++ ; Увеличиваем счетчик



    ; Завершаем обработчик события
}

 return

F4::
DesiredWindowTitle := "Avangard Season"
WinGet, hWndList, List, %DesiredWindowTitle%
if (hWndList) {
    Loop, % hWndList {
        hWnd := hWndList%A_Index%
        
        ; Отправляем клавишу Shift
        ControlSend, , {F4}, ahk_id %hWnd% ; бафы
       
    }
}
return ; Завершаем обработчик события






F12::
DesiredWindowTitle := "Avangard Season"
WinGet, hWndList, List, %DesiredWindowTitle%
if (hWndList) {
    Loop, % hWndList {
        hWnd := hWndList%A_Index%
        
        ; Отправляем клавишу Shift
        ControlSend, , {F12}, ahk_id %hWnd% ; бот
    }
}
return ; Завершаем обработчик события
Doing it on many game clients at once. But on my server his code doesnt working and idk why
User avatar
mikeyww
Posts: 27137
Joined: 09 Sep 2014, 18:38

Re: Need to use ControlSend instead ControlClick

20 Jan 2024, 11:18

I maintain my suggestion.

Unlabeled commands, expressions, or function calls following a Return command are unreachable and will never execute. You can confirm that quickly if needed.
fenomen63
Posts: 7
Joined: 12 Nov 2023, 06:12

Re: Need to use ControlSend instead ControlClick

21 Jan 2024, 01:11

Idk why you keep telling that it will not working on several windows at once cuz IT IS WORKING RIGHT NOWbut on my server only with ControlClick, on other server ControlSend is working too, so I just need some good thoughts how to make it working on my server too
User avatar
mikeyww
Posts: 27137
Joined: 09 Sep 2014, 18:38

Re: Need to use ControlSend instead ControlClick

21 Jan 2024, 06:37

OK. All I meant there is that the commands execute sequentially and not at the same time.

I provided an approach to troubleshooting this, but it seems that you would like a different approach, so perhaps someone on the forum here has one for you.

I noticed line 73 of your script earlier.

Code: Select all

counter := 1
I explained why this line will never execute. If you believe that it will execute, you can quickly confirm that by adjusting your script to prove it. Another way to approach this bug is to ask whether this line follows a Return command. If it does follow a Return command, you can determine how this line will ever execute. Return is not a filler but a command with a real effect on the script.
fenomen63
Posts: 7
Joined: 12 Nov 2023, 06:12

Re: Need to use ControlSend instead ControlClick

21 Jan 2024, 23:48

If you need a prove that controlsend macro that I mentioned earlier is working - https://youtu.be/gFEB52A4bQI?si=-AAy-HNAkvQTWlCv

Anyway im here not for discussions why and how its working, im not so good at writing macros, im just a regular player using it for my profit. If you dont have enough knowledge to help in my situation - I dont think our conversation can be effective
gregster
Posts: 9070
Joined: 30 Sep 2013, 06:48

Re: Need to use ControlSend instead ControlClick

22 Jan 2024, 04:03

@fenomen63, if you are not really interested in learning about AutoHotkey, I am not sure how you can expect to get effective help here. If I were you, I would take all the help and the knowledge which is offered to you.
We don't have your game to test, but a simple debugging strategy was laid out for you: start with a short script - if it works, then expand it incrementally. That should help to pinpoint the issue.

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: Bender and 24 guests