Auto type in chat

Ask gaming related questions (AHK v1.1 and older)
MajesticRaven
Posts: 6
Joined: 31 Mar 2021, 19:34

Re: Auto type in chat

Post by MajesticRaven » 01 Apr 2021, 19:27

Code: Select all

wTitle := "ahk_class Chrome_WidgetWin_1 ahk_exe Discord.exe", control := "ahk_parent"
^`::
If !WinExist(wTitle) {
 MsgBox, 48, Error, Window was not found.`n`n%wTitle%
 Return
} Else SoundBeep, 1500, 120
ControlSend, %control%, {Text}:-b, %wTitle%
Sleep, 900
SetTimer, Go, 10000
SetTimer, Stop, -1100000
Go:
ControlSend, %control%, {Enter}   , %wTitle%
Return
Stop:
SetTimer, Go, Off
Return
^^code used^^

ok so its working for the most part. the major issue is it not repeating the action until the stop timer goes off, its typing it one time and entering it soon after i start the script but then it seems as if the script is done at that point and doesn't repeat per go timer.

minor issue, which I was hoping/thinking we fixed with the AHK. command line is I still need to have the curser selecting the desired chat box for the script to insert and enter. meaning the script wont work as I am multi tasking other programs

User avatar
mikeyww
Posts: 26601
Joined: 09 Sep 2014, 18:38

Re: Auto type in chat

Post by mikeyww » 01 Apr 2021, 20:29

Code: Select all

wTitle := "ahk_class Chrome_WidgetWin_1 ahk_exe Discord.exe", control := "ahk_parent"
^`::
If !WinExist(wTitle) {
 MsgBox, 48, Error, Window was not found.`n`n%wTitle%
 Return
} Else SoundBeep, 1500, 120
ControlSend, %control%, {Text}:-b ; Initial text
Sleep, 900
SetTimer, Go  ,   60112           ; Timer frequency
SetTimer, Stop, -180000           ; Stop after this interval
; -------------------------------------------
; Timed loop
Go:
ControlSend, %control%, {Text}::-b, %wTitle%
ControlSend, %control%, {Enter}   , %wTitle%
Return
; -------------------------------------------
Stop:
SetTimer, Go, Off
Return

MajesticRaven
Posts: 6
Joined: 31 Mar 2021, 19:34

Re: Auto type in chat

Post by MajesticRaven » 01 Apr 2021, 21:34

so I was eating diner and the idea flashed in my head. I got it working, it ends up leaving an unsent text in the chat box so I'm sure I'm missing an {enter} somewhere but its working so I don't feel like looking a gift horse in the mouth

I can post the problem/solution if you care to know, otherwise I super appreciate everything you have done I defiantly couldn't of done anything with out you!! :bravo: :rainbow: :superhappy:

User avatar
mikeyww
Posts: 26601
Joined: 09 Sep 2014, 18:38

Re: Auto type in chat

Post by mikeyww » 01 Apr 2021, 21:38

Good!

I do not have a way to test, but this is an alternative in case it helps.

Code: Select all

wTitle := "ahk_class Chrome_WidgetWin_1 ahk_exe Discord.exe", control := "ahk_parent"
^`::
If !WinExist(wTitle) {
 MsgBox, 48, Error, Window was not found.`n`n%wTitle%
 Return
} Else SoundBeep, 1500, 120
SetTimer, Go  ,   60112           ; Timer frequency
SetTimer, Stop, -180000           ; Stop after this interval
; -------------------------------------------
; Timed loop
Go:
ControlSend, %control%, {Text}::-b, %wTitle%
ControlSend, %control%, {Enter}   , %wTitle%
Return
; -------------------------------------------
Stop:
SetTimer, Go, Off
Return

bucke
Posts: 1
Joined: 26 Aug 2019, 07:08

Re: Auto type in chat

Post by bucke » 03 Apr 2021, 18:47

Im having trouble ControlSending {Down} = DownArrowKey to BlueStacks

This is what my code looks like and the above ControlClick works perfectly...

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
SetTitleMatchMode, 2

Numpad3::
Loop
{
ControlClick, x297 y954, BlueStacks
Sleep, 1000
ControlSend, BlueStacksApp1, {Down down}, BlueStacks
Sleep, 3500
}
return

#x::ExitApp ; Win+X to exit
[Mod edit: [code][/code] tags added.]

Any idea whats wrong with ControlSend?

User avatar
mikeyww
Posts: 26601
Joined: 09 Sep 2014, 18:38

Re: Auto type in chat

Post by mikeyww » 03 Apr 2021, 19:23

Since your script does not work, try a one-liner instead, until you get it working.

Code: Select all

F3::ControlSend, BlueStacksApp1, x, BlueStacks
Is BlueStacksApp1 really the name of the control?

Some windows do not respond to ControlSend. I do not use BlueStacks and so cannot test, but you could search the forum for this term, to look for examples.

Haruki
Posts: 3
Joined: 19 May 2022, 02:22

Re: Auto type in chat

Post by Haruki » 19 May 2022, 02:31

mikeyww wrote:
23 Mar 2021, 19:47

Code: Select all

Loop {
 Send {Text}/forage
 Sleep, 300000
}
hey umm can i randomize this loop timer? like every 2-3 mins instead of every 5 mins, or it can only be a constant value

User avatar
boiler
Posts: 16769
Joined: 21 Dec 2014, 02:44

Re: Auto type in chat

Post by boiler » 19 May 2022, 02:40

Haruki wrote: hey umm can i randomize this loop timer? like every 2-3 mins instead of every 5 mins, or it can only be a constant value

Code: Select all

Loop {
 Send {Text}/forage
 Random, Delay, 120000, 180000
 Sleep, Delay
}

Haruki
Posts: 3
Joined: 19 May 2022, 02:22

Re: Auto type in chat

Post by Haruki » 19 May 2022, 02:57

tyvm

Haruki
Posts: 3
Joined: 19 May 2022, 02:22

Re: Auto type in chat

Post by Haruki » 24 Jun 2022, 02:23

Also can i put multiple loops with different delays in one script? i tried few thing didnt work

User avatar
mikeyww
Posts: 26601
Joined: 09 Sep 2014, 18:38

Re: Auto type in chat

Post by mikeyww » 24 Jun 2022, 05:26

Could try SetTimer, because an infinite loop will not get you to the next loop without a Break, etc.

Post Reply

Return to “Gaming Help (v1)”