Send multiple keys when typing 1103 , 1105 and 4418 Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Prazul
Posts: 94
Joined: 05 Aug 2021, 15:55

Send multiple keys when typing 1103 , 1105 and 4418

05 Aug 2021, 16:03

Greetings,

I'm in need of a script wich should act as follow:

1) Detect when I type the number 1103 and 1105 from numpad and send the combinations of keys TAB, TAB, TAB
2) After third TAB pressed and released the cursor will be in a field where I should introduce the tommorrow day (e.g today is 6 august 2021, tommorrow is 7 august 2021, it should introduce only the number of the day , the number 7)
3) After the number 7 send again combination of keys TAB, TAB, TAB

Thanks in advance, I'm begginer and your help will save a lot of work of reading Help manual, :superhappy:

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

Re: Send multiple keys when typing 1103 , 1105 and 4418  Topic is solved

05 Aug 2021, 17:36

Code: Select all

:B0*:1103::
:B0*:1105::
Input, key, VL3, -()[]{}':;""/\`,.?! `n
If (key != "`t`t`t")
 Return
tomorrow := ""
tomorrow += 1, D
FormatTime, tomorrow, %tomorrow%, d
SendInput %tomorrow%{Tab 3}
Return
If you mean to send the Tabs instead:

Code: Select all

:B0*:1103::
:B0*:1105::
tomorrow := ""
tomorrow += 1, D
FormatTime, tomorrow, %tomorrow%, d
SendInput {Tab 3}%tomorrow%{Tab 3}
Return
Prazul
Posts: 94
Joined: 05 Aug 2021, 15:55

Re: Send multiple keys when typing 1103 , 1105 and 4418

06 Aug 2021, 02:41

If you mean to send the Tabs instead:

Code: Select all

:B0*:1103::
:B0*:1105::
tomorrow := ""
tomorrow += 1, D
FormatTime, tomorrow, %tomorrow%, d
SendInput {Tab 3}%tomorrow%{Tab 3}
Return

Hi Mikey. Thanks very much for help. Yes, the second code work very good. :dance: :bravo:
A last request if I can, please. :roll:
I wrote on picture. beloww
123.png
(159.12 KiB) Downloaded 316 times
User avatar
mikeyww
Posts: 26596
Joined: 09 Sep 2014, 18:38

Re: Send multiple keys when typing 1103 , 1105 and 4418

06 Aug 2021, 05:32

I leave the new request to you. Others may chime in with solutions. There are some other recent posts with similar scripts-- using Input, I believe.
User avatar
mikeyww
Posts: 26596
Joined: 09 Sep 2014, 18:38

Re: Send multiple keys when typing 1103 , 1105 and 4418

06 Aug 2021, 09:45

This example uses digits followed by a letter. You might be able to adapt it.

https://www.autohotkey.com/boards/viewtopic.php?p=413560#p413560
Prazul
Posts: 94
Joined: 05 Aug 2021, 15:55

Re: Send multiple keys when typing 1103 , 1105 and 4418

06 Aug 2021, 14:41

I appreciate your indications and intention to make me work for something to achieve. And I would do it with no hesitation BUT i'm very new to autohotkey and I don't know at all complex algorithms. It took me 2 weeks of tries to create these macros consulting, reading and re reading and re reading and so son, the help manual. And guess what, I don't have time to study, because I work. :cry: :headwall:

Code: Select all

LAlt & `::
MouseMove, 807, 360
MouseClick, left, 807, 360
Send, 1, {Tab}, 1
MouseClick, left, 535, 261
Send ^{V}
SetKeyDelay, 1
MouseClick, left, 295, 260
MouseClick, left, 350, 440
return


#MaxThreadsBuffer On
#MaxThreadsPerHotkey 50


LAlt & Q::
Send, +{Down}
Send, {Tab}
return
If you know the answer, why don't you give a hand of help? I wouldn't be here if I knew to made myself.

Anyway I understand you, you helped me a lot until now, so it's ok.

Thanks again.
Prazul
Posts: 94
Joined: 05 Aug 2021, 15:55

Re: Send multiple keys when typing 1103 , 1105 and 4418

06 Aug 2021, 15:27

mikeyww wrote:
06 Aug 2021, 09:45
This example uses digits followed by a letter. You might be able to adapt it.

https://www.autohotkey.com/boards/viewtopic.php?p=413560#p413560
Ok,
you are reffering to

Code: Select all

::100T::100000
Than mean when I press 100T on keyboard it will send the number "100000" .

But I have dozens of numbers :
123456T
564234T
987654T
....
xxxxxxT

So I will input random numbers before T every time, because I work with a database of clients and every client has it's own code for reference.

So if I follow this, then I shall create lots of macros each with it's own code. I have over 300 clients, so over 300 different codes.
That's why I need a code wich will make possible to listen for any six digits written followed by Letter
User avatar
boiler
Posts: 16768
Joined: 21 Dec 2014, 02:44

Re: Send multiple keys when typing 1103 , 1105 and 4418

06 Aug 2021, 15:50

If I understand what you are looking for (which I'm not sure of), this should do it:

Code: Select all

:?B0:T::
	ClipSave := ClipboardAll
	Clipboard := ""
	Send, +^{Left}^c^{Right}
	Entry := Clipboard
	Clipboard := ClipSave
	if (Entry ~= "^\d{6,}T")
		gosub, MyRoutine
return

MyRoutine:
LAlt & `::
	MouseMove, 807, 360
	MouseClick, left, 807, 360
	Send, 1, {Tab}, 1
	MouseClick, left, 535, 261
	Send ^v ; this is preferred over ^{V}
	SetKeyDelay, 1
	MouseClick, left, 295, 260
	MouseClick, left, 350, 440
