Typing twice for a different command

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
rubbioli
Posts: 36
Joined: 14 Sep 2019, 17:55

Typing twice for a different command

02 Sep 2022, 20:55

Hi!
I have the following hotkey for a specific program:

Code: Select all

appskey::
SetCapsLockState, Off
send ^+b
return

But i would like that when i press the "appkey" key fast twice it would open "notepad".
It´s possible?
Rohwedder
Posts: 7765
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Typing twice for a different command

03 Sep 2022, 02:19

Hallo,
try:

Code: Select all

appskey Up::SetTimer, Takey,% -10-400*(Takey:=!Takey)
Takey:
IF Takey
{
	SetCapsLockState, Off
	send ^+b
}
Else Run, Notepad.exe
Takey := False
Return
or fewer script lines:

Code: Select all

appskey Up::SetTimer, Takey,% -10-400*(Takey:=!Takey)
Takey:
IF Takey And !Takey := False {
	SetCapsLockState, Off
	send ^+b
} Else Run, Notepad.exe
Return
rubbioli
Posts: 36
Joined: 14 Sep 2019, 17:55

Re: Typing twice for a different command

03 Sep 2022, 15:40

Tks a lot my brother!
It Worked!
Have a noce day!!!
:clap:
rubbioli
Posts: 36
Joined: 14 Sep 2019, 17:55

Re: Typing twice for a different command

05 Sep 2022, 10:56

Hum...

unfortunately, this script conflicts with the command below, which was disabled after adopting your proposal:

Code: Select all

Loop
{ ;Format: ddMMyyyy
	Input, Key, L1 V
	IF Key is not Integer
		Date := Key := ""
	IF StrLen(Date .= Key) < 8
		Continue
	Try := (Year:=SubStr(Date,5)) (Month:=SubStr(Date,3,2)) SubStr(Date,1,2)
	Try -= A_Now, Days
	IF Try > ""
		SendInput, {BackSpace 6}/%Month%/%Year%
	Date := ""
}
return
[Mod edit: [code][/code] tags added.]


Is there any way for the two to work without conflicting with each other?
User avatar
boiler
Posts: 17374
Joined: 21 Dec 2014, 02:44

Re: Typing twice for a different command

05 Sep 2022, 12:35

Is it because you put the code you just showed below Rohwedder’s code? See Structure of a Script.
rubbioli
Posts: 36
Joined: 14 Sep 2019, 17:55

Re: Typing twice for a different command

05 Sep 2022, 13:21

Understand my friend: I don't understand much about AHK. I like it, I use it a lot, but I have limitations in its knowledge. I changed the order of the scripts, but the problem continued... one blocks the other.
User avatar
boiler
Posts: 17374
Joined: 21 Dec 2014, 02:44

Re: Typing twice for a different command

05 Sep 2022, 13:27

Understand that I’m just trying to help. Do you not want me to make suggestions? Isn’t that why you’re posting?

Please post your code as you’ve modified it for further feedback.
rubbioli
Posts: 36
Joined: 14 Sep 2019, 17:55

Re: Typing twice for a different command

05 Sep 2022, 14:29

boiler wrote:
05 Sep 2022, 13:27
Understand that I’m just trying to help. Do you not want me to make suggestions? Isn’t that why you’re posting?

Please post your code as you’ve modified it for further feedback.
Sorry, there was a misunderstanding. I really appreciate your suggestion, but I just wanted to say that it didn't work. Sorry if I sounded rude, but that was never my intention! :D ;) :dance:
User avatar
boiler
Posts: 17374
Joined: 21 Dec 2014, 02:44

Re: Typing twice for a different command

05 Sep 2022, 14:43

OK, so can you please post your code?
rubbioli
Posts: 36
Joined: 14 Sep 2019, 17:55

Re: Typing twice for a different command

06 Sep 2022, 08:25

Code: Select all

appskey Up::SetTimer, Takey,% -10-400*(Takey:=!Takey)
Takey:
IF Takey And !Takey := False {
	SetCapsLockState, Off
	send ^+b
} Else Run, Notepad.exe
Return
rubbioli
Posts: 36
Joined: 14 Sep 2019, 17:55

Re: Typing twice for a different command

06 Sep 2022, 08:27

Code: Select all

Loop
{ ;Format: ddMMyyyy
	Input, Key, L1 V
	IF Key is not Integer
		Date := Key := ""
	IF StrLen(Date .= Key) < 8
		Continue
	Try := (Year:=SubStr(Date,5)) (Month:=SubStr(Date,3,2)) SubStr(Date,1,2)
	Try -= A_Now, Days
	IF Try > ""
		SendInput, {BackSpace 6}/%Month%/%Year%
	Date := ""
}
return
[Mod edit: [code][/code] tags added.]
rubbioli
Posts: 36
Joined: 14 Sep 2019, 17:55

Re: Typing twice for a different command

06 Sep 2022, 08:27

