PDA

View Full Version : Question concerning variable input (W2K)



mikhaelmas
02-03-2004, 08:24 AM
Please forgive my ignorance, but I'm new to scripting and this is my first script. I have an application called radmin.exe that I'm trying to automate somewhat. When launched it starts up a remote administration application that I use to connect sites remotely via ip. This same application supports cmd line.

Typing the following string at a cmd promt launches the app, in this case connects to site 1234BO, and locolor and updates are just switches for preferences:

C:\>radmin.exe /connect:1234BO /locolor /updates:10

The next thing that happens is your prompted to enter a password. So this where my vbscript came in to play.

set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "radmin.exe /connect:1234BO /locolor /updates:10"
WScript.Sleep 2500
WshShell.SendKeys "password"
WshShell.SendKeys "{ENTER}"

Now the above script works. When I dbl-clk it from my desktop it launches my app with my preferences, pauses for the password pop-up, then sends the keys "password" and "ENTER", and I'm connected to my site.

That's all fine and dandy except for the fact that I've got over a 1000 sites. So how do I make the "1234" portion of the script a variable based on user input?

I created a little gui in VB 6.0 (something else I have no experience with). It's basically a little window with an input box large enough to hold 4 characters. It also has two radio buttons. The input box is what I wanted to be my variable. The radio buttons are labled "View Only" and "File Transfer" which are two more switches that determine the type of view you have when you connect to the site.

So I'm lost now. How do I make that portion of my script "XXXX"BO variable? That is the x's are equal to whatever someone puts in the input box and I still need the "BO" tagged on to the end.

How do I make it so that if "View Only" is ticked it adds the switch /noinput ?

How do I make it so that if "File Transfer" is ticked it adds the switch /file ?

If anyone wants to see the radmin program itself it can be found at the following url - http://www.famatech.com/

Thanks in advance,

Michael

unknown634
02-03-2004, 09:04 AM
OK, from what I gathered, this should help. I also see you're using VB6, which helps also.
Sorry for the lack of tabs, but this should do it.

Try this code:
<font color=red>
Option Explicit
'''''Mode Num Vars''''''''
Dim ModeNum as Integer
Const Locked=1
Const Trans=2
'''''''''''''''''''''''''''''''''''''''''''
Const Path=&lt;path to radmin.exe&gt;\radmin.exe 'Set this equal to wherever you have radmin stored, leaving the \radmin.exe at the end.

''''''''''''''Set read only mode'''''''''''''''
Sub &lt;Read-only radiobutton&gt;_Click
ModeNum=Locked

End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''
'''''''''''''''Set Transfer Mode''''''''''''''''
Sub &lt;Transfer radiobutton&gt;_Click
ModeNum=Trans

End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''
'''''''''''''''''Main Processing'''''''''''''''''''
Sub &lt;button name&gt;_Click()
Dim SiteNum.
Const CmdPart = " /connect:" & SiteNum & "BO /locolor /updates:10"
SiteNum= &lt;textbox name&gt; 'Get the site number

If ModeNum = 1 Then
Shell Path & CmdPart & "/noinput" 'Run read only command

ElseIf ModeNum = 2 Then 'In reality, you *could* just type else and be done with this line.

Shell Path & CmdPart & "/file" 'Run transfer command

End If

End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''
</font color=red>

That's all the code the form should need. Open up the code window, kill everything in it for the form and copy/paste all the red into it.

Let me know if you need anymore help/images/forums/icons/smile.gif
-Unknown

-----------------
C:\
C:\DOS
C:\DOS\RUN
RUN\DOS\RUN

mikhaelmas
02-03-2004, 09:38 AM
First thanks soooooo much for your help.

Ok I opened up my project in VB and made sure there was no code for Form1 and pasted in yours and edited the following line:

Const Path=C:\Program Files\Radmin\radmin.exe 'Set this equal to wherever you have radmin stored, leaving the \radmin.exe at the end.

I must be typing it in wrong though cause if I click on the PLAY button at that point it stops at the first \ in my path and gives a "Compile error: Expected: line number or label or statement or end of statement."

Something else I noticed was when I go back to View Object mode and click on my first radio button I noticed that it's actually calling it an OptionButton. I have two with just a text label next to each, one reads "File Transfer" the other "View Only". I want neither ticked by default.

Now on the OptionButton's properties is there any field that I need to modify to match your code so that your code can find the right option button?

It also seems to be missing the option that waits for the password pop-up and automatically sends the password I define along with the enter key.

Thanks again,

Michael

<P ID="edit"><FONT class="small">Edited by mikhaelmas on 02/03/04 10:03.</FONT></P>

unknown634
02-03-2004, 11:35 AM
Yeah, I did miss a few things.

The Const for the exe path should be in quotes

To make all option buttons unpicked by default, add a Form_Load procedure:
Also, you can name your options buttons whatever you like, just replace &lt;readonly radiobutton&gt; with your Read only option button and &lt;transfer radiobutton&gt; with the name of the File Transfer button.

<font color=red>
Sub Form_Load()
&lt;readonly radiobutton&gt;.Value=False
&lt;transfer radiobutton&gt;.Value=False

End Sub
</font color=red>

I completely overlooked the waiting on the password, sorry about that.
You need a TIMER object to do that (since I've never gotten Wscript.Sleep to work for me anyway)

I'll repaste the Command button too, as that's relevant.
<font color=red>
Sub &lt;button name&gt;_Click()
Dim SiteNum.
Const CmdPart = " /connect:" & SiteNum & "BO /locolor /updates:10"
SiteNum= &lt;textbox name&gt; 'Get the site number

If ModeNum = 1 Then
Shell Path & CmdPart & "/noinput", vbNormalFocus 'Run read only command
&lt;timername&gt;.Interval=2500 'This number is in MILLIseconds and has to be set as such, so it's actually 2.5 seconds wait time.

ElseIf ModeNum = 2 Then 'In reality, you *could* just type else and be done with this line.

Shell Path & CmdPart & "/file", vbNormalFocus 'Run transfer command at normal focus, so the sendkeys works
&lt;timername&gt;.Interval=2500

End If

End Sub

Sub &lt;timername&gt;_Timer() 'This will execute after 2500ms (2.5 sec) have elapsed from setting the above interval

Dim WScript
Set WScript=CreateObject("Wscript.Shell")
WScript.SendKeys "&lt;your pass here&gt;"
&lt;timername&gt;.Interval=0 'Stops this from running itself again

End Sub
</font color=red>

That should do it. Let me know if you need anything else.
-Unknown

-----------------
C:\
C:\DOS
C:\DOS\RUN
RUN\DOS\RUN

mikhaelmas
02-03-2004, 01:06 PM
I'm not combining the two scripts correctly can you show me from top to bottom how the script should read? Then I promise to leave you alone for today :)

unknown634
02-03-2004, 02:18 PM
It's no problem really....
<font color=red>
Option Explicit
'''''Mode Num Vars''''''''
Dim ModeNum as Integer
Const Locked=1
Const Trans=2
'''''''''''''''''''''''''''''''''''''''''''
Const Path=&lt;path to radmin.exe&gt;\radmin.exe 'Set this equal to wherever you have radmin stored, leaving the \radmin.exe at the end.

