Reputation: 7875
Is it possible to create a vbs script that call itself when a certain pc action is activated,lets say opening up a browser?A replica would be someone opens up a browser,then the vbs listens to this activity and runs itself or calls another vbs script?
Upvotes: 0
Views: 710
Reputation: 387
You may want to give System Scheduler a try.
http://www.splinterware.com/products/wincron.htm
Upvotes: 0
Reputation: 58
Jimmy, if you want the code to be executed when a browser window is opened, consider this code :
Set obj0 = createobject("wscript.shell")
Dim Count
Count = 0
Do while count = 0
If obj0.appactivate("browserwindowtitle") then
-------do something----
----
----
Count = 1
Else
Wscript.sleep(10000)
Count = 0
End if
Loop
Set obj0 = nothing
The above code will check if the window having the title "browserwindowtitle" is open or not. If it is open, it will execute the desired action. If the window is not open, script will wait for 10 seconds and try again.
After writing the script go to control panel-> scheduled tasks and add the script as scheduled on startup. When you do this, the script will start executing when your PC turns on and will keep on checking if the browser window is open or not.
There will be easier ways to do this, others might be able to help.
Upvotes: 1