AHK AutoTyper need Help Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
AHKBadAss

AHK AutoTyper need Help

08 Nov 2015, 15:55

Ok so basically im trying to create an autotyper, first It asks me how many messages I want to type (%Amount%)
Then it "Loops" %Amount% InputBoxes. This is where my Problem starts. I need 1 InputBox for each Message, but I need to access the Variable afterwards so I tried
InputBox, %Message%%i%, and from my logic I should be able to access it with %Message0% but it doesent seem to work at all (trying 1 message atm for testing reason thats why its %Message0%

Code: Select all

Amount := 0
i :=0
Message :=Message
InputBox, Amount, Message Amount, Input amount of Messages to type
 
g:
if(Amount>i){
InputBox, %Message%%i%, Message, Input text to Autotype
Amount--
i++
Goto, g
}
 
loop{
 
MsgBox, %Message0%
i--
 
if(i<0){
break
}
 
}
return
 
 
Can anyone help me fixing this
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: AHK AutoTyper need Help

08 Nov 2015, 16:18

Run this script, and see if that helps:

Code: Select all

InputBox, Msg_Count, Message Amount, Enter the number of messages

Loop, %Msg_Count%
    InputBox, Message%A_Index%, Message, Enter text for message #%A_Index%

Loop, %Msg_Count%
    MsgBox, % A_Index ": " Message%A_Index%
Hope that gets you started.
AHKBadAss

Re: AHK AutoTyper need Help

08 Nov 2015, 16:38

wolf_II wrote:Run this script, and see if that helps:

Code: Select all

InputBox, Msg_Count, Message Amount, Enter the number of messages

Loop, %Msg_Count%
    InputBox, Message%A_Index%, Message, Enter text for message #%A_Index%

Loop, %Msg_Count%
    MsgBox, % A_Index ": " Message%A_Index%
Hope that gets you started.

Just what I needed! Thanks man!
AHKBadAss

Re: AHK AutoTyper need Help  Topic is solved

08 Nov 2015, 17:23

I dont really understand the whole %A_index% thing eventho it works I'd like to know how, and is it possible to change a specific message for example I need 5 messages and want to change message 3
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: AHK AutoTyper need Help

08 Nov 2015, 18:24

Read Loop to find out about A_Index. It is a build-in index variable similar to the variable i in your script.
and is it possible to change a specific message for example I need 5 messages and want to change message 3
Yes, it is easy to do. Try for yourself first, and if you get stuck, post your script.
AHKBadAss

Re: AHK AutoTyper need Help

09 Nov 2015, 10:29

wolf_II wrote:Read Loop to find out about A_Index. It is a build-in index variable similar to the variable i in your script.
and is it possible to change a specific message for example I need 5 messages and want to change message 3
Yes, it is easy to do. Try for yourself first, and if you get stuck, post your script.

Allright, I tried really hard after I came back from school today.

This is what I tried.. (and other things... but this looks the most realistic)

Code: Select all

InputBox, Edit_Msg, Edit Message, Enter the number of the Message to edit.
Loop, %A_Index%{
MsgBox,%A_Index% %Edit_Msg%
if(%A_Index%==%Edit_Msg%){
    InputBox, Message%A_Index%, Message, Enter text for message #%A_Index%
}
}
Full Code:

Code: Select all

MsgBox, 

(
Welcome to my Autotyper
^ means CTRL (Control)

Commands:
^r: Reload
^p: Pause/Play
^s: Display Messages/Edit
Escape: Exit

The Messages will be repeated until you Pause or Exit.
Think of how many different Messages you want to type (for the next Step)
)

InputBox, Msg_Count, Message Amount, Enter the number of messages
InputBox, Delay_Count, Delay Amount, Enter the number of Delay in seconds, normally 5

Loop, %Msg_Count%{
    InputBox, Message%A_Index%, Message, Enter text for message #%A_Index%
}
 WinWait, RuneLoader v2`,19 - dustyhands, 
IfWinNotActive, RuneLoader v2`,19 - dustyhands, , WinActivate, RuneLoader v2`,19 - dustyhands, 
WinWaitActive, RuneLoader v2`,19 - dustyhands, 

d:
While(true){
Loop, %Msg_Count%{
Send, % Message%A_Index% 
Send, {ENTER}
Sleep, Delay_Count*1000
}
}


f:
MsgBox, 

(
MsgBox, Hit Control+R to enter completly new Messages
Will now show the current Messages!
)
Loop, %Msg_Count%{
    MsgBox, % A_Index ": " Message%A_Index%
}
InputBox, Edit_Msg, Edit Message, Enter the number of the Message to edit.
Loop, %A_Index%{
MsgBox,%A_Index% %Edit_Msg%
if(%A_Index%==%Edit_Msg%){
    InputBox, Message%A_Index%, Message, Enter text for message #%A_Index%
}
}
return



^r::Reload
^p::Pause
^s::Goto, f
Escape::ExitApp
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: AHK AutoTyper need Help

09 Nov 2015, 10:56

try with

Code: Select all

if (A_Index = Edit_Msg){
better yet:

Code: Select all

InputBox, Edit_Msg, Edit Message, Enter the number of the Message to edit.
InputBox, Message%Edit_Msg%, Message, Enter text for message #%Edit_Msg%
AHKBadAss

Re: AHK AutoTyper need Help

09 Nov 2015, 11:01

wolf_II wrote:try with

Code: Select all

if (A_Index = Edit_Msg){
better yet:

Code: Select all

InputBox, Edit_Msg, Edit Message, Enter the number of the Message to edit.
InputBox, Message%Edit_Msg%, Message, Enter text for message #%Edit_Msg%

Haha, stupid me. I had something like
InputBox, Message%Edit_Msg%, Message, Enter text for message #%Edit_Msg%
but I didnt got it right.
Anyways is there any way to display all the Messages I typed in a Window while the script is running? I heard of GUI but I never looked into it
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: AHK AutoTyper need Help

09 Nov 2015, 11:34

AHKBadAss wrote:Anyways is there any way to display all the Messages I typed in a Window while the script is running? I heard of GUI but I never looked into it
Do you want to keep track of what the script is doing? Or do you want to keep track of what a user is typing, while your script is active?
AHKBadAss

Re: AHK AutoTyper need Help

10 Nov 2015, 08:24

wolf_II wrote:
AHKBadAss wrote:Anyways is there any way to display all the Messages I typed in a Window while the script is running? I heard of GUI but I never looked into it
Do you want to keep track of what the script is doing? Or do you want to keep track of what a user is typing, while your script is active?

I want to see the Messages I typed in (What the Script is doing kind of)
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: AHK AutoTyper need Help

10 Nov 2015, 08:55

Using your full code from above, you could use a text file in A_ScriptDir and write to it with something like:

Code: Select all

d:
While(true){
Loop, %Msg_Count%{
Send, % Message%A_Index% 
Send, {ENTER}
FileAppend, % Message%A_Index% "`n", %A_ScriptDir%\message_log.txt ; <<< added
Sleep, Delay_Count*1000
}
}
I have not checked your full code, I am just demonstrating the approach you could take.
AHKBadAss

Re: AHK AutoTyper need Help

10 Nov 2015, 10:21

wolf_II wrote:Using your full code from above, you could use a text file in A_ScriptDir and write to it with something like:

Code: Select all

d:
While(true){
Loop, %Msg_Count%{
Send, % Message%A_Index% 
Send, {ENTER}
FileAppend, % Message%A_Index% "`n", %A_ScriptDir%\message_log.txt ; <<< added
Sleep, Delay_Count*1000
}
}
I have not checked your full code, I am just demonstrating the approach you could take.

Thats decent, but I ment something like a little Window displaying me what Messages are currently saved to type:

Imganie this is a Window... maybe looking like a MsbBox or whatever
Message 1: This
Meesage 2: That
Message 3: Bla
Next Message #2

Thats what Im trying to get
User avatar
MasterFocus
Posts: 146
Joined: 01 Oct 2013, 09:47
GitHub: MasterFocus
Location: Rio de Janeiro - RJ - Brasil
Contact:

Re: AHK AutoTyper need Help

10 Nov 2015, 10:31

Untested:

Code: Select all

InputBox, var_Amount, Message Amount, Enter the number of messages
Loop, %var_Amount%
{
    InputBox, array_Msg%A_Index%, Message #%A_Index%, Ok, tell me the message number %A_Index%.
    var_Text .= "`n" array_Msg%A_Index%
}
MsgBox, All set! Press OK to see them.
MsgBox, % SubStr(var_Text,2)
InputBox: http://autohotkey.com/docs/commands/InputBox.htm
Loop and A_Index: http://autohotkey.com/docs/commands/Loop.htm
Pseudo-arrays: http://www.autohotkey.com/docs/misc/Arrays.htm#pseudo
SubStr(): http://autohotkey.com/docs/Functions.htm#SubStr
Assign/Concatenation: search for ".=" here => http://autohotkey.com/docs/Variables.htm

Gui (used in wolf_II's anwser below): http://autohotkey.com/docs/commands/Gui.htm
Antonio França - git.io | github.com | ahk4.net | sites.google.com
Member of the AHK community since 08/Apr/2009. Moderator since mid-2012.
Need help? Please post on the forum before sending me a PM.
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: AHK AutoTyper need Help

10 Nov 2015, 10:40

Ohh, sorry. Is this what you are looking for?

Code: Select all

InputBox, Msg_Count, Message Amount, Enter the number of messages

Loop, %Msg_Count%
    InputBox, Message%A_Index%, Message, Enter text for message #%A_Index%

Loop, % Msg_Count {
    Gui, Add, Text, xm, Message #%A_Index%
    Gui, Add, Edit, x+m w200, % Message%A_Index%
}
Gui, Show,, Autotyper
Return
AHKBadAss

Re: AHK AutoTyper need Help

10 Nov 2015, 15:24

wolf_II wrote:Ohh, sorry. Is this what you are looking for?

Code: Select all

InputBox, Msg_Count, Message Amount, Enter the number of messages

Loop, %Msg_Count%
    InputBox, Message%A_Index%, Message, Enter text for message #%A_Index%

Loop, % Msg_Count {
    Gui, Add, Text, xm, Message #%A_Index%
    Gui, Add, Edit, x+m w200, % Message%A_Index%
}
Gui, Show,, Autotyper
Return
Thanks guys, now I got this one, and it works ;)

Code: Select all

MsgBox, 

(
Welcome to my Autotyper
^ means CTRL (Control)

Commands:
^s: Edit Messages
^r: Reload
^p: Pause/Play
Escape: Exit

The Messages will be repeated until you Pause or Exit.
Think of how many different Messages you want to type (for the next Step)
)

InputBox, Msg_Count, Message Amount, Enter the number of messages
InputBox, Delay_Count, Delay Amount, Enter the number of Delay in seconds, normally 5

Loop, %Msg_Count%{
    InputBox, Message%A_Index%, Message, Enter text for message #%A_Index%
}

Loop, % Msg_Count {
    Gui, Add, Text, xm, Message #%A_Index%
    Gui, Add, Edit, x+m w200, % Message%A_Index%
}
    Gui, Add, Text, xm, Press Control+S to edit Messages.
Gui, Show,, Autotyper

MsgBox, Press OK to start Typing (Cant Edit from GUI)

d:
While(true){
Loop, %Msg_Count%{
Send, % Message%A_Index% 
Send, {ENTER}
FileAppend, % Message%A_Index% "`n", %A_ScriptDir%\message_log.txt ; <<< added
Sleep, Delay_Count*1000
}
}


f:
InputBox, Edit_Msg, Edit Message, Enter the number of the Message to edit.
InputBox, Message%Edit_Msg%, Message, Enter text for message #%Edit_Msg%
Gui Destroy
Loop, % Msg_Count {
    Gui, Add, Text, xm, Message #%A_Index%
    Gui, Add, Edit, x+m w200, % Message%A_Index%
}
    Gui, Add, Text, xm, Press Control+S to edit Messages.
Gui, Show,, Autotyper
MsgBox, Press OK to start Typing again!

return

^r::Reload
^p::Pause
^s::Goto, f
Escape::ExitApp
Maybe possible to Add/Remove+Update GUI, I managed to Edit and change GUI but not sure how to Remove or Add
Remove should Remove any of X Messages example I have 4 Messages and I want to delete Message 2, after the deletion I have 3 Messages left, Message 3 becomes Message 2 and Message 4 becomes Message 3.
Adding should just add a Message at the End of the Row

I know its probably possible, but I dont know how :P
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: AHK AutoTyper need Help

10 Nov 2015, 15:32

I think we have reached the point, where you should step back from inputboxes and messageboxes.
Try this demo, but it won't handle Remove yet:

Code: Select all

Msg_Count := 1 ; initial

Show_Gui:
    Loop % Msg_Count {
        Gui, Add, Text, xm, Message #%A_Index%
        Gui, Add, Edit, x+m w200 vText%A_Index%, % Text%A_Index%
    }
    Gui, Add, Button,, More
    Gui, Show,, Autotyper
Return

GuiClose:
    Gui, Cancel
Return

ButtonMore:
    Gui, Submit
    Gui, Destroy
    Msg_Count += 1
    Gosub, Show_Gui
Return
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: AHK AutoTyper need Help

10 Nov 2015, 16:39

With "Delete" buttons:

Code: Select all

#SingleInstance, Force
Msg_Count := 1 ; initial

Show_Gui:
    Loop % Msg_Count {
        Gui, Add, Text, xm, Message #%A_Index%
        Gui, Add, Edit, x+m w200 vText%A_Index%, % Text%A_Index%
        Gui, Add, Button, x+m gDelete, Delete #%A_Index%
    }
    Gui, Add, Button, xm, More
    Gui, Show,, Autotyper
Return

GuiClose:
    Gui, Cancel
Return

ButtonMore:
    Gui, Submit
    Gui, Destroy
    Msg_Count += 1
    Gosub, Show_Gui
Return

Delete:
    Delete_me := SubStr(A_GuiControl, 9) ; index to delete
    Gui, Submit
    Gui, Destroy
    Msg_Count -= 1

    ; move the messages up
    Loop, % Msg_Count {
        Next_Index := A_Index + 1
        If (A_Index >= Delete_me)
            Text%A_Index% := Text%Next_Index%
    }
    Text%Next_Index% := "" ; delete last entry

    Gosub, Show_Gui
Return
AHKBadAss

Re: AHK AutoTyper need Help

11 Nov 2015, 09:24

wolf_II wrote:With "Delete" buttons:

Code: Select all

#SingleInstance, Force
Msg_Count := 1 ; initial

Show_Gui:
    Loop % Msg_Count {
        Gui, Add, Text, xm, Message #%A_Index%
        Gui, Add, Edit, x+m w200 vText%A_Index%, % Text%A_Index%
        Gui, Add, Button, x+m gDelete, Delete #%A_Index%
    }
    Gui, Add, Button, xm, More
    Gui, Show,, Autotyper
Return

GuiClose:
    Gui, Cancel
Return

ButtonMore:
    Gui, Submit
    Gui, Destroy
    Msg_Count += 1
    Gosub, Show_Gui
Return

Delete:
    Delete_me := SubStr(A_GuiControl, 9) ; index to delete
    Gui, Submit
    Gui, Destroy
    Msg_Count -= 1

    ; move the messages up
    Loop, % Msg_Count {
        Next_Index := A_Index + 1
        If (A_Index >= Delete_me)
            Text%A_Index% := Text%Next_Index%
    }
    Text%Next_Index% := "" ; delete last entry

    Gosub, Show_Gui
Return
Wow man! Thats so sick! I never thought GUI would be that Cool. I defenetly will look into that later...
AMAZING :dance:

Return to “Ask For Help”

Who is online

Users browsing this forum: Chunjee, Google [Bot], malcev and 41 guests