''''''''''''''Set read only mode'''''''''''''''
Sub &lt;Read-only radiobutton&gt;_Click
ModeNum=Locked

End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''
'''''''''''''''Set Transfer Mode''''''''''''''''
Sub &lt;Transfer radiobutton&gt;_Click
ModeNum=Trans

End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''
'''''''''''''''''Main Processing'''''''''''''''''''
Sub &lt;button name&gt;_Click()
Dim SiteNum.
Const CmdPart = " /connect:" & SiteNum & "BO /locolor /updates:10"
SiteNum= &lt;textbox name&gt; 'Get the site number

If ModeNum = 1 Then
Shell Path & CmdPart & "/noinput", vbNormalFocus 'Run read only command
&lt;timername&gt;.Interval=2500 'This number is in MILLIseconds and has to be set as such, so it's actually 2.5 seconds wait time.

ElseIf ModeNum = 2 Then 'In reality, you *could* just type else and be done with this line.

Shell Path & CmdPart & "/file", vbNormalFocus 'Run transfer command at normal focus, so the sendkeys works
&lt;timername&gt;.Interval=2500

End If

End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''
''''''''''''''''''Timer Function'''''''''''''''''''''
Sub &lt;timername&gt;_Timer() 'This will execute after 2500ms (2.5 sec) have elapsed from setting the above interval

Dim WScript
Set WScript=CreateObject("Wscript.Shell")
WScript.SendKeys "&lt;your pass here&gt;"
&lt;timername&gt;.Interval=0 'Stops this from running itself again

End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''
</font color=red>

That should do it. Kill the code in the form, copy/paste this in, change the necessary stuff and it should work. I copy/pasted my codes from both posts so that should do it.

Let me know if you need anything else,
-Unknown

-----------------
C:\
C:\DOS
C:\DOS\RUN
RUN\DOS\RUN

mikhaelmas
02-04-2004, 05:54 AM
Thanks again...I think I've got it all right now. Would you mind reviewing my entries? Also I'm unsure what button name your looking for on the first line of code under "Main Processing". If your talking about what triggers the rest of the code, like an "Ok" button I don't have one. Can we make it so that after they type in the site number the trigger is the "Enter" key?

Why is the first instance of ModeNum=Locked but the next is =Trans? Sorry if that's a dumb question but I am learning alot by what you've shown me. If I'm interpreting that portion of the code correctly one of those option buttons is going to be ticked by default. My guess is the one that has ModeNum=Locked. Well I don't want either ticked by default. The way radmin.exe works is that by default it connects to a site in "full control" mode which is fine. However, I wanted the option buttons present so that the user has a choice to connect to the site with a different view "file transfer" or "read-only".

Option Explicit
'''''Mode Num Vars''''''''
Dim ModeNum as Integer
Const Locked=1
Const Trans=2
'''''''''''''''''''''''''''''''''''''''''''
Const Path = "C:\Program Files\Radmin\radmin.exe" 'The full path in quotes where radmin.exe can be found.

''''''''''''''Set read only mode'''''''''''''''
Sub Option1_Click() 'I changed &lt;Read-only radiobutton&gt; to Option1 which is the name I have for my first button.
ModeNum=Locked

End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''
'''''''''''''''Set Transfer Mode''''''''''''''''
Sub Option2_Click() 'I changed &lt;Transfer radiobutton&gt; to Option2 which is the name I have for my second button
ModeNum=Trans

End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''
'''''''''''''''''Main Processing'''''''''''''''''''
Sub &lt;button name&gt;_Click() 'Which button name are you asking for here?
Dim SiteNum.
Const CmdPart = " /connect:" & SiteNum & "BO /locolor /updates:10"
SiteNum= "StoreNmbr" 'Changed this to StoreNmbr the name of my input box

If ModeNum = 1 Then
Shell Path & CmdPart & "/noinput", vbNormalFocus 'Run read only command
pwwait.Interval=2500 'I changed &lt;timername&gt; to pwwait which is just a name I came up with to stand for password wait

