我最近接触过vb.net脚本,我在确定如何完成任务时遇到了一些麻烦。我应该创建一个程序来自动化最终用户进程,但现在它只适用于一个特定的id(因为我已经硬编码了一个值来使脚本运行)。我编写了使用StreamReader循环遍历所有可能的条目的脚本,但是我无法弄清楚如何将该结果放入变量中,因此程序将自动读取所选的id并继续执行这些步骤,然后循环,直到通过StreamReader识别出的所有id都已被处理。如果以前曾经问过我,我很抱歉,我对这个术语不是很熟悉。
Private Sub Form1_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
Application.DoEvents()
End
End Sub
Private Sub Form1_FormLoad(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
uxNote.Text = "Starting"
Me.Update()
RunApp()
Me.Close()
End Sub
Sub RunApp()
Dim b As New BostonWorkStation
Dim myHandle As Long
b.Shell_("C:\Software\Application.exe")
b.Activate("AppCaption", True)
b.Connect("AppCaption", enumStreamType1.stWindows)
uxNote.Text = myHandle.ToString
Me.Update()
b.Wait(2)
b.Pause("@378,423")
b.Tab_("user")
b.Enter("password")
b.Wait(2)
b.Shell_("C:\Software\Application2.exe")
b.Activate("App2Caption", True)
b.Wait(4)
b.Connect("App2Caption", enumStreamType1.stWindows)
uxNote.Text = myHandle.ToString
Me.Update()
b.Wait(4)
b.Smart.Create("App2Caption@726,1088", -1024, -633, 0)
b.Smart.Click(False, False)
b.Wait(3)
b.Activate("Patient Lookup", True)
b.Connect("Patient Lookup", enumStreamType1.stWindows)
uxNote.Text = myHandle.ToString
Me.Update()
b.Wait(1)
b.Pause("@104,423")
ProcessPatients(b)
b.Enter("10001") 'hardcoded id this is where I would like a variable to pull in the value
b.Wait(2)
'some more code steps here specific to what should be done once patient id has been selected
End Sub
Sub ProcessPatients(ByVal w As BostonWorkStation)
Dim record() As String
Dim sr As New StreamReader("my path for csv or txt file")
Do While sr.Peek > -1
record = sr.ReadLine.Split(CChar("|"))
Loop
sr.Close()
End Sub
答案 0 :(得分:0)
我想它看起来像这样:
timeLeftUntilSpawn = Time.time - startTime;
System.Random secondsBetweenSpawn = new System.Random ();
float num2 = secondsBetweenSpawn.Next (1, 10); // random number between 1 and 10 'seconds'
if (timeLeftUntilSpawn >= num2) {
startTime = Time.time;
timeLeftUntilSpawn = 0;
Debug.Log ("Spawn one here");
System.Random rnd = new System.Random (); // from here is deciding on the position of the spawn after one has been spawned
int num = rnd.Next (0, 10); //random number between 0 and 10
if (num < 5) {
switchSpawning = false;
Debug.Log ("False");
transform.position = spawnPosition;
} else if (num > 5) {
switchSpawning = true;
Debug.Log ("True");
transform.position = spawnPosition2;
}
}