Script inside script 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

Script inside script

24 Oct 2021, 03:44

Hi,
I have the following codes

Code: Select all

`:: ; the script no.1
Send P0
return


:B0*:P0714:: ; the script no.2
SendInput {Tab 2}
Return
When I press "`" it send P0 . Now I am programming to send 2x Tab when P0714 is detected.
The second script It work ok if I manually type P0714 , but if I execute the script no.1 then manually type 714, the script no.2 doesnt execute.
I'm wondering why because "P0" are already sent through the script no.1 :think:
Thanks for help
Rohwedder
Posts: 7645
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Script inside script

24 Oct 2021, 03:51

Hallo,
try:

Code: Select all

`:: ; the script no.1
SendLevel 1
Send P0
return


:?B0*:P0714:: ; the script no.2
SendInput {Tab 2}
Return
Prazul
Posts: 94
Joined: 05 Aug 2021, 15:55

Re: Script inside script

24 Oct 2021, 03:56

Rohwedder wrote:
24 Oct 2021, 03:51
Hallo,
try:

Code: Select all

`:: ; the script no.1
SendLevel 1
Send P0
return


:?B0*:P0714:: ; the script no.2
SendInput {Tab 2}
Return
Hi. Thanks but it doesnt work.
When I execute first script it send "P0" . Then when I manually press "714" nothing happen.
Rohwedder
Posts: 7645
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Script inside script

24 Oct 2021, 04:03

Here it works. Do you have the question mark in the 2nd script?
On my keyboard, Grave Accent is dead key.
https://en.wikipedia.org/wiki/Dead_key
Therefore I replaced `:: with q::
Last edited by Rohwedder on 24 Oct 2021, 04:14, edited 1 time in total.
Prazul
Posts: 94
Joined: 05 Aug 2021, 15:55

Re: Script inside script

24 Oct 2021, 04:13

Rohwedder wrote:
24 Oct 2021, 04:03
Here it works. Do you have the question mark in the 2nd script?
Yes.

Is simple as that : I press key "`" (without quotes) then it send "P0" (without quotes).
Then I press keys "714" (without quotes) and nothing happen.

If I press keys "P0714" (without quotes) , that is, the entire sequence, then it work.

But I need to send script no.1 first then followed by pressed keys "714" (without quotes) and after pressing 714 it should send 2x Tab

I only mannualy press "714" (without quotes) because "P0" (whithout quotes) is already sent with script no.1. And after manually send "714" then script no.2 should execute, respectively sending 2x Tab
Rohwedder
Posts: 7645
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Script inside script

24 Oct 2021, 04:23

Here it works as desired (with q::). No matter if in a single script or in two, no matter which one was started first.
Prazul
Posts: 94
Joined: 05 Aug 2021, 15:55

Re: Script inside script

24 Oct 2021, 04:31

Rohwedder wrote:
24 Oct 2021, 04:23
Here it works as desired (with q::). No matter if in a single script or in two, no matter which one was started first.
Nope.

I tried in a simple Notepad. It doesnt work at all.
:?
Prazul
Posts: 94
Joined: 05 Aug 2021, 15:55

Re: Script inside script

24 Oct 2021, 04:33

Rohwedder wrote:
24 Oct 2021, 04:03
Here it works. Do you have the question mark in the 2nd script?
On my keyboard, Grave Accent is dead key.
https://en.wikipedia.org/wiki/Dead_key
Therefore I replaced `:: with q::
replaced with Q also and issue persist :think:
Prazul
Posts: 94
Joined: 05 Aug 2021, 15:55

Re: Script inside script

04 Nov 2021, 05:54

Anybody can help ?
RussF
Posts: 1268
Joined: 05 Aug 2021, 06:36

Re: Script inside script

04 Nov 2021, 06:20

I can confirm that @Rohwedder's script works as intended in Notepad and in Chrome, however, when triggered within VS Code, only a single tab was sent (or captured by VS Code). Interesting behavior.

Russ
Prazul
Posts: 94
Joined: 05 Aug 2021, 15:55

Re: Script inside script

04 Nov 2021, 06:50

RussF wrote:
04 Nov 2021, 06:20
I can confirm that @Rohwedder's script works as intended in Notepad and in Chrome, however, when triggered within VS Code, only a single tab was sent (or captured by VS Code). Interesting behavior.

Russ
I think nobody understand the ideea.

So, it is already wrote "P0"because I first run Script no.1
After typing "714" it should check if "P0" exist ahead. If so, then proceed with sending 2x tab.
RussF
Posts: 1268
Joined: 05 Aug 2021, 06:36

Re: Script inside script

04 Nov 2021, 06:58

Why do you think that? The concept is simple. Using @rohwedder's script within Notepad, first type ` and the characters "P0" appear. Then immediately type 714 and the script sends two x Tab. As I said, it works properly in Notepad. It only sends one Tab if I trigger the script within VS Code. That's the only part I don't understand. If that's not what you want, then you didn't explain it well enough.

Russ
Prazul
Posts: 94
Joined: 05 Aug 2021, 15:55

Re: Script inside script

04 Nov 2021, 07:13