ElseIf ModeNum = 2 Then 'In reality, you *could* just type else and be done with this line.

Shell Path & CmdPart & "/file", vbNormalFocus 'Run transfer command at normal focus, so the sendkeys works
pwwait.Interval=2500 'Again &lt;timername&gt; switched to pwwait

End If

End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''
''''''''''''''''''Timer Function'''''''''''''''''''''
Sub pwwait_Timer() 'Again &lt;timername&gt; switched to pwwait

Dim WScript
Set WScript=CreateObject("Wscript.Shell")
WScript.SendKeys "hopethisworks" 'Added characters to send
pwwait.Interval=0 'Again &lt;timername&gt; switched to pwwait

End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''

unknown634
02-04-2004, 09:26 AM
Son of a...I could have sworn I put the form load in there...

Add This in at the end:
<font color=red>
Sub Form_Load()
Option1.Value=False
Option2.Value=False
ModeNum=Trans 'Defaults it to File Transfer in the background, should no option button be hit

End Sub
</font color=red>

For the Enter key thing, I will make it so if you hit ENTER in the text box, it will do the same thing as anm OK button. Change this line to (and there is a line below it to add in, but copy and paste should do that for you):
<font color=red>

Sub StorNmbr_KeyPress(KeyAscii as Integer) 'Which button name are you asking for here?
If KeyAscii=13 Then 'KeyAscii is picked up by the system, the Enter keys are 13.
</font color=red>
Add an End If right before the end sub.

Some other things I noticed were that there shouldn't be a period here:
<font color=blue>Dim SiteNum. </font color=blue>
And when you set a variable equal to another variable (in this case the textbox's Text property) DON'T use quotes, as then it will think that is a string with StoreNmbr in it.
<font color=blue>SiteNum= "StoreNmbr"</font color=blue>

You asked about having one modenum set to Locked and one to Trans.

What I did here was use a global integer (ModeNum) to store the mode number, but use two constants (Locked [equal to 1] and Trans [equal to 2]) to represent those numbers, so it's more easily recognizable in the code. In the If statement, I used these numbers to determine if it should run the Read-only command or the File Transfer command.

The option buttons set this variable to determine the mode. I made it in Form_Load set this equal to 2 by default, so it goes into File Transfer mode.

Well, I think *now* that should do it.
Let me know if you need anymore info.
-Unknown

Oh yeah, I have source codes of my progs on my site if you wanna check 'em out sometime. Email me on those (email on site) or post on my boards if you have questions bout those.

-----------------
C:\
C:\DOS
C:\DOS\RUN
RUN\DOS\RUN

mikhaelmas
02-04-2004, 01:12 PM
We're almost there...I can see the light at the end of the tunnel! Something else I noticed is that once an option button has been ticked you cannot untick it. So in order for the user to go back to "full control" mode they'd have to close the app and launch it again.

Option Explicit
'''''Mode Num Vars''''''''
Dim ModeNum As Integer
Const Locked = 1
Const Trans = 2
'''''''''''''''''''''''''''''''''''''''''''
Const Path = "C:\Program Files\Radmin\radmin.exe"

''''''''''''''Set file transfer view'''''''''''''''
Sub Option1_Click()
ModeNum = Locked

End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''
'''''''''''''''Set read only view''''''''''''''''
Sub Option2_Click()
ModeNum = Trans

End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''
'''''''''''''''''Main Processing'''''''''''''''''''
Sub StoreNmbr_KeyPress(KeyAscii As Integer) 'This whole line is highlighting yellow
If KeyAscii = 13 Then
Dim SiteNum
Const CmdPart = " /connect:" & SiteNum & "BO /locolor /updates:10" 'If I hit START as soon as I type the first character it goes back to the code and SiteNum is highlighted. Compile Error: Constant Expression Required is the popup.
SiteNum = StoreNmbr

If ModeNum = 1 Then
Shell Path & CmdPart & "/noinput", vbNormalFocus
pwwait.Interval = 2500

ElseIf ModeNum = 2 Then
Shell Path & CmdPart & "/file", vbNormalFocus
pwwait.Interval = 2500

End If

End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''
''''''''''''''''''Timer Function'''''''''''''''''''''
Sub pwwait_Timer()

Dim WScript
Set WScript = CreateObject("Wscript.Shell")
WScript.SendKeys "password"
pwwait.Interval = 0

End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''

unknown634
02-04-2004, 02:12 PM
Options buttons will do that. Once one is pushed, one will always be on. Add a command button that'll reset them Double click the command button and type this into the sub it creates (hence, I didn't put the Sub name and End Sub):

<font color=red>
Option1.value=false
Option2.value=false
ModeNum=Trans 'Resets the mode var
</font color=red>

That should do it. Hope you got it working all good.
Should you need further help, please post back.
-Unknown

-----------------
C:\
C:\DOS
C:\DOS\RUN
RUN\DOS\RUN

mikhaelmas
02-04-2004, 03:12 PM
Sorry I should of stated more clearly at the beginning of my last post I still have the compile error. See my previous post for the notes next to the code in the Main Processing section.

mikhaelmas
02-05-2004, 04:55 AM
I've also changed my Option1 and Option2 to Check1 and Check2 in case that changes the code any. The way I want the gui to work is:

- User enters 4 character site code

- If necessary they check off "File Transfer" or "Read-Only" to connect to the site with a particular view. The appropriate switch is appended to the end of:
C:\Program Files\Radmin\radmin.exe /connect:xxxxBO /locolor /updates:10 /noinput or /file

- If not they connect to the site with the default view which is "Full Control" and that string is = C:\Program Files\Radmin\radmin.exe /connect:xxxxBO /locolor /updates:10

- Hit ENTER

- Then WScript waits the 2500ms for the password pop-up and sends the appropriate keystrokes

- User is connected to the site

I know I've already said thanks before, but I really do appreciate all your help.

unknown634
02-05-2004, 09:13 AM
This should about do it....

<font color=red>
Option Explicit
'''''Mode Num Vars''''''''
Dim ModeNum As Integer
Const Full = 0
Const Locked = 1
Const Trans = 2
'''''''''''''''''''''''''''''''''''''''''''
Const Path = "C:\Program Files\Radmin\radmin.exe"

