I need some help. I am a newbie in VBS and I want to write a bot for a video game I play to type stuff.
set sellAllTyping = wscript.CreateObject(\"WScript.Shell\
I don't know which looping keyword you used. Use any of the below keyword after
if x=vbOK then "Exit For/Exit Do/Exit Function" might help you
Unfortuately, msgbox freeze the execution.
In others words, you cannot loop between the moment the message apear and the moment you click on Ok or Cancel.
The only way to achieve this is to make a HTA file like this:
<SCRIPT LANGUAGE="VBScript" src="test.vbs"> </SCRIPT>
<input type='button' value='Start' onclick='startLoop()'>
<input type='button' value='Stop' onclick='stopLoop()'>
then, on the linked vbs file (for this example, it's test.vbs), you must write something like this:
set sellAllTyping = CreateObject("Wscript.shell")
loopState = true
sub startLoop()
do while loopState = true
msgbox "yeah"
loop
end sub
sub stopLoop()
loopState = false
end sub
The only problem now is that the app is freezing because of the loop (if I replace msgbox with sendkeys) or is always hide behind the msgbox.
this code work well (with a sleep function):
set sellAllTyping = CreateObject("Wscript.shell")
loopState = true
sub startLoop()
do while loopState = true
msgbox "yeah"
sleep(2)
loop
end sub
sub stopLoop()
loopState = false
end sub
Sub sleep (Timesec)
sellAllTyping.Run "Timeout /T " & Timesec & " /nobreak" ,0 ,true
End Sub
Make sure you name the hta file "something.hta" and NOT "something.html"