return
Type 6 or more numbers followed by a T then a space or Enter or some other hotstring ending character, and it will launch your subroutine.
Prazul
Posts: 94
Joined: 05 Aug 2021, 15:55

Re: Send multiple keys when typing 1103 , 1105 and 4418

06 Aug 2021, 16:27

boiler wrote:
06 Aug 2021, 15:50
If I understand what you are looking for (which I'm not sure of), this should do it:

Code: Select all

:?B0:T::
	ClipSave := ClipboardAll
	Clipboard := ""
	Send, +^{Left}^c^{Right}
	Entry := Clipboard
	Clipboard := ClipSave
	if (Entry ~= "^\d{6,}T")
		gosub, MyRoutine
return

MyRoutine:
LAlt & `::
	MouseMove, 807, 360
	MouseClick, left, 807, 360
	Send, 1, {Tab}, 1
	MouseClick, left, 535, 261
	Send ^v ; this is preferred over ^{V}
	SetKeyDelay, 1
	MouseClick, left, 295, 260
	MouseClick, left, 350, 440
return
Type 6 or more numbers followed by a T then a space or Enter or some other hotstring ending character, and it will launch your subroutine.
Thanks boiler.

You understood the idea but the pre code doesn't work.
Just typed a code from six digits followed by letter D and sub routine didnt worked.
Also, after releasing letter D, should send {Tab 2} then wait for digits from 1 to 20 (1,2,3 4, 5,... 11, 12... 20) to be pressed on numpad. Right after that should run the sub routine as you said.
image.png
(158.92 KiB) Downloaded 230 times
User avatar
boiler
Posts: 16768
Joined: 21 Dec 2014, 02:44

Re: Send multiple keys when typing 1103 , 1105 and 4418

06 Aug 2021, 18:25

I thought you said the letter T somewhere. Below is the code modified for the letter d. But it's not after you release the letter. It's after you press d and then a space or enter like I said. I didn't make it do the part where it sends the other stuff and wait for other digits. I was just trying to show how you can get it to do the recognizing the 6+ digits followed by a d. Other things can be added.

Code: Select all

:?B0:T::
	ClipSave := ClipboardAll
	Clipboard := ""
	Send, +^{Left}^c^{Right}
	Entry := Clipboard
	Clipboard := ClipSave
	if (Entry ~= "^\d{6,}d")
		gosub, MyRoutine
return

MyRoutine:
LAlt & `::
	MouseMove, 807, 360
	MouseClick, left, 807, 360
	Send, 1, {Tab}, 1
	MouseClick, left, 535, 261
	Send ^v ; this is preferred over ^{V}
	SetKeyDelay, 1
	MouseClick, left, 295, 260
	MouseClick, left, 350, 440
return
Prazul
Posts: 94
Joined: 05 Aug 2021, 15:55

Re: Send multiple keys when typing 1103 , 1105 and 4418

07 Aug 2021, 01:10

boiler wrote:
06 Aug 2021, 18:25
I thought you said the letter T somewhere. Below is the code modified for the letter d. But it's not after you release the letter. It's after you press d and then a space or enter like I said. I didn't make it do the part where it sends the other stuff and wait for other digits. I was just trying to show how you can get it to do the recognizing the 6+ digits followed by a d. Other things can be added.

Code: Select all

:?B0:T::
	ClipSave := ClipboardAll
	Clipboard := ""
	Send, +^{Left}^c^{Right}
	Entry := Clipboard
	Clipboard := ClipSave
	if (Entry ~= "^\d{6,}d")
		gosub, MyRoutine
return

MyRoutine:
LAlt & `::
	MouseMove, 807, 360
	MouseClick, left, 807, 360
	Send, 1, {Tab}, 1
	MouseClick, left, 535, 261
	Send ^v ; this is preferred over ^{V}
	SetKeyDelay, 1
	MouseClick, left, 295, 260
	MouseClick, left, 350, 440
return

Dear boiler, I'm sorry I stress you with that, but the code doesn't work.
Nothing happen after I type six digits follower by letter D not even after I press Enter.

The code should start something with :

Code: Select all

:B0*:1103::
:B0*:1105::
as Mikey did earlier. But instead of 1103, wich are 4 digits, it should be six digits and not exactly 1103, could be any six digits, random digits (e.g 110033D , 322555D etc)
After D is pressed and released it should send {Tab 2} then wait for digits from 1 to 20 range (1,2,3 4, 5,... 11, 12... 20) to be pressed on numpad. Right after that should run the sub routine as you said.

Mikey's macro detect automatically the four digits 1103 and respectively 1105 and after that it continue with further commands.
I need a similar macro , detecting six digits, but should be aleatory these digits instead of fixed ones.

For example I have 3 clients, Bill, Will, Charlie

Bill have the code 123123D
Will have the code 321321D
Charlie have the code 112221D

Each of them has its unique identification code in database wich I will introduce from numpad .
So I will press on numpad for Bill 12123 and then the key D on keyboard and program will recognize the client, that is 123123D
After that, macro should continue with sending {Tab 2} and then wait for 2 digits sent from numpad again before continuing with execution of the subRoutine.
Last edited by Prazul on 07 Aug 2021, 04:54, edited 1 time in total.
User avatar
boiler
Posts: 16768
Joined: 21 Dec 2014, 02:44

Re: Send multiple keys when typing 1103 , 1105 and 4418

07 Aug 2021, 04:54

Prazul wrote: Dear boiler, I'm sorry I stress you with that, but the code doesn't work.
Nothing happen after I type six digits follower by letter D not even after I press Enter.
Sorry, I didn’t correct it fully for D instead of T. But I started changing it to be d since that’s what you said last time. I will make it for either d or D, and I’ll just have it trigger a MsgBox for testing:

Code: Select all

:?B0C1:D::
	ClipSave := ClipboardAll
	Clipboard := ""
	Send, +^{Left}^c^{Right}
	Entry := Clipboard
	Clipboard := ClipSave
	if (Entry ~= "i)^\d{6,}D")
		gosub, MyRoutine
return

MyRoutine:
	MsgBox, Subroutine starts here
return

Prazul wrote: The code should start something with :

Code: Select all

:B0*:1103::
:B0*:1105::"
No, it shouldn’t start with something like that. How could it start with some numbers when the numbers are unknown? Getting it to work for an unknown set of 6 or more digits is very different than the previous code of a couple known digit sequences, so the code will look very different. Here is how this code works: When it gets triggered by typing d or D followed by a space or Enter, it then checks what precedes it, and if it is 6 or more numeric digits, it launches the subroutine. If you know a better way, please tell me. I’m ready to learn.
Prazul
Posts: 94
Joined: 05 Aug 2021, 15:55

Re: Send multiple keys when typing 1103 , 1105 and 4418

07 Aug 2021, 05:25

boiler wrote:
07 Aug 2021, 04:54
Prazul wrote: Dear boiler, I'm sorry I stress you with that, but the code doesn't work.
Nothing happen after I type six digits follower by letter D not even after I press Enter.
Sorry, I didn’t correct it fully for D instead of T. But I started changing it to be d since that’s what you said last time. I will make it for either d or D, and I’ll just have it trigger a MsgBox for testing:

Code: Select all

:?B0C1:D::
	ClipSave := ClipboardAll
	Clipboard := ""
	Send, +^{Left}^c^{Right}
	Entry := Clipboard
	Clipboard := ClipSave
	if (Entry ~= "i)^\d{6,}D")
		gosub, MyRoutine
return

MyRoutine:
	MsgBox, Subroutine starts here
return

Prazul wrote: The code should start something with :

Code: Select all

:B0*:1103::
:B0*:1105::"
No, it shouldn’t start with something like that. How could it start with some numbers when the numbers are unknown? Getting it to work for an unknown set of 6 or more digits is very different than the previous code of a couple known digit sequences, so the code will look very different. Here is how this code works: When it gets triggered by typing d or D followed by a space or Enter, it then checks what precedes it, and if it is 6 or more numeric digits, it launches the subroutine. If you know a better way, please tell me. I’m ready to learn.
No no, you misunderstood me. I don't know better, the codes of Mikeys were just for example to better transmit the ideea so you better understand what I mean regarding reading the digits sents and how the macro should act after that. Will try your last input right now. Thanks.
Prazul
Posts: 94
Joined: 05 Aug 2021, 15:55

Re: Send multiple keys when typing 1103 , 1105 and 4418

07 Aug 2021, 07:53

Dear boiler, I tried and tried your code. For example when I send 007407D followed by Enter, nothing happen, no MsgBox appear. :cry:
Prazul
Posts: 94
Joined: 05 Aug 2021, 15:55

Re: Send multiple keys when typing 1103 , 1105 and 4418

07 Aug 2021, 08:06

Update:

Whoa whoa :o It work!!! :bravo:

The MsgBox appear succesfully when I press SPACE but not Enter. Does not work on Enter, just for SPACE.
Ok, until here it seem syntax is working.

I would like know if it's possible that instead of pressing SPACE, after releasing "d" key, if can can send {Tab 2} and after
inputing a number of two digits should execute My routine.
image.png
(217.88 KiB) Downloaded 155 times
User avatar
boiler
Posts: 16768
Joined: 21 Dec 2014, 02:44

Re: Send multiple keys when typing 1103 , 1105 and 4418

07 Aug 2021, 12:17

It could be made to not require a space, but that would cause it to check for the preceding numbers every time you typed a d or D instead of just at the end of a word. You might find it to be too disruptive to your typing. If you want it to work that way anyway, change the first line to this:

Code: Select all

:?B0C1*:D::
Prazul
Posts: 94
Joined: 05 Aug 2021, 15:55

Re: Send multiple keys when typing 1103 , 1105 and 4418

07 Aug 2021, 13:33

boiler wrote:
07 Aug 2021, 12:17
It could be made to not require a space, but that would cause it to check for the preceding numbers every time you typed a d or D instead of just at the end of a word. You might find it to be too disruptive to your typing. If you want it to work that way anyway, change the first line to this:

Code: Select all

:?B0C1*:D::
GrrREAT! :superhappy:

This one is what I'm looking for. Anyway in case I change my mind I have the other too. :bravo: :dance:
Thanks very much!
Prazul
Posts: 94
Joined: 05 Aug 2021, 15:55

Re: Send multiple keys when typing 1103 , 1105 and 4418

08 Aug 2021, 00:29

Prazul wrote:
07 Aug 2021, 05:25
boiler wrote:
07 Aug 2021, 04:54
Prazul wrote: Dear boiler, I'm sorry I stress you with that, but the code doesn't work.
Nothing happen after I type six digits follower by letter D not even after I press Enter.
Sorry, I didn’t correct it fully for D instead of T. But I started changing it to be d since that’s what you said last time. I will make it for either d or D, and I’ll just have it trigger a MsgBox for testing:

Code: Select all

:?B0C1:D::
	ClipSave := ClipboardAll
	Clipboard := ""
	Send, +^{Left}^c^{Right}
	Entry := Clipboard
	Clipboard := ClipSave
	if (Entry ~= "i)^\d{6,}D")
		gosub, MyRoutine
return

MyRoutine:
	MsgBox, Subroutine starts here
return
Unfortunately macro have some bugs. When I press "d" sometimes macro is executed sometimes not. I don't know why :think:
Prazul wrote: The code should start something with :

Code: Select all

:B0*:1103::
:B0*:1105::"
No, it shouldn’t start with something like that. How could it start with some numbers when the numbers are unknown? Getting it to work for an unknown set of 6 or more digits is very different than the previous code of a couple known digit sequences, so the code will look very different. Here is how this code works: When it gets triggered by typing d or D followed by a space or Enter, it then checks what precedes it, and if it is 6 or more numeric digits, it launches the subroutine. If you know a better way, please tell me. I’m ready to learn.
No no, you misunderstood me. I don't know better, the codes of Mikeys were just for example to better transmit the ideea so you better understand what I mean regarding reading the digits sents and how the macro should act after that. Will try your last input right now. Thanks.
Unfortunately macro have some bugs. When I press "d" sometimes macro is executed sometimes not. I don't know why :think:
Also I don't understand why it copy the six digits and d in clipboard and then paste. It interferate with my data saved in clipboard.
User avatar
boiler
Posts: 16768
Joined: 21 Dec 2014, 02:44

Re: Send multiple keys when typing 1103 , 1105 and 4418

08 Aug 2021, 04:46

Prazul wrote: Unfortunately macro have some bugs. When I press "d" sometimes macro is executed sometimes not. I don't know why :think:
I don’t know why either. Are you sure it’s not executing? You can put the line SoundBeep right after the first line to get an audible confirmation for test purposes.

Prazul wrote: Also I don't understand why it copy the six digits and d in clipboard and then paste.
It doesn’t paste, it just copies. That’s how it finds what characters the d follows to see if it is 6 or more numbers. If you know a better way, please tell me.

Prazul wrote: It interferate with my data saved in clipboard.
Have you seen that it interferes with the data saved in the clipboard, or are you just assuming it does? Because I put code in to save the previous contents of the clipboard and restore it after it copies the text into it and analyzes it.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], masheen, mikeyww and 145 guests