''''''''''''''Set file transfer view'''''''''''''''
Sub Check1_Click() 'read only checkbox
ModeNum = Locked
If check2.Value = 1 then check2.value = 0 'if check1 is checked, uncheck it

End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''
'''''''''''''''Set read only view''''''''''''''''
Sub Check2_Click() 'transfer checkbox
ModeNum = Trans
If check1.Value = 1 then check1.value = 0 'if check2 is checked, uncheck it

End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''
'''''''''''''''''Main Processing'''''''''''''''''''
Private Sub StoreNmbr_KeyPress(KeyAscii As Integer)
If Check1.Value = 0 And Check2.Value = 0 Then ModeNum = Full 'If both checks aren't checked, take Full Control using a constant variable
If KeyAscii = 13 Then
Dim SiteNum
SiteNum = StoreNmbr 'should fix below compile error
Const CmdPart = " /connect:" & SiteNum & "BO /locolor /updates:10"

If ModeNum = 0 Then 'This new part of the if (yeah, I coulda put it on the end, but I just like number order) takes into account the Full COntrol command line.
Shell Path & CmdPart, vbNormalFocus
pwwait.Interval = 2500

ElseIf ModeNum = 1 Then
Shell Path & CmdPart & "/noinput", vbNormalFocus
pwwait.Interval = 2500

ElseIf ModeNum = 2 Then
Shell Path & CmdPart & "/file", vbNormalFocus
pwwait.Interval = 2500

End If

End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''
''''''''''''''''''Timer Function'''''''''''''''''''''
Sub pwwait_Timer()

Dim WScript
Set WScript = CreateObject("Wscript.Shell")
WScript.SendKeys "password"
pwwait.Interval = 0

End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''
</font color=red>

Again, lemme know if you need anything else...
-Unknown

-----------------
C:\
C:\DOS
C:\DOS\RUN
RUN\DOS\RUN

mikhaelmas
02-05-2004, 09:49 AM
Still getting "Compile Error: Constant Expression Required" and it highlights SiteNum in "..... & SiteNum & .....". Then I hit OK and it puts a yellow arrow next to "Private Sub StoreNmbr........" and highlights that whole line in yellow.

mikhaelmas
02-05-2004, 10:29 AM
The checkmarks were working, but not correctly. I looked at the code and I think you might of just had the number reversed so I edited to reflect the following:
<font color=red>
''''''''''''''Set file transfer view'''''''''''''''
Sub Check1_Click() 'transfer checkbox
ModeNum = Locked
If Check1.Value = 1 Then Check2.Value = 0 'if check1 is checked, uncheck it

End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''
'''''''''''''''Set read only view''''''''''''''''
Sub Check2_Click() 'read only checkbox
ModeNum = Trans
If Check2.Value = 1 Then Check1.Value = 0 'if check2 is checked, uncheck it

End Sub </font color=red>

In this form if Check1 is checked Check2 cannot be checked and vice versa. Your way worked also but it forced you to check a box twice to get the check to actually show up.

I also changed the following line:

<font color=red>If Check1.Value = 0 And Check2.Value = 0 Then ModeNum = 0 'If both checks aren't checked, take Full Control using a constant variable</font color=red>

Your line said <font color=red>"......Then ModeNum = Full"</font color=red> I think your meant to put 0

I can't figure out the compile error though....

unknown634
02-05-2004, 11:44 AM
Found the compile error...a lil stupid mistake....
Replace this:
<font color=red>
Const CmdPart = " /connect:" & SiteNum & "BO /locolor /updates:10"
</font color=red>

With

<font color=blue>
Dim CmdPart as String
CmdPart = " /connect:" & SiteNum & "BO /locolor /updates:10"
</font color=blue>

It was doing that because of the variable part in the string.
Now it should work...

An I saw my checkbox error. Least you caught it/images/forums/icons/smile.gif

This (should) hopefully get it working.
Need anything else, just post away...
-Unknown

-----------------
C:\
C:\DOS
C:\DOS\RUN
RUN\DOS\RUN

mikhaelmas
02-05-2004, 11:52 AM
We're gonna get beat this thing darnit!

Now I get a "Compile Error: Variable Not Defined." and it highlights the first instance of pwwait

<font color=red>pwwait.Interval = 2500</font color=red>

unknown634
02-05-2004, 02:08 PM
Check the (Name) property on the Timer object & see if you somehow inadvertanely renamed it. Trust me, I've done that several times.

-----------------
C:\
C:\DOS
C:\DOS\RUN
RUN\DOS\RUN

mikhaelmas
02-06-2004, 11:41 PM
Okay I didn't have a timer object. So...added one and named it pwwait and left all the other properties as default. New problem "Compile Error: Block If without End If"