RussF wrote:
04 Nov 2021, 06:58
Why do you think that? The concept is simple. Using @rohwedder's script within Notepad, first type ` and the characters "P0" appear. Then immediately type 714 and the script sends two x Tab. As I said, it works properly in Notepad. It only sends one Tab if I trigger the script within VS Code. That's the only part I don't understand. If that's not what you want, then you didn't explain it well enough.

Russ
Very strange. Here doesnt work at all the way you describe despite I runed it as admin
RussF
Posts: 1268
Joined: 05 Aug 2021, 06:36

Re: Script inside script

04 Nov 2021, 07:34

So, I just figured out why it didn't work properly in VS Code. The script WAS actually sending two Tabs, but because I had the actual script open in another tab, VS Code was picking up the "P0714" in it and triggering the autocomplete and the "first" Tab sent was being absorbed by that. It was happening so fast though, I didn't see it actually happening. Once I closed the tab with the script's source code in it so that there was no instance of the text "P0714", then it worked as expected.

Do you have any other scripts running that might conflict with this one?

Russ
Prazul
Posts: 94
Joined: 05 Aug 2021, 15:55

Re: Script inside script

04 Nov 2021, 09:09

RussF wrote:
04 Nov 2021, 07:34


Do you have any other scripts running that might conflict with this one?

Russ
N ope. I havent
RussF
Posts: 1268
Joined: 05 Aug 2021, 06:36

Re: Script inside script

04 Nov 2021, 09:30

Ok, did you copy and paste @Rohwedder's script into a separate file and test it all by itself, or did you manually type it in (possible typo) or have you inserted it in another script? Try copy/pasting it and test it completely by itself within Notepad.

Russ
Prazul
Posts: 94
Joined: 05 Aug 2021, 15:55

Re: Script inside script

04 Nov 2021, 09:45

RussF wrote:
04 Nov 2021, 09:30
Ok, did you copy and paste @Rohwedder's script into a separate file and test it all by itself, or did you manually type it in (possible typo) or have you inserted it in another script? Try copy/pasting it and test it completely by itself within Notepad.

Russ
Created a fresh autohotkey file and Copy/pasted the code of Rohwedder, saved, run and tested in notepad. It send P0 with script no1 and then when I type from numpad 714 it doesnt proceed with script no2, I mean it doesnt send 2x tabs

When I type P0714 manually, then it send 2xtabs. But P0 will be sent with script no1, and what it remain to be sent is only 714 and after manually typing on numpad that, it doesnt send 2x tab.

So, pressing "`" (without quotes) will send P0. Then I type on numpad "714" (without quotes) and it doesnt send 2x tab. I need to
send 2x tab after "714" BUT taking in consideration entire sequence , I mean P0714

So the second script work ok, it send 2x tabs once is detect P0714

But i want send P0 using another script, script no.1. So instead typing manually P0, I use script no.1 . The remaining sequence , 714, will be typed manually.
After 714 is typed, then autohotkey should send 2x tab.
RussF
Posts: 1268
Joined: 05 Aug 2021, 06:36

Re: Script inside script

04 Nov 2021, 12:06

@Prazul, I'm not sure where to go now. This is now beyond my VERY limited expertise. The script works perfectly for me as you defined it. Tested it in Notepad, Word, Chrome and VS Code. It works the same whether I user the numeric keypad or the upper row of numbers. When I type `714, the output is "P0714{Tab}{Tab}"

I tested using ahk version 1.1.33.09 Unicode on 32 bit Windows 10 Pro.

I must now defer to some other ahk gurus on this forum - so sorry.

Russ
Prazul
Posts: 94
Joined: 05 Aug 2021, 15:55

Re: Script inside script

05 Nov 2021, 06:37

RussF wrote:
04 Nov 2021, 12:06
@Prazul, I'm not sure where to go now. This is now beyond my VERY limited expertise. The script works perfectly for me as you defined it. Tested it in Notepad, Word, Chrome and VS Code. It works the same whether I user the numeric keypad or the upper row of numbers. When I type `714, the output is "P0714{Tab}{Tab}"

I tested using ahk version 1.1.33.09 Unicode on 32 bit Windows 10 Pro.

I must now defer to some other ahk gurus on this forum - so sorry.

Russ
I'm using windows 7. It doesnt work :oops: Thank you anyway for your help.
Prazul
Posts: 94
Joined: 05 Aug 2021, 15:55

Re: Script inside script

05 Nov 2021, 13:01

RussF wrote:
04 Nov 2021, 12:06
@Prazul, I'm not sure where to go now. This is now beyond my VERY limited expertise. The script works perfectly for me as you defined it. Tested it in Notepad, Word, Chrome and VS Code. It works the same whether I user the numeric keypad or the upper row of numbers. When I type `714, the output is "P0714{Tab}{Tab}"

I tested using ahk version 1.1.33.09 Unicode on 32 bit Windows 10 Pro.

I must now defer to some other ahk gurus on this forum - so sorry.

Russ
@RussF Please past the entire code here as is working for you. Thanks

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: ArkuS, Chunjee, WAZAAAAA and 389 guests