These scripts are conflicting with each other. In fact, the script that puts dates automatically has no effect after the script that uses the appskey key.
User avatar
boiler
Posts: 17374
Joined: 21 Dec 2014, 02:44

Re: Typing twice for a different command

06 Sep 2022, 09:05

Don't show them separately. Show them exactly as how you have combined them into the same script that you say does not work. It's important to see how you have combined them.
rubbioli
Posts: 36
Joined: 14 Sep 2019, 17:55

Re: Typing twice for a different command

06 Sep 2022, 12:26

Hi, just um above the other, in the same txt file!
User avatar
boiler
Posts: 17374
Joined: 21 Dec 2014, 02:44

Re: Typing twice for a different command

06 Sep 2022, 16:43

You can't have the hotkey first. That was the point of the "Structure of a Script" link. You said you tried it the other way, but I can't see how this script alone would work:

Code: Select all

Loop
{ ;Format: ddMMyyyy
	Input, Key, L1 V
	IF Key is not Integer
		Date := Key := ""
	IF StrLen(Date .= Key) < 8
		Continue
	Try := (Year:=SubStr(Date,5)) (Month:=SubStr(Date,3,2)) SubStr(Date,1,2)
	Try -= A_Now, Days
	IF Try > ""
		SendInput, {BackSpace 6}/%Month%/%Year%
	Date := ""
}
return
...while this one would not:

Code: Select all

Loop
{ ;Format: ddMMyyyy
	Input, Key, L1 V
	IF Key is not Integer
		Date := Key := ""
	IF StrLen(Date .= Key) < 8
		Continue
	Try := (Year:=SubStr(Date,5)) (Month:=SubStr(Date,3,2)) SubStr(Date,1,2)
	Try -= A_Now, Days
	IF Try > ""
		SendInput, {BackSpace 6}/%Month%/%Year%
	Date := ""
}
return

appskey Up::SetTimer, Takey,% -10-400*(Takey:=!Takey)
Takey:
IF Takey And !Takey := False {
	SetCapsLockState, Off
	send ^+b
} Else Run, Notepad.exe
Return


...especially before you press a hotkey.
rubbioli
Posts: 36
Joined: 14 Sep 2019, 17:55

Re: Typing twice for a different command

08 Sep 2022, 18:05

This one above makes the date with "/". Like that: if I type 08092022 it shows 08/08/2022 (puts "/" inside automatically):
Loop
{ ;Format: ddMMyyyy
Input, Key, L1 V
IF Key is not Integer
Date := Key := ""
IF StrLen(Date .= Key) < 8
Continue
Try := (Year:=SubStr(Date,5)) (Month:=SubStr(Date,3,2)) SubStr(Date,1,2)
Try -= A_Now, Days
IF Try > ""
SendInput, {BackSpace 6}/%Month%/%Year%
Date := ""
}
return


And it stops working after I add this one suggested by "Rohwedder":


appskey Up::SetTimer, Takey,% -10-400*(Takey:=!Takey)
Takey:
IF Takey And !Takey := False {
SetCapsLockState, Off
send ^+b
} Else Run, Notepad.exe
Return

I´m not an expert, sorry!
User avatar
boiler
Posts: 17374
Joined: 21 Dec 2014, 02:44

Re: Typing twice for a different command

08 Sep 2022, 18:25

Last time I’m going to say this then I give up trying to help:
boiler wrote: Don't show them separately. Show them exactly as how you have combined them into the same script that you say does not work. It's important to see how you have combined them.
rubbioli
Posts: 36
Joined: 14 Sep 2019, 17:55

Re: Typing twice for a different command

08 Sep 2022, 19:44

boiler wrote:
08 Sep 2022, 18:25
Last time I’m going to say this then I give up trying to help:
boiler wrote: Don't show them separately. Show them exactly as how you have combined them into the same script that you say does not work. It's important to see how you have combined them.
Dear friend, I changed the order and it started working!

Code: Select all

Loop
{ ;Format: ddMMyyyy
	Input, Key, L1 V
	IF Key is not Integer
		Date := Key := ""
	IF StrLen(Date .= Key) < 8
		Continue
	Try := (Year:=SubStr(Date,5)) (Month:=SubStr(Date,3,2)) SubStr(Date,1,2)
	Try -= A_Now, Days
	IF Try > ""
		SendInput, {BackSpace 6}/%Month%/%Year%
	Date := ""
}
return

appskey Up::SetTimer, Takey,% -10-400*(Takey:=!Takey)
Takey:
IF Takey And !Takey := False {
SetCapsLockState, Off
send ^+b
} Else Run, Notepad.exe
Return
[Mod edit: [code][/code] tags added.]

I really appreciate you taking the time to help me. :P
Last edited by gregster on 08 Sep 2022, 21:38, edited 1 time in total.
Reason: Please use code tags instead of hard to read colors (at least in some forum themes). Thank you!

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot], blackbook7777, Google [Bot], MrDoge and 134 guests