<font color=red>Option Explicit
'''''Mode Num Vars''''''''
Dim ModeNum As Integer
Const Full = 0
Const Locked = 1
Const Trans = 2
'''''''''''''''''''''''''''''''''''''''''''
Const Path = "C:\Program Files\Radmin\radmin.exe"
''''''''''''''Set file transfer view'''''''''''''''
Sub Check1_Click() 'transfer checkbox
ModeNum = Locked
If Check1.Value = 1 Then Check2.Value = 0

End Sub
'''''''''''''''Set read only view''''''''''''''''''
Sub Check2_Click() 'read only checkbox
ModeNum = Trans
If Check2.Value = 1 Then Check1.Value = 0

End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''' '
'''''''''''''''''Main Processing'''''''''''''''''''
Private Sub StoreNmbr_KeyPress(KeyAscii As Integer)
If Check1.Value = 0 And Check2.Value = 0 Then ModeNum = 0
If KeyAscii = 13 Then
Dim SiteNum
SiteNum = StoreNmbr
Dim CmdPart As String
CmdPart = " /connect:" & SiteNum & "BO /locolor /updates:10"

If ModeNum = 0 Then
Shell Path & CmdPart, vbNormalFocus
pwwait.Interval = 2500

ElseIf ModeNum = 1 Then
Shell Path & CmdPart & "/noinput", vbNormalFocus
pwwait.Interval = 2500

ElseIf ModeNum = 2 Then
Shell Path & CmdPart & "/file", vbNormalFocus
pwwait.Interval = 2500

End If

End Sub<font color=blue> 'This is what highlights when the compile error pops up</font color=blue>
'''''''''''''''''''''''''''''''''''''''''''''''''' '''
''''''''''''''''''Timer Function'''''''''''''''''''''
Sub pwwait_Timer()

Dim WScript
Set WScript = CreateObject("Wscript.Shell")
WScript.SendKeys "password"
pwwait.Interval = 0

End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''</font color=red>

unknown634
02-07-2004, 08:17 PM
To fix the Block end without if:

I went and forgot to add the 2nd end if for the one I added!

Long story short, add an <font color=blue>End If</font color=blue> right before the End Sub under Main Processing. To give you an idea of where, here's a part of the code around where it needs to go:

<font color=red>
ElseIf ModeNum = 2 Then
Shell Path & CmdPart & "/file", vbNormalFocus
pwwait.Interval = 2500

End If
<font color=blue>End If</font color=blue>

End Sub 'This is what highlights when the compile error pops up
'''''''''''''''''''''''''''''''''''''''''''''''''' '''
''''''''''''''''''Timer Function'''''''''''''''''''''
</font color=red>

This should do it.
If you need...ah forget it; you know I'll help you/images/forums/icons/smile.gif
-Unknown

-----------------
C:\
C:\DOS
C:\DOS\RUN
RUN\DOS\RUN

mikhaelmas
02-08-2004, 09:00 AM
IT'S ALIVE! It works....Now just some fine tuning. Right now "ENTER" doesn't trigger it unless the cursor is in the text box. If I'm just connecting to a site with full control that works fine. If I'm connecting to a site and I check one of the options and hit "ENTER" nothing happens. I have to put the cursor back in the text box and hit "ENTER" then it works. How do we fix it so that as long as the gui is the active window "ENTER" triggers it regardless of cursor location? Also after it connects to the site the task is minimized. How can we make it so that after the connection it is the active window? Here's the code as it is now:

<font color=red>Option Explicit
'''''Mode Num Vars''''''''
Dim ModeNum As Integer
Const Full = 0
Const Locked = 1
Const Trans = 2
'''''''''''''''''''''''''''''''''''''''''''
Const Path = "C:\Program Files\Radmin\radmin.exe"

''''''''''''''Set file transfer view'''''''''''''''
Sub Check1_Click()
ModeNum = Locked
If Check1.Value = 1 Then Check2.Value = 0

End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''
'''''''''''''''Set read only view''''''''''''''''
Sub Check2_Click() 'read only checkbox
ModeNum = Trans
If Check2.Value = 1 Then Check1.Value = 0

End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''
'''''''''''''''''Main Processing'''''''''''''''''''
Private Sub StoreNmbr_KeyPress(KeyAscii As Integer)
If Check1.Value = 0 And Check2.Value = 0 Then ModeNum = 0
If KeyAscii = 13 Then

Dim SiteNum
SiteNum = StoreNmbr

Dim CmdPart As String
CmdPart = " /connect:" & SiteNum & "BO /locolor /updates:10"

If ModeNum = 0 Then
Shell Path & CmdPart, vbNormalFocus
pwwait.Interval = 400

ElseIf ModeNum = 1 Then
Shell Path & CmdPart & " /file", vbNormalFocus<font color=blue> 'the switches were not working at first cause they needed a space - fixed that</font color=blue>
pwwait.Interval = 400<font color=blue> '2500ms seemed like it was taking forever and I read somewhere that if I was to put 1ms it's actually equal to about 52ms</font color=blue>

ElseIf ModeNum = 2 Then
Shell Path & CmdPart & " /noinput", vbNormalFocus
pwwait.Interval = 400

End If
End If

