1.

Solve : Batch keypress help?

Answer»

Ok so i have a program that closes every 30 minutes and i wanted it to loop so it goes infinity. first my thought camed to that i could make it loop every 30 min but then i remembered that i have to set it up after every startup so now i wonder if any of u experienced bat coders could make me a bat code or say the commands to make it happen

this is the order

Start (program)
Press TAB
Press TAB
Press TAB
Press TAB
Press TAB
Press TAB
Press TAB
Press Enter
Wait a minute for next action
Press TAB
Press TAB
Press Enter
Wait a minute(for next action
Press TAB
Press TAB
Press TAB
Press TAB
Press TAB
Press TAB
Press TAB
Press TAB
Press TAB
Press TAB
Press TAB
Press TAB
Press TAB
Press TAB
Press Enter
And a timer at the end on 31 minutes and then start this bat up again

Please i would love an answer would really mean alot  This would be a lot more easily done in a VBScript. I'm currently getting my feet wet with VB, so I do not know all of the nuances about the CODING, but as a ROUGH go at it, try:

Code: [Select]Set WshShell = WScript.CreateObject("WScript.Shell")
Do
WshShell.Run "Program", 1
WshShell.Sleep 60

WshShell.SendKeys "{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{ENTER}"
WshShell.Sleep 1000

WshShell.SendKeys "{TAB}{TAB}{ENTER}"
WshShell.Sleep 1000

WshShell.SendKeys "{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{ENTER}"
WshShell.Sleep 1860000
Loop

This script will loop indefinetely, so if you are needing it to stop at any point, you are going to have to kill the process manually or look into coding some exit do conditions. Also, the sleep numbers are in milliseconds, so if you need to make the sleep times between sending the keys longer, you just need to increase that number.wont work ?= :S
 is coming up wich in english means

Script .... u know that urself

Row 3
Characters 16
Error : statement expected
code : 800A0400
Source: Compile error in Microsoft VBscript

Code screen: Quote from: Raven19528 on November 03, 2011, 11:24:11 AM

This would be a lot more easily done in a VBScript. I'm currently getting my feet wet with VB, so I do not know all of the nuances about the coding, but as a rough go at it, try:

Code: [Select]Set WshShell = WScript.CreateObject("WScript.Shell")
Do
WshShell.Run "Program", 1
WshShell.Sleep 60

WshShell.SendKeys "{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{ENTER}"
WshShell.Sleep 1000

WshShell.SendKeys "{TAB}{TAB}{ENTER}"
WshShell.Sleep 1000

WshShell.SendKeys "{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{ENTER}"
WshShell.Sleep 1860000
Loop

This script will loop indefinetely, so if you are needing it to stop at any point, you are going to have to kill the process manually or look into coding some exit do conditions. Also, the sleep numbers are in milliseconds, so if you need to make the sleep times between sending the keys longer, you just need to increase that number.
Quote from: sobbo90 on November 03, 2011, 01:36:50 PM
wont work ?= :S
 is coming up wich in english means

Script .... u know that urself

Row 3
Characters 16
Error : statement expected
code : 800A0400
Source: Compile error in Microsoft VBscript

Code screen:

any help please :S
You need quotation marks and a file extension, I think.
Like:
Code: [Select]WshShell.Run "C:\blah\blah\blah\blah.exe", 1Syntax error, line 3 of the script. Ah I see Cheezey beat me to it. The shell object expects a string. Strings have quotes. If the program you want to run is not on the PATH then you need the full path, filename and extension.

Quote from: Cheezey on November 03, 2011, 02:00:31 PM
You need quotation marks and a file extension, I think.
Like:
Code: [Select]WshShell.Run "C:\blah\blah\blah\blah.exe", 1
Ok fixed that and now i did put it in the same directory did fix quotes and get full location but it says it cant find the file
This is error picture :

Uploaded with ImageShack.us
The Fel:(Error) means that it cannot find the file
This is the code

Code: [Select]Set WshShell = WScript.CreateObject("WScript.Shell")
Do
WshShell.Run "C:\Users\Linus\Desktop\wowrob\WowRobot Evolution", 1
WshShell.Sleep 60

WshShell.SendKeys "{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{ENTER}"
WshShell.Sleep 1000

WshShell.SendKeys "{TAB}{TAB}{ENTER}"
WshShell.Sleep 1000

WshShell.SendKeys "{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{ENTER}"
WshShell.Sleep 1860000
LoopIs WowRobot Evolution a program file?
Quote from: Salmon Trout on November 03, 2011, 02:04:16 PM
Syntax error, line 3 of the script. Ah I see Cheezey beat me to it. The shell object expects a string. Strings have quotes. If the program you want to run is not on the PATH then you need the full path, filename and extension.

OKEY tried to fix this but now i get error where it says that it cant find it even thoe i did put the script in same directory and did full path length this is code

Code: [Select]Set WshShell = WScript.CreateObject("WScript.Shell")
Do
WshShell.Run "C:\Users\Linus\Desktop\wowrob\WowRobot Evolution", 1
WshShell.Sleep 60

WshShell.SendKeys "{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{ENTER}"
WshShell.Sleep 1000

WshShell.SendKeys "{TAB}{TAB}{ENTER}"
WshShell.Sleep 1000

WshShell.SendKeys "{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{ENTER}"
WshShell.Sleep 1860000
Loop 



Uploaded with ImageShack.us At the "Fel" (ErroR) it says cannot find the file. Quote from: Salmon Trout on November 03, 2011, 02:26:33 PM
Is WowRobot Evolution a program file?
Quote from: Salmon Trout on November 03, 2011, 02:26:33 PM
Is WowRobot Evolution a program file?
Filetype is Program.exetestet to add .exe on the end of the file path. no success Quote from: Salmon Trout on November 03, 2011, 02:29:42 PM


Okey i changed some directory names and file names etc...
 
do u see anything in this script that should't work?

Code: [Select]Set WshShell = WScript.CreateObject("WScript.Shell")
Do
WshShell.Run "C:\Users\Linus\Desktop\wowrob\hejsan\Enkel.exe", 1
WshShell.Sleep 60

WshShell.SendKeys "{TAB}{ENTER}"
WshShell.Sleep 1000

WshShell.SendKeys "{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{ENTER}"
WshShell.Sleep 1000

WshShell.SendKeys "{TAB}{TAB}{ENTER}"
WshShell.Sleep 1000

WshShell.SendKeys "{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{ENTER}"
WshShell.Sleep 1860000
Loopdoes this file and path exist exactly as SHOWN?

"C:\Users\Linus\Desktop\wowrob\hejsan\Enkel.exe"

Don't PM for special help.

You should wait for Raven to answer, it's his script.

Shouldn't it be Wscript.sleep?

Quote from: Salmon Trout on November 03, 2011, 02:55:21 PM
does this file and path exist exactly as shown?

"C:\Users\Linus\Desktop\wowrob\hejsan\Enkel.exe"

Don't PM for special help.

You should wait for Raven to answer, it's his script.

Shouldn't it be Wscript.sleep?

Thanks now its no error and yes it did i dont know if i did get dot or something in it cause now it launches and same with sleep command. i only have one problem left after i started the program i need it to get "TARGETED" as the window that i am on so that the tab and enter have any effect cause now it only starts and then it presses tab and enter in the same folder as the script

Yeah sorry for that wont do that again


Discussion

No Comment Found