Hello there guys, I am making a guide for starcraft 2 players, and it will require me to use a timmer...
This is how I need it:
1) Activate timer by pressing SHIFT + P (This is how I am using my hotkey if it matters (LINK HERE)
2)Timer started at ZERO, now it will go for ever until user wants to stop it.
3)After 30 seconds the timer is on, I want to execute this:
axWindowsMediaPlayer1.currentPlaylist = axWindowsMediaPlayer1.mediaCollection.getByName("mediafile");
axWindowsMediaPlayer1.URL = "zerg1.mp3";
axWindowsMediaPlayer1.Ctlcontrols.play();
4)After 68 seconds, I want to execute this:
axWindowsMediaPlayer1.currentPlaylist = axWindowsMediaPlayer1.mediaCollection.getByName("mediafile");
axWindowsMediaPlayer1.URL = "zerg2.mp3";
axWindowsMediaPlayer1.Ctlcontrols.play();
and so on, ... untill the player deactivates the timer,...
How can I acomplish this ?
I was gonna make a LARGE mp3 file, for each strategy method, but then my program will be 600 MB...
I wish to create tiny mp3 files (spoken instructions) so that each time the timmer hits my desired seconds, it will execute that tiny mp3 file through media player..
Media player is already on my program (using WMPLib;), it works and all ...
I just need the timer to start from Zero each time the person uses the global hotkey (which I believe my hotkey is fully working already)
Thanks guys !!!
Loading
thiago costaPosted Dec 1, 2011, 9:16 PM
When I get stuck on a problem, you always help me :D ..
But I don't stop trying after I ask :D I am persistent !!! Now I have a new problem (small) but I will make a new thread... Thanks so much Sam !!!
Sam HobbsPosted Nov 30, 2011, 10:10 PM
thiago costaPosted Nov 30, 2011, 8:32 PM
SOLVED...
I had to do TT1.Enabled = false; BEFORE what ever was going to happen (zerg.mp3) not after... 100% solved !!!! :D
thiago costaPosted Nov 30, 2011, 8:08 PM
Thanks Sam for looking for a resolution for me... I struggled and I was able to make it work !!!!
This is how the current setting works !!!
1)IF Radio Box is checked,
2)Shift + P = Turn timer (in this case TT1, and TT1(2 timers(I made 18))) but only using 2 times just to test...
3)Timer 1 (TT1) will play zerg1.mp3 after 5 seconds, then disable itself,t
Timer 2, which started together with timer one, will play zerg2.mp3 when it hits 15 seconds, then turn it self off...
:D DONE !!!!! Now I can finish the rest easy, ...
So when the players are playing starcraft 2, which is a VERY timming intense game for pro gamers, it will speak what the player should do next at the right time !!!
The noobies will become pro's much faster now :D
once again, Thanks sam.
The code below works 90 % :D
I just need a way to stop timmers now, like tt1, tt2, etc.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Diagnostics;
using WMPLib;
using System.Threading;
using System.Timers;
using System.Net;
using System.IO;
namespace Starcraft_2_Builder
{
public partial class Form1 : Form
{
private static System.Timers.Timer TT1;
private static System.Timers.Timer TT2;
private static System.Timers.Timer TT3;
private static System.Timers.Timer TT4;
private static System.Timers.Timer TT5;
private static System.Timers.Timer TT6;
private static System.Timers.Timer TT7;
private static System.Timers.Timer TT8;
private static System.Timers.Timer TT9;
private static System.Timers.Timer TT10;
private static System.Timers.Timer TT11;
private static System.Timers.Timer TT12;
private static System.Timers.Timer TT13;
private static System.Timers.Timer TT14;
private static System.Timers.Timer TT15;
private static System.Timers.Timer TT16;
private static System.Timers.Timer TT17;
private static System.Timers.Timer TT18;
[DllImport("user32.dll")]
public static extern bool RegisterHotKey(IntPtr hWnd, int id, int fsModifiers, int vlc);
[DllImport("user32.dll")]
public static extern bool UnregisterHotKey(IntPtr hWnd, int id);
public Form1()
{
InitializeComponent();
// Alt = 1, Ctrl = 2, Shift = 4, Win = 8
Form1.RegisterHotKey(this.Handle, this.GetType().GetHashCode(), 4, (int) 'P');
// Form1.UnregisterHotKey(this.Handle, this.GetType().GetHashCode());
//zvp timmers
TT1 = new System.Timers.Timer(10000);
TT1.Elapsed += new ElapsedEventHandler(_event1);
TT1.Interval = 999900;
TT1.Enabled = false;
TT2 = new System.Timers.Timer(10000);
TT2.Elapsed += new ElapsedEventHandler(_event2);
TT2.Interval = 999900;
TT2.Enabled = false;
TT3 = new System.Timers.Timer(10000);
TT3.Elapsed += new ElapsedEventHandler(_event3);
TT3.Interval = 999900;
TT3.Enabled = false;
TT4 = new System.Timers.Timer(10000);
TT4.Elapsed += new ElapsedEventHandler(_event4);
TT4.Interval = 999900;
TT4.Enabled = false;
TT5 = new System.Timers.Timer(10000);
TT5.Elapsed += new ElapsedEventHandler(_event5);
TT5.Interval = 999900;
TT5.Enabled = false;
TT6 = new System.Timers.Timer(10000);
TT6.Elapsed += new ElapsedEventHandler(_event6);
TT6.Interval = 999900;
TT6.Enabled = false;
//zvz timmers
TT7 = new System.Timers.Timer(10000);
TT7.Elapsed += new ElapsedEventHandler(_event7);
TT7.Interval = 999900;
TT7.Enabled = false;
TT8 = new System.Timers.Timer(10000);
TT8.Elapsed += new ElapsedEventHandler(_event8);
TT8.Interval = 999900;
TT8.Enabled = false;
TT9 = new System.Timers.Timer(10000);
TT9.Elapsed += new ElapsedEventHandler(_event9);
TT9.Interval = 999900;
TT9.Enabled = false;
TT10 = new System.Timers.Timer(10000);
TT10.Elapsed += new ElapsedEventHandler(_event10);
TT10.Interval = 999900;
TT10.Enabled = false;
TT11 = new System.Timers.Timer(10000);
TT11.Elapsed += new ElapsedEventHandler(_event11);
TT11.Interval = 999900;
TT11.Enabled = false;
TT12 = new System.Timers.Timer(10000);
TT12.Elapsed += new ElapsedEventHandler(_event12);
TT12.Interval = 999900;
TT12.Enabled = false;
//zvt timmers
TT13 = new System.Timers.Timer(10000);
TT13.Elapsed += new ElapsedEventHandler(_event13);
TT13.Interval = 999900;
TT13.Enabled = false;
TT14 = new System.Timers.Timer(10000);
TT14.Elapsed += new ElapsedEventHandler(_event14);
TT14.Interval = 999900;
TT14.Enabled = false;
TT15 = new System.Timers.Timer(10000);
TT15.Elapsed += new ElapsedEventHandler(_event15);
TT15.Interval = 999900;
TT15.Enabled = false;
TT16 = new System.Timers.Timer(10000);
TT16.Elapsed += new ElapsedEventHandler(_event16);
TT16.Interval = 999900;
TT16.Enabled = false;
TT17 = new System.Timers.Timer(10000);
TT17.Elapsed += new ElapsedEventHandler(_event17);
TT17.Interval = 999900;
TT17.Enabled = false;
TT18 = new System.Timers.Timer(10000);
TT18.Elapsed += new ElapsedEventHandler(_event18);
TT18.Interval = 999900;
TT18.Enabled = false;
}
public int intv;
protected override void WndProc(ref Message m)
{
if (m.Msg == 0x0312)
quadaxial();
//this.Activate();
base.WndProc(ref m);
}
private void _event1(object source, ElapsedEventArgs e)
{
//axWindowsMediaPlayer1.currentPlaylist = axWindowsMediaPlayer1.mediaCollection.getByName("mediafile");
//axWindowsMediaPlayer1.URL = "zerg1.mp3";
//axWindowsMediaPlayer1.Ctlcontrols.play();
MessageBox.Show("5 secs");
TT1.Enabled = false;
}
private void _event2(object source, ElapsedEventArgs e)
{
// axWindowsMediaPlayer1.currentPlaylist = axWindowsMediaPlayer1.mediaCollection.getByName("mediafile");
//axWindowsMediaPlayer1.URL = "zerg2.mp3";
//axWindowsMediaPlayer1.Ctlcontrols.play();
MessageBox.Show("15 secs");
TT2.Enabled = false;
}
private void _event3(object source, ElapsedEventArgs e)
{
}
private void _event4(object source, ElapsedEventArgs e)
{
}
private void _event5(object source, ElapsedEventArgs e)
{
}
private void _event6(object source, ElapsedEventArgs e)
{
}
private void _event7(object source, ElapsedEventArgs e)
{
}
private void _event8(object source, ElapsedEventArgs e)
{
}
private void _event9(object source, ElapsedEventArgs e)
{
}
private void _event10(object source, ElapsedEventArgs e)
{
}
private void _event11(object source, ElapsedEventArgs e)
{
}
private void _event12(object source, ElapsedEventArgs e)
{
}
private void _event13(object source, ElapsedEventArgs e)
{
}
private void _event14(object source, ElapsedEventArgs e)
{
}
private void _event15(object source, ElapsedEventArgs e)
{
}
private void _event16(object source, ElapsedEventArgs e)
{
}
private void _event17(object source, ElapsedEventArgs e)
{
}
private void _event18(object source, ElapsedEventArgs e)
{
}
private void quadaxial()
{
if (RB_zvt1.Checked)
{
zerg1();
}
if (RB_zvt2.Checked)
{
zerg2();
}
if (RB_zvt3.Checked)
{
zerg3();
}
}
private void zerg1()
{
TT1.Interval = 5000;
TT1.Enabled = true;
TT2.Interval = 15000;
TT2.Enabled = true;
}
private void zerg2()
{
}
private void zerg3()
{
}
private void BTN_save_Click(object sender, EventArgs e)
{
Application.Restart();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void Form1_Load_1(object sender, EventArgs e)
{
}
}
}
thiago costaPosted Nov 30, 2011, 5:59 PM
Sorry for the poor explanation... This is an example,
30 seconds, zerg1.mp3,
68 seconds, zerg2.mp3
128 seconds, zerg3.mp3,
158 seconds, zerg4.mp4
Done,
The timmer started at 0 seconds, and ended at 158 seconds, so 158 seconds total.
I will have radio buttons, for different timmings,
I have acomplished something, Let me upload the current program, it might help you understand.
Thanks so much sam.
The zip file, has the source code, and also the compiled file in the bin directory,
Thanks again Sam.
Sam HobbsPosted Nov 30, 2011, 12:13 PM
A lot depends on what the times are and whether they change. For example you say 30 seconds then 68 seconds. If those numbers are always the same then that will be easier than if they change. It also depends on whether the action to perform is always the same in the sense of the program used and the only difference is the data that is used each time. So will you always play a mp3 file each time that an event occurs but just a different mp3 file?
The amount of time between events vary; for example, first the amount of time is 30 seconds, then the next one is 38 seconds after that. So perhaps you can have a table such as:
30 zerg1.mp3
38 zerg2.mp3
Then each time an event occurs, you should cancel the timer then set a new interval for the next event and start the timer for the new event.