End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''
''''''''''''''''''Timer Function'''''''''''''''''''''
Sub pwwait_Timer()

Dim WScript
Set WScript = CreateObject("Wscript.Shell")
WScript.SendKeys "password"
WScript.SendKeys "{ENTER}"<font color=blue> 'after the password was entered it was just sitting there so I put in a ENTER keystroke</font color=blue>
pwwait.Interval = 0

End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''</font color=red>

unknown634
02-08-2004, 09:40 AM
Add a KeyPress procedure for the two checkboxes:

<font color=red>
Sub Check1_KeyPress(KeyAscii as Integer)
StorNmbr_KeyPress(KeyAscii)

End Sub
</font color=red>
Repeat for the other checkbox and those will do what hitting enter on the textbox does

And by task, are you talking about the Radmin program minimizing itself? Because that's something you can't make the program do as far as I know.
You can, however, add a <font color=blue>SendKeys %{TAB}</font color=blue> statement at the end of Main Processing, which would ALT-TAB the focus to the next window (which should be Radmin) and bring it back up.

I'm still around if you need any more info,
Unknown

-----------------
C:\
C:\DOS
C:\DOS\RUN
RUN\DOS\RUN

mikhaelmas
02-08-2004, 10:09 AM
Okay I was smoking crack on the minimize thing. I closed all my windows and ran just the app and it works fine. On the keypress for the check boxes where do I add that bit of code in at? And where/which property lets me add a custom made icon to the left of my title in the title bar? I tried icon and that doesnt seem to do anything...

mikhaelmas
02-08-2004, 10:28 AM
Okay I had the wrong border style so that's what was preventing ICON from working. I had 4-Fixed ToolWindow instead of 1-Fixed Single. But, I still haven't figured out where to add in the keypress code for the check boxes.

unknown634
02-08-2004, 12:58 PM
Good to see you caught the icon. As for the checkbox KeyPress code, you can append that onto the bottom of your code.

Now you should be good to go/images/forums/icons/smile.gif

-Unknown

-----------------
C:\
C:\DOS
C:\DOS\RUN
RUN\DOS\RUN

mikhaelmas
02-09-2004, 05:44 AM
I added a command button to the gui. What I wanted it to do was open a cmd prompt and run ping XXXXBO -l 132 -t. I added the following code right before Main Processing:

<font color=red>Private Sub Command1_Click()

Const Path = "C:\WINNT\system32\cmd.exe"

Dim SiteNum
SiteNum = StoreNmbr

Dim PingPart As String
PingPart = "ping" & SiteNum & "BO -l 132 -t"

Shell Path & PingPart, vbNormalFocus

End Sub</font color=red>

I get a <font color=blue>"Run-Time error '53' file not found"</font color=blue> error when I click on the button.

Brf
02-09-2004, 08:32 AM
I think you need some spaces in there. When you are concantinating everything into the command-line you have no spaces and it is smashing it all together.

It should say this (note the spaces between the words):

PingPart = "ping " & SiteNum & " BO -l 132 -t"

Shell Path & " " & PingPart, vbNormalFocus

mikhaelmas
02-09-2004, 08:47 AM
K that works.....it pulls up a cmd prompt, but it never sends the string. Is that because it actually is sending the string, but it's just too fast. Like it sends the string before the cmd window even has a chance to open?

Brf
02-09-2004, 10:10 AM
I think the cmd.exe needs the /K switch, so it says:

Const Path = "C:\WINNT\system32\cmd.exe /K "


otherweise it doesnt execute the command.

mikhaelmas
02-09-2004, 10:58 AM
K I'm lost I can't get this dern cmd button to work. See previous posts for what I wanted it to do...

unknown634
02-09-2004, 01:22 PM
<font color=red>
Sub Command1_Click()
Dim SiteNum
SiteNum = StoreNmbr
Const CMDPath="cmd.exe /k ping "
Shell CMDPath & SiteNum & "BO -l 132 -t", vbNormalFocus

End Sub
</font color=red>

Try this, I tested it with VERY similar syntax and it worked fine.

Lemme know if you need anything else...
-Unknown

-----------------
C:\
C:\DOS
C:\DOS\RUN
RUN\DOS\RUN

mikhaelmas
02-09-2004, 01:27 PM
Your the man! Worked like a charm...

unknown634
02-09-2004, 02:23 PM
S' you got it all working like you wanted? Coolness/images/forums/icons/smile.gif

Oh yeah, if you want, you can check out some progs I've done in VB <a target="_blank" href=http://www-personal.umd.umich.edu/~amalenfa>here</a> Look in the downloads page for exe's. I got the source up too. Go 'head an post on the board I've linked on the site too if wanna know bout those.

Unknown

-----------------
C:\
C:\DOS
C:\DOS\RUN
RUN\DOS\RUN

mattmac24
02-12-2004, 04:11 AM
ok well i have no scripting skills so as i guessed when i tryed to copy what you have done it did not work. can somebody plase post or email me at mattishstuff@hotmail.com with the completed script and how to work it(well hopefully just double click)

You guys are so smart....and does anybody know a site that teaches you how to do stuff like that?^^^^ coz i really want to learn. you can do so much stuff.

Thanks in advance, Matt

mikhaelmas
02-12-2004, 08:57 AM
How can I make it so that after someone checks and option and hits ENTER it does it's deal and then clears the check mark?

Most recent version of code:<font color=red>

Option Explicit
'''''Mode Num Vars''''''''
Dim ModeNum As Integer
Const Full = 0
Const Locked = 1
Const Trans = 2
'''''''''''''''''''''''''''''''''''''''''''
Const Path = "C:\Program Files\Radmin\radmin.exe"

