How would I make the 1_MS button change the number after the Sleep, command in Spam_C?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
PARATR00PER
Posts: 8
Joined: 20 Aug 2017, 11:41

How would I make the 1_MS button change the number after the Sleep, command in Spam_C?

20 Aug 2017, 12:48

Gui, Add, Button, x15 y15 w175 h45 gSpam_C, Spam C

Gui, Add, Button, x195 y15 w45 h45 g1_MS, 1 MS

Gui, Show, w255 h75
return

Spam_C:
WinActivate ######
While 1=1
Loop
{
sleep,1
SendInput c
}
return


1_MS:

return
Last edited by PARATR00PER on 22 Aug 2017, 03:51, edited 6 times in total.
SirRFI
Posts: 404
Joined: 25 Nov 2015, 16:52

Re: I want to make the 1_MS button change the "Sleep,[CHANGED NUMBER]" in the Spam_C button but I don't know how.

20 Aug 2017, 17:34

Put the code in

Code: Select all

[/c] tag, remove irrelevant parts of code and put some comment so we know where you want the asked thing to be.

As far I understand your question, [docs]Random[/docs] and forced expression [docs]Sleep[/docs] ([c]Sleep % expression or variable[/c]) should do the trick, unless You want specific numbers in order, then use [docs]Loop[/docs] or [docs]For[/docs] and [docs]Array[/docs].
Use

Code: Select all

[/c] forum tag to share your code.
Click on [b]✔[/b] ([b][i]Accept this answer[/i][/b]) on top-right part of the post if it has answered your question / solved your problem.
SirRFI
Posts: 404
Joined: 25 Nov 2015, 16:52

Re: How would I make the 1_MS button change the number after the Sleep, command in Spam_C?

21 Aug 2017, 18:12

That's better, but I meant to put [code=autohotkey] on the beginning of code, and [/code] at the end, like following:

Code: Select all

Gui, Add, Button, x15 y15 w175 h45 gSpam_C, Spam C

Gui, Add, Button, x195 y15 w45 h45 g1_MS, 1 MS

Gui, Show, w255 h75
return

Spam_C:
WinActivate ######
While 1=1
Loop
{
sleep,1
SendInput c
}
return

1_MS:
;--------------------------------------------------------------------------------------- What do I put here? ------------------------------------------------------------
return
Putting that aside, I think I misunderstood your question first time, unless You edited it. Still not certain what You meant exactly, so please elaborate if necessary.

To my current understanding, You want to change text on second button from "1 MS" to "2 MS", then to "3 MS" and so on - everytime the loop goes. If that's correct, try following:

Code: Select all

Counter := 1

Gui, Add, Button, x15 y15 w175 h45 gSpam_C, Spam C
Gui, Add, Button, x195 y15 w45 h45 vGUI_Counter, % Counter " MS"	;gLabel not needed if the label has no code
Gui, Show, w255 h75
Return

Spam_C:
WinActivate ######
While ()
{
	Loop
	{
		Sleep 1
		Counter++
		GuiControl,, GUI_Counter, Counter 
		SendInput c
	}
}
Return
If You want the Sleep to be equal to Counter variable - change the Sleep line onto Sleep % Counter.
Use

Code: Select all

[/c] forum tag to share your code.
Click on [b]✔[/b] ([b][i]Accept this answer[/i][/b]) on top-right part of the post if it has answered your question / solved your problem.
PARATR00PER
Posts: 8
Joined: 20 Aug 2017, 11:41

Re: How would I make the 1_MS button change the number after the Sleep, command in Spam_C?

22 Aug 2017, 03:43

Sorry for describing this so terribly, I am trying to make the 1_MS button change the value after the "sleep," command to 1 (I plan on another button beneath 1_MS called 10_MS doing the same but changing the value to 10. I think I'm still explaining this badly so here is an example: https://gyazo.com/653d82afbaad342392dbda077d85c610
SirRFI
Posts: 404
Joined: 25 Nov 2015, 16:52

Re: How would I make the 1_MS button change the number after the Sleep, command in Spam_C?

22 Aug 2017, 06:23

I changed your code a bit, and I think following is what You wanted to achieve:

Code: Select all

SendMode Input	; Makes all Send to become SendInput



Gui, Add, Button, X10 Y10 W100 H30 gToggle_SpamC, Spam C
Gui, Add, DropDownList, X+5 YP+0 W50 vTimer_SpamC Choose1, 100|500|1000|3000	; Instead of making many buttons - just pick one from list
Gui, Show
Return



Toggle_SpamC:
Toggle_SpamC := !Toggle_SpamC	; Negates itself, creating a simple ON/OFF switch used next line
SetTimer, Loop_SpamC, % Toggle_SpamC ? "0" : "OFF"	; Turns on or off the loop below, which also allows to run multiple loops simultaneously
Return

Loop_SpamC:
;WinActivate
GuiControlGet, Timer_SpamC	; Gets current value from DropDownList
Sleep % Timer_SpamC	; Sleeps equal to the time for DropDownList (in MS)
;Send {c}
ToolTip, c	; for testing purpose
Return
Use

Code: Select all

[/c] forum tag to share your code.
Click on [b]✔[/b] ([b][i]Accept this answer[/i][/b]) on top-right part of the post if it has answered your question / solved your problem.
PARATR00PER
Posts: 8
Joined: 20 Aug 2017, 11:41

Re: How would I make the 1_MS button change the number after the Sleep, command in Spam_C?

22 Aug 2017, 09:57

Thank you so much! Is there any way I can have the Toggle button and another DropDownList with C|V|B|N|R?

Gui, Font, cWhite s16, Gentium Basic
Gui, Add, Button, x15 y15 w90 h29 ga, Toggle
Gui, Font, cWhite s12, Gentium Basic
Gui, Add, DropDownList, x103 y16 w90 va, 1|10|20|25|50|75|100|125|150|175|200
Gui, Add, DropDownList, x192 y16 w90 vb, C|V|B|N|R|
Gui, +AlwaysOnTop
Gui, Color, White
Gui, Show, w297 h58
Return

b:
return

a:
return

GuiClose:
ExitApp
return
Last edited by PARATR00PER on 23 Aug 2017, 02:44, edited 2 times in total.
SirRFI
Posts: 404
Joined: 25 Nov 2015, 16:52

Re: How would I make the 1_MS button change the number after the Sleep, command in Spam_C?

22 Aug 2017, 12:45

You can copy-paste all related lines and just change the label names from something SpamC to anything else, like SpamB.
Use

Code: Select all

[/c] forum tag to share your code.
Click on [b]✔[/b] ([b][i]Accept this answer[/i][/b]) on top-right part of the post if it has answered your question / solved your problem.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: scriptor2016 and 153 guests