Hello all,
I am very new to Visual Basic, and programming in general. So in advance I apologize. After reading up on Visual Basic via my Library and some tutorials and creating a patchwork script (Non Visual Studio .exe). Refresh.vb I have a script that works great. Below is my v1 script, my inquiry is that I need the placement to do ether of the following 1. automatically go to background, 2. go to bottom right hand corner of the screen. The reasoning is that I need the popup to stay alive to let the users know that it is running, also for the sake of automation it needs to not be in the center of the screen in front of the window it targets.
My hopes for my version 2 is what is shown below. I want to remove the sleep function and just adjust the number of seconds the popup stays up. Then auto minimize or move the pop up placement so that it does not stay in the middle of the "NCD" window.
If there is any way you can help, this would be much appreciated. I am a big believer that instead of asking how to do something, I should first read up on it, investigate and try to solve it my self. Through a few days of text books and google / bing searches and looking through MSDN I am stumped I am now asking for help.
I do also want to state that I have created exactly what I need via visual studio, but IT will not approve a .exe application for production, this is why it needs to be a ".vb" file. For giggles here is the program I created in visual studio.
-Austregisel-
I am very new to Visual Basic, and programming in general. So in advance I apologize. After reading up on Visual Basic via my Library and some tutorials and creating a patchwork script (Non Visual Studio .exe). Refresh.vb I have a script that works great. Below is my v1 script, my inquiry is that I need the placement to do ether of the following 1. automatically go to background, 2. go to bottom right hand corner of the screen. The reasoning is that I need the popup to stay alive to let the users know that it is running, also for the sake of automation it needs to not be in the center of the screen in front of the window it targets.
Code:
Version 1
~~~~~~~~~~~~~~~~~~~Begin Code~~~~~~~~~~~~~~~~~~~
Do
Set objShell = WScript.CreateObject("WScript.Shell" )
' Set the focus to the browser named "NCD"
objShell.AppActivate "NCD"
' Send the F5 key for a refresh
objShell.SendKeys "{F5}"
' Pop utility - Stop Script option, currently set to stay up 1 second
iRetVal = objShell.Popup("Stop refreshing script?", 1, "", 4)
If (iRetVal = 6) Then
Exit Do
End If
' Wait for 10 Minutes
' Wscript.Sleep 600000
Loop
~~~~~~~~~~~~~~~~~~~End Code~~~~~~~~~~~~~~~~~~~
My hopes for my version 2 is what is shown below. I want to remove the sleep function and just adjust the number of seconds the popup stays up. Then auto minimize or move the pop up placement so that it does not stay in the middle of the "NCD" window.
Code:
~~~~~~~~~~~~~~~~~~~Begin Code~~~~~~~~~~~~~~~~~~~
'////\\\\\Perhaps do a pre configuration script for all popup placement mode "This confuses me"////\\\\
Do
Set objShell = WScript.CreateObject("WScript.Shell" )
' Set the focus to the browser named "NCD"
objShell.AppActivate "NCD"
' Send the F5 key for a refresh
objShell.SendKeys "{F5}"
'////\\\\\ Perhaps set the placement in here, a way by pixels?////\\\\
' Pop utility - Stop Script option, currently set to stay up 1 second
iRetVal = objShell.Popup("Stop refreshing script?", 1, "", 4)
If (iRetVal = 6) Then
Exit Do
End If
Loop
~~~~~~~~~~~~~~~~~~~End Code~~~~~~~~~~~~~~~~~~~
I do also want to state that I have created exactly what I need via visual studio, but IT will not approve a .exe application for production, this is why it needs to be a ".vb" file. For giggles here is the program I created in visual studio.
Code:
~~~~~~~~~~~~~~~~~~~Begin Code~~~~~~~~~~~~~~~~~~~
Public Class Form1
Private cancelFlag As Boolean = False
Dim objShell As Object
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.Visible = True
Dim x As Integer
Dim y As Integer
x = Screen.PrimaryScreen.WorkingArea.Width
y = Screen.PrimaryScreen.WorkingArea.Height - Me.Height
Do Until x = Screen.PrimaryScreen.WorkingArea.Width - Me.Width
x = x - 1
Me.Location = New Point(x, y)
Loop
End Sub
Private Sub Stroodle_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Stroodle.Click
Stroodle.Enabled = False
Stroodle.Visible = False
OhSnapple.Enabled = True
OhSnapple.Visible = True
objShell = CreateObject("WScript.Shell")
' Set the focus to the browser named "Cox Media - Web Scheduler - CT"
objShell.AppActivate("NCD")
BackgroundWorker1.RunWorkerAsync()
End Sub
Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
Application.DoEvents()
Do Until cancelFlag = True
' Set the focus to the browser named "Cox Media - Web Scheduler - CT"
objShell.AppActivate("NCD")
'Send the F5 key for a refresh
objShell.SendKeys("{F5}")
' Wait for 10 Minutes
System.Threading.Thread.Sleep(600000)
Loop
End Sub
Private Sub OhSnapple_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OhSnapple.Click
cancelFlag = False
Me.Close()
End Sub
End Class
~~~~~~~~~~~~~~~~~~~End Code~~~~~~~~~~~~~~~~~~~
-Austregisel-