''''''''''''''Set file transfer view'''''''''''''''
Sub Check1_Click()
ModeNum = Locked
If Check1.Value = 1 Then Check2.Value = 0

End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''
'''''''''''''''Set read only view''''''''''''''''
Sub Check2_Click() 'read only checkbox
ModeNum = Trans
If Check2.Value = 1 Then Check1.Value = 0

End Sub
Sub Command1_Click()
Dim SiteNum
SiteNum = StoreNmbr
Const CMDPath = "cmd.exe /k ping "
Shell CMDPath & SiteNum & "BO -l 132 -t", vbNormalFocus

End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''
'''''''''''''''''Main Processing'''''''''''''''''''
Private Sub StoreNmbr_KeyPress(KeyAscii As Integer)
If Check1.Value = 0 And Check2.Value = 0 Then ModeNum = 0
If KeyAscii = 13 Then

Dim SiteNum
SiteNum = StoreNmbr

Dim CmdPart As String
CmdPart = " /connect:" & SiteNum & "BO /locolor /updates:10"

If ModeNum = 0 Then
Shell Path & CmdPart, vbNormalFocus
pwwait.Interval = 500

ElseIf ModeNum = 1 Then
Shell Path & CmdPart & " /file", vbNormalFocus
pwwait.Interval = 500

ElseIf ModeNum = 2 Then
Shell Path & CmdPart & " /noinput", vbNormalFocus
pwwait.Interval = 500

End If
End If

End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''
''''''''''''''''''Timer Function'''''''''''''''''''''
Sub pwwait_Timer()

Dim WScript
Set WScript = CreateObject("Wscript.Shell")
WScript.SendKeys "password"
WScript.SendKeys "{ENTER}"
pwwait.Interval = 0

End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''
Sub Check1_KeyPress(KeyAscii As Integer)
StoreNmbr_KeyPress (KeyAscii)

End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''
Sub Check2_KeyPress(KeyAscii As Integer)
StoreNmbr_KeyPress (KeyAscii)

End Sub</font color=red>

unknown634
02-12-2004, 09:06 AM
Add to the end of Main Processing this:

<font color=red>
Check1.Value = 0
Check2.Value = 0
</font color=red>

This'll kill off the checks in both boxes after doing its work.

Mattmac24: I sent on a copy of the code... an see if <a target="_blank" href=http://www.w3schools.com/vbscript/default.asp>this site</a> helps you any

I'll be lurking if anyone else needs anything...
Unknown

-----------------
C:\
C:\DOS
C:\DOS\RUN
RUN\DOS\RUN

mikhaelmas
02-12-2004, 09:20 AM
As usual it was one stop shop with you. Thanks again it works perfect....

mikhaelmas
02-12-2004, 09:36 AM
Since I can't ever seem to stump you...How would we go about making the program dockable in the taskbar, or in IE's toolbar?

mattmac24
02-13-2004, 02:38 AM
if you mean like the norton antivirus one i have (but turned off) that would be pretty cool.

i mean up in the same place near where ur current dir is.



if possible please explain how to do so we can make our own for all sorts of programs...and shortcuts to folders


good idea....just wish i knew how 2 do it

<P ID="edit"><FONT class="small">Edited by mattmac24 on 02/13/04 03:45.</FONT></P>

unknown634
02-13-2004, 11:35 AM
Hmm....interesting idea I never looked into before...might be something to try to do...

-----------------
C:\
C:\DOS
C:\DOS\RUN
RUN\DOS\RUN

mikhaelmas
02-15-2004, 06:31 AM
K while your pondering the other idea. How about after clicking a command button how do I make the cursor or focus return to the text box? Also is there a way to keep the ENTER key from repeating? Right now if someone has a "lead finger" and they hit ENTER it will cause the program to open up 3+ sessions depending on how long they hold down the key. I don't want to take away the ability to have more than one session open at once, just the "lead finger syndrome".

unknown634
02-15-2004, 03:53 PM
Textbox return after command button:

Add this to the end of the button code:

<font color=red>SiteNmbr.SetFocus</font color=red>

As for killing the lead finger, add a new timer object and set the Interval equal to whatever timeout you want (say if you wanted to have it wait for 2 seconds, make Interval 2000)

Add this code (I used the default name Timer1; you can change it if you want):
<font color=red>
Sub Timer1_Timer()
SiteNmbr.Enabled=True 're-enables the textbox events and editing
Timer1.Interval=0

End Sub
</font color=red>

and add this to the end of Main Processing:
<font color=red>
SiteNmbr.Enabled=False 'disables textbox editing and events
Timer1.Interval=&lt;number of milliseconds to wait&gt;
</font color=red>

That should cover it...I will update the downloadable files soon.

-Unknown

-----------------
C:\
C:\DOS
C:\DOS\RUN
RUN\DOS\RUN

mikhaelmas
02-17-2004, 06:17 AM
Okay everything works, but the lead finger timer is kicking in after each character that is in the text box instead of after the ENTER key.

Focus is returning to the text box like I wanted after a command button is click. Is there any way to have it not only return to the text box, but "Select All" too?

Like I want it to return focus to the text bar and highlight everything in the textbox.

unknown634
02-17-2004, 11:53 AM
Yet Another Stupid Mistake.

You don't want to set that timer's property at runtime (i.e., use the default, 0)

And add this after the Storenmbr.SetFocus Statement:

<font color=red>Storenmbr.SelLength=Len(storenmbr)</font color=red>

That should clear it up.

Need anything else, I will be lurking.
-Unknown

-----------------
C:\
C:\DOS
C:\DOS\RUN
RUN\DOS\RUN

mikhaelmas
02-22-2004, 05:40 AM
In case you (mattmac24) don't get my response to your PM....

If your referring to "Remote Shutdown", as in shutting down the remote computer, then the command switch for that is <font color=red>/shutdown</font color=red>. So the whole string would look like this:

<font color=red>/connect:(ip goes here) /hicolor /updates:100 /shutdown</font color=red>

Here is a list of all the other available switches:

<font color=blue>Usage: radmin.exe /connect:xxxxx:nnnn other_options

Examples: radmin.exe /connect:server:1000 /fullscreen /encrypt
radmin.exe /connect:10.0.0.100:4000 /telnet
radmin.exe /connect:server /through:gate

Options:
/connect:xxxxx:nnnn - specify an address and a port of the server. This option is required for
connection without a phonebook.

/through:xxxxx:nnnn - specify an address and a port of the intermediate server
By default, connection mode is 'Full control' (see remote screen, send mouse and keyboard input)
To specify other connection modes use switches:

/noinput - specify a View only connection mode (view of remote screen).

/shutdown - specify a Shutdown connection mode

/file - specify a File connection mode

/telnet - specify a Telnet connection mode
These switches are used in 'Full control' and 'View only' modes:

/fullscreen - specify the fullscreen view mode

/hicolor - specify a 65536 color format, while transferring via a network.

/locolor - specify a 16 color format, while transferring via a network.

/updates:nn - specify a maximum number of screen updates per second

/encrypt - specify to encrypt data stream
Other switches:

/unregister - delete already entered key for Remote Administrator.

/? - shows help screen</font color=blue>

mikhaelmas
02-22-2004, 05:47 AM
The "lead finger" timer and the select all text after returning focus to the text box still do not work. I haven't had the time to play with it though in the past few days. It doesn't generate any errors. It just doesn't work. The timer still pauses data entry in between each character...actually now that I think about it all it lets you enter is one character. You get to enter one character it grays the text box out. After the timer expires it lets you type again and your input goes right over the last character typed.

*UPDATE* Ok. I was partially wrong. The lead finger timer does disable the textbox and appears to be waiting the appropriate time before re-enabling. However, subsequent characters are not written after or over the initial character. Since no errors are being generated I'm guessing it's where I have the line of code positioned in the whole scheme of things?

<font color=red>Option Explicit
'''''Mode Num Vars''''''''
Dim ModeNum As Integer
Const Full = 0
Const Locked = 1
Const Trans = 2
'''''''''''''''''''''''''''''''''''''''''''
Const Path = "C:\Program Files\Radmin\radmin.exe"

