Alternative to ControlSend

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Baldemord
Posts: 1
Joined: 01 Apr 2017, 05:45

Alternative to ControlSend

01 Apr 2017, 06:05

Hello everyone,

I have a few skripts which use ControlSend in combination with "WinGet, active_id," to send keystrokes to specific windows.
The problem with ControlSend is, that I can not use CTRL or ALT ect. while they are active since it effects the Script.
Is there any alternative to ControlSend in this case?

Here is my code:

Code: Select all

playing:=false

^Up::
if (!playing) {
	WinGet, active_id, ID, A
	SetTimer, 1, 150
	SetTimer, 2, 19500
	SetTimer, 3, 1805000						
	playing:=true
}
return

^Down::
if (playing) {
	SetTimer, 1, Off
	SetTimer, 2, Off
	SetTimer, 3, Off
	playing:=false
}
return


1:

	ControlSend, , 1, ahk_id %active_id%
	Sleep 50
	ControlSend, , v, ahk_id %active_id%
	Sleep 50
	ControlSend, , 4, ahk_id %active_id%
	
return


2:

	SetTimer, 1, Off
	Sleep 1250
	ControlSend, , 2, ahk_id %active_id%
	Sleep 1000
	ControlSend, , 3, ahk_id %active_id%
	Sleep 2000
	ControlSend, , 5, ahk_id %active_id%
	SetTimer, 1, On

return


3:

	SetTimer, 1, Off
	SetTimer, 2, Off
	Sleep 1000
	ControlSend, , 6, ahk_id %active_id%
	Sleep 500
	SetTimer, 1, On
	SetTimer, 2, On
return
I want to be able to run more than one script at a time that can also send keystrokes to minimized windows.

Thanks in advance!

Baldemord
User avatar
SnowFlake
Posts: 368
Joined: 28 Apr 2015, 05:41
Contact:

Re: Alternative to ControlSend

11 Apr 2017, 16:04

you could try editing the programs memory/game and set the values to the once you want that way you dont have to have the game/program opend all the time, but its not so easy to do and also do you mind saying what program or game the script is for and what OS you are on?
:yawn:
Darayavahus
Posts: 36
Joined: 21 May 2016, 03:32

Re: Alternative to ControlSend

13 Apr 2017, 02:12

Try sending unicode characters with Controlsend, this way they should not be interrupted by any additional key modifiers. (only issue with this i found are function keys)

Below function i made that stringsplits "String" you provide and sends it to "ahk_id %ID%" process.

Code: Select all

CSend(String,ID)
{
SC_Table := Object()
SC_Table := {1:"61",2:"62",3:"63",4:"64",5:"65",6:"66",7:"67",8:"68",9:"69",10:"6A",11:"6B",12:"6C",13:"6D",14:"6E",15:"6F",16:"70",17:"71",18:"72",19:"73",20:"74",21:"75",22:"76",23:"77",24:"78",25:"79",26:"7A",27:"41",28:"42",29:"43",30:"44",31:"45",32:"46",33:"47",34:"48",35:"49",36:"4A",37:"4B",38:"4C",39:"4D",40:"4E",41:"4F",42:"50",43:"51",44:"52",45:"53",46:"54",47:"55",48:"56",49:"57",50:"58",51:"59",52:"5A",53:"30",54:"31",55:"32",56:"33",57:"34",58:"35",59:"36",60:"37",61:"38",62:"39",63:"21",64:"40",65:"23",66:"24",67:"25",68:"26",69:"5F",70:"2B",71:"2D",72:"3D",73:"2C",74:"27",75:"20",76:"3B",77:"28",78:"29",79:"",80:"",81:"",82:"",83:"",84:"",85:"",86:"",87:"",88:"",89:"",90:"",91:"",92:"",93:"",94:"",95:"",96:"",97:"",98:"",99:"",100:""}
ID_Table := "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%&_+-=,' ;()"
Loop % StrLen(String)
{
Part := SubStr(String,A_Index,1)
Pos := InStr(ID_Table,Part,1,1,1)
SC := SC_Table[Pos]
ControlSend,,{u+%SC%},AHK_ID %ID%
}}

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: apeironn, Bing [Bot], Chunjee and 246 guests