ControlSend being interrupted by special keys

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
DannyJulianto
Posts: 6
Joined: 18 Aug 2018, 23:48

ControlSend being interrupted by special keys

19 Aug 2018, 00:02

Hi guys,

I have a problem with my script that using ControlSend to sends text in specific window, I made the script to automatically send some messages in specific window. So the problems were that I'm working on other things else so sometimes I'd use special keys as CTRL, Shift and those keys would sometimes interfered with my script, for example : My script are going to send ".halo" for every 15sec, so sometimes it sent ">halo" because on another Windows I'm typing while holding Shift.
Can I prevent special keys from interfering with my scripts (not on top window)?

Thank you in advance.
Rohwedder
Posts: 7625
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: ControlSend being interrupted by special keys

19 Aug 2018, 01:22

Hallo,
place before your ControlSend:

Code: Select all

#InstallKeybdHook
While, A_TimeIdleKeyboard < 300 Or GetKeyState("Shift","P") Or GetKeyState("Alt","P") Or GetKeyState("LWin","P") Or GetKeyState("RWin","P") Or GetKeyState("Ctrl","P")
	Sleep, 50
Last edited by Rohwedder on 19 Aug 2018, 01:48, edited 1 time in total.
DannyJulianto
Posts: 6
Joined: 18 Aug 2018, 23:48

Re: ControlSend being interrupted by special keys

19 Aug 2018, 01:39

Could you please explain more about that? I can't get to my computer right now so I'll try it later as soon as possible.
Thank you for reply.
Rohwedder
Posts: 7625
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: ControlSend being interrupted by special keys

19 Aug 2018, 01:49

Hallo,
wait until you get to your computer so you can read the autohotkey manual!
User avatar
Scr1pter
Posts: 1272
Joined: 06 Aug 2017, 08:21
Location: Germany

Re: ControlSend being interrupted by special keys

19 Aug 2018, 05:04

Rohwedder wrote:Hallo,
wait until you get to your computer so you can read the autohotkey manual!
:mrgreen: :mrgreen: :mrgreen: :mrgreen:

But he's right, in the documentation you can find (almost) everything.
https://autohotkey.com/docs/AutoHotkey.htm
Read about some functions you want to use.
If you have questions, you can always ask ;)

Regards
Please use [code][/code] when posting code!
Keyboard: Logitech G PRO - Mouse: Logitech G502 LS - OS: Windows 10 Pro 64 Bit - AHK version: 1.1.33.09
DannyJulianto
Posts: 6
Joined: 18 Aug 2018, 23:48

Re: ControlSend being interrupted by special keys

19 Aug 2018, 06:59

Mhmm thanks that works, but pause toggle made my script not working normally since im using SetTimer. Pause toggle would make it keep the "keys" and then continued send next text, for example :
the script started just now, and i hold down CTRL for 5 secs after hold up the CTRL,, the script continued send the text for next 10seconds so the script ingored the "Sleep 15000" or meant it's just paused the script from send texts but neglecting the sleep commands.
So if I somehow accidentally hold it for a long times, it would spam my game xP, is there another way?

and thank you very much for the help
Sorry for my bad english.
DannyJulianto
Posts: 6
Joined: 18 Aug 2018, 23:48

Re: ControlSend being interrupted by special keys

19 Aug 2018, 07:23

Ah, I think the problem is fixed.. I just removed SetMouseDelay, -1 and SetKeyDelay, -1, -1, .
Tyvm Rohwedar & Scr1pter for refering documentation.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Anput and 200 guests