''''''''''''''Set file transfer view'''''''''''''''
Sub Check1_Click()
ModeNum = Locked
If Check1.Value = 1 Then Check2.Value = 0

End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''
'''''''''''''''Set read only view''''''''''''''''
Sub Check2_Click() 'read only checkbox
ModeNum = Trans
If Check2.Value = 1 Then Check1.Value = 0

End Sub
Sub Command1_Click()
Dim SiteNum
SiteNum = StoreNmbr
Const CMDPath = "cmd.exe /k ping "
Shell CMDPath & SiteNum & "BO -l 132 -t", vbNormalFocus
StoreNmbr.SetFocus
StoreNmbr.SelLength = Len(StoreNmbr)

End Sub
Sub Command2_Click()
Dim SiteNum
SiteNum = StoreNmbr
Const CMDPath = "cmd.exe /k ping "
Shell CMDPath & SiteNum & "RTR -l 132 -t", vbNormalFocus
StoreNmbr.SetFocus
StoreNmbr.SelLength = Len(StoreNmbr)

End Sub
Sub Command3_Click()
Dim SiteNum
SiteNum = StoreNmbr
Const CMDPath = "cmd.exe /k ping "
Shell CMDPath & SiteNum & "GW -l 132 -t", vbNormalFocus
StoreNmbr.SetFocus
StoreNmbr.SelLength = Len(StoreNmbr)

End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''
'''''''''''''''''Main Processing'''''''''''''''''''
Private Sub StoreNmbr_KeyPress(KeyAscii As Integer)
If Check1.Value = 0 And Check2.Value = 0 Then ModeNum = 0
If KeyAscii = 13 Then

Dim SiteNum
SiteNum = StoreNmbr

Dim CmdPart As String
CmdPart = " /connect:" & SiteNum & "BO /locolor /updates:10"

If ModeNum = 0 Then
Shell Path & CmdPart, vbNormalFocus
pwwait.Interval = 500

ElseIf ModeNum = 1 Then
Shell Path & CmdPart & " /file", vbNormalFocus
pwwait.Interval = 500

ElseIf ModeNum = 2 Then
Shell Path & CmdPart & " /noinput", vbNormalFocus
pwwait.Interval = 500

End If
End If

Check1.Value = 0
Check2.Value = 0

StoreNmbr.Enabled = False 'disables textbox editing and events
leadfinger.Interval = 3000

End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''
''''''''''''''''''Timer Function'''''''''''''''''''''
Sub pwwait_Timer()

Dim WScript
Set WScript = CreateObject("Wscript.Shell")
WScript.SendKeys "password"
WScript.SendKeys "{ENTER}"
pwwait.Interval = 0

End Sub
Sub leadfinger_Timer()
StoreNmbr.Enabled = True 're-enables the textbox events and editing
leadfinger.Interval = 0

End Sub

'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''
Sub Check1_KeyPress(KeyAscii As Integer)
StoreNmbr_KeyPress (KeyAscii)

End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''
Sub Check2_KeyPress(KeyAscii As Integer)
StoreNmbr_KeyPress (KeyAscii)

End Sub</font color=red><P ID="edit"><FONT class="small">Edited by mikhaelmas on 02/22/04 06:08.</FONT></P>

mattmac24
02-22-2004, 12:04 PM
ok thanks alot, no i didnt get ur response....i thought it would email if u replyied..but obvioulsy not..thanks heaps.

matt