Need help with scripting.

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
AnonimoDrago
Posts: 2
Joined: 08 Jun 2017, 21:23

Need help with scripting.

13 Jun 2017, 17:10

So, I found a script that works as a .ahk file. It's supposed to play the piano when you press F4, here's my question: Can someone please help me script two things:
1.Stop button, there is a play button..No stop button.
2.A line of code that allows the program to play anything in [ ] for example: It'd play the following buttons on its own a b d w e then [ab], I want the program to press [ab] together then continue to play the other notes on their own. TL;DR Press anything in [ ] together.

Code: Select all

Gui, Add, Text,, ------------------------------------------Key Delay------------------------------------------
Gui, Add, Edit, w300 vKeyDelay, 100
Gui, Add, Text,, ----------------------------------------Piano Music-----------------------------------------
Gui, Add, Edit, R10 w300 vPianoMusic
Gui, Add, Text,, -------------------------------F5 To Play Piano Music-------------------------------
Gui, Add, Text,, ----------------------------Made by Rasv on V3rmillion----------------------------
Gui, Show
F4::
!F4::
Gui, Submit, Nohide
SetKeyDelay, %KeyDelay%
PianoMusic := StrReplace(PianoMusic, "`n")  ; Remove linefeeds
PianoMusic := StrReplace(PianoMusic, "`r")  ; Remove carriage returns
PianoMusic := StrReplace(PianoMusic, "/")   ; Remove Ingame Chat
Send, %PianoMusic%
return
GuiClose:
ExitApp
Thanks
User avatar
Cuadrix
Posts: 236
Joined: 07 May 2017, 08:26

Re: Need help with scripting.

13 Jun 2017, 22:54

Wrong section.
User avatar
DyaTactic
Posts: 221
Joined: 04 Apr 2017, 05:52

Re: Need help with scripting.

14 Jun 2017, 04:28

The code to press a and b together is

Code: Select all

Send, {a Down}{b Down}	; Not sure how SetKeyDelay handles this. It is necessary to set it to 0 before this command.
; Make sure there is a delay.
Send, {a Up}{b Up}		; Release a and b.
The challange here is converting your code ([ab]) to my code above.

Hope this helps.
krypteddna

Re: Need help with scripting.

28 Aug 2017, 02:38

DyaTactic wrote:The code to press a and b together is

Code: Select all

Send, {a Down}{b Down}	; Not sure how SetKeyDelay handles this. It is necessary to set it to 0 before this command.
; Make sure there is a delay.
Send, {a Up}{b Up}		; Release a and b.
The challange here is converting your code ([ab]) to my code above.

Hope this helps.
Well I wanted it to press ANYTHING inside the "[ ]". E.G: [1IuyIa] I want the program to press 1IuyIa all at the same time.
AnonimoDrago
Posts: 2
Joined: 08 Jun 2017, 21:23

Re: Need help with scripting.

28 Aug 2017, 02:41

Code: Select all

Gui, Add, Text,, ------------------------------------------Key Delay------------------------------------------
Gui, Add, Edit, w300 vKeyDelay, 100
Gui, Add, Text,, ----------------------------------------Piano Music-----------------------------------------
Gui, Add, Edit, R10 w300 vPianoMusic
Gui, Add, Text,, -------------------------------F4 To Play Piano Music-------------------------------
Gui, Add, Text,, ----------------------------Made by KryptedDNA----------------------------
Gui, Show
F4::
!F4::
Gui, Submit, Nohide
PianoMusic := RegExReplace(PianoMusic, "`n|`r|/") ; Remove Stuff
X := 1
while (X:=RegExMatch(PianoMusic, "U)(\[.*]|.)",Keys, X))
{	
	X+=StrLen(Keys)
	Keys := Trim(Keys, "[]")
	SendInput % Keys
	Sleep, %KeyDelay%
}
return

GuiClose:
	ExitApp
[Mod edit: Added [code][/code] tags.]
User avatar
DyaTactic
Posts: 221
Joined: 04 Apr 2017, 05:52

Re: Need help with scripting.

28 Aug 2017, 03:20

I haven't worked with RegEx functions yet. Is this the script how it should be or do you need help with it?

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 308 guests