Web browser that can not be closed - vb.net

I am trying to create a locked down browser for the employees at my work to use at a kiosk. I need to prevent the user from getting out of the app. I have figured out how to prevent them from closing it by pressing alt-f4 or ctrl-f4 but I would like to also prevent alt-esc, ctrl-esc, alt-tab, and the windows key. Can anyone help me figure out how to do this? I am new to windows application development but have experience in web vb.net. I am using VB.NET 2010 express. Thanks.

Rather than do that, why not just Cancel the close?
Handle the Closing event on your form and set Cancel to true.
Public Class MyForm Inherits Form
//Wire the event...
Public Sub MyForm_FormClosing(sender as Object, args as FormClosingEventArgs) Handles Closing
args.Cancel = True
End Sub
End Class
That way, you can decide when it should be closed and it doesn't matter what other ways the user thinks of.
As Cody mentioned in the comments, a lot of this should be enforced (and some can only be enforced) by Group Policy. You can script Group Policy settings, to make it easily deployable.

Related

Automatic login when run the program second time

Recently try to use a webbrowser component.
when I click button, it will navigate to facebook.com. after I login on first time and stop the program. and then when I run the program second time I don't need to fill the email and password. why I don't need to fill an email and password textbox ? thanks
Here's the code
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
WebBrowser1.Navigate("m.facebook.com")
End Sub
End Class
Note: I will delete this post, because it doesn't help the community. Just my curiosity. Thanks
how do i need to re-type the email password again when 2nd starting the program
You have two options:
The first is to save the CookieContainer associated with the WebBrowser to disk and reload it when you restart your program. There is no straightforward way to serialize cookies to disk or other storage method - that is up to you.
Instruct the WebBrowser object to make use of the user's Windows profile Internet Explorer cookie collection which is shared with Internet Explorer and other programs that also opt-in to sharing state (I do not know if this also applies to the Edge browser, I suspect it does not). See here for instructions on how to do this: Use cookies from CookieContainer in WebBrowser

Win Forms VB App in Win 10 - focus issues

I have an app built in VB in Visual Studio 2012 that works absolutely fine on my windows 10 desktop, but as soon as i use it on my windows 10 tablet i see a couple of issues :
1) any forms that were intended to be smaller than full screen are shown fullscreen anyway (almost as if you're not allowed any windows less than full screen) i can live with that if need be, but surely theres a way around it?
2) - the most important one - for some strange reason, i start my app, and when i click on a button let's say it opens form 6. once i finish what i'm doing the code closes the form 6, but the previous form is now hidden and all you see is the desktop. ie it's still running, it just lost its focus and must be selected again. I understand i could set the focus to the underlying form before closing form 6, but here's the problem : it can be one of several different forms calling form 6..... so how do i make the app stay aware of what form called form6 so that when done i can return focus there?
this doesnt seem to be a problem on the desktop so i've never encountered it before. i hope one of you experts has dealt with this before
I don't have enough points yet to comment. My guess for #1 is either resolution or DPI differences between the 2 screens, and I don't have experience with the latter.
As for #2 and keeping the form aware of who called it, this is how I do it, which may not be the best solution, of course. ;)
First any form that can have multiple callers has a variable defined like
Dim callingForm As New Form
I typically create an Initialize routine to handle as much as possible before loading a form and this routine is called with the parent form (Me) as a parameter.
Dim frm As New frmClient
frm.Initialize(Me)
frm.Show()
Me.Hide()
In Initialize, callingForm is set to the parent
Public Sub Initialize(parent As Form)
callingForm = parent
'whatever else you need to do to init...
End Sub
Then when you exit the form...
Private Sub exitForm()
'whatever other closing stuff you need to do...
callingForm.Show()
Me.Close()
End Sub
That should get you started.
fyi for anyone encountering this problem, i solved it myself and it didn't require any coding. It was a difference between how vb apps act when the tablet is in "TABLET" mode, and when tablet mode is switched off. So all that needed doing is switching off enhanced tablet mode in the windows 10 settings

Possible to start an application without a GUI but show GUI if required?

I have a small application that monitors an external executable to ensure that it is running/perform upgrades, etc. This application has to run all the time, however, I need it to run semi-invisible to the user.
By this I mean that when the application first launches, it has not GUI (runs as a process but has no interface to the user). However, if required, the user can launch the application again which will bring up the GUI so they can see what's going on.
I already run the external executable in the system tray, so I didn't really want to create two icons in the system tray for the one thing if possible. I would much prefer this utility to just run in the background until needed.
I can start the application minimized and set ShowInTaskbar = false but I then don't know how to access the GUI if required.
Is this possible? Or can someone suggest a method of achieving this? Do I need to create another exe to simply set the window state back to normal?
Any help or guidance would be appreciated. Thanks
Try this code:
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Me.Visible = False
Me.ShowInTaskbar = False
End Sub
You can make it visible again by setting the two aforementioned properties to True.
Use a NotifyIcon and show your GUI for ex. on a doubleclick. You can even use the icon as a status indicator. To hide it on start use this one: varocarbas answer and to show just set me.visisble to true.
I just think a NotifyIcon is better than starting the exe a second time to show the gui.

VB.Net button open multiple user and auto login in different window of IE

I have a website stored 100 users ....now i want to create a VB form with 100 buttons ....while i click button1, it will open IE then log in users1 automatic and when i click button2 , it will open IE then log in as user2 automatic. user3 until user100 the same ....click from button on vb form.
Note : i am already done to set open IE and log in as different users in each windows but now i am finding how to set auto log in with different users in the same website when i click each button in form.
i have something more about form....i will use ( 100 button click = 100 users = 100 IE window ....)
it depend on user click on button that he need to log in......because we don't know that what button/users/time will he want to click .....
I really need your help urgently...
Thank in advanced.
here is some code of Button_Click
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Using p As New Process
p.StartInfo.FileName = "C:\Program Files\Internet Explorer\iexplore.exe"
p.StartInfo.Arguments = "http://test.com"
p.Start()
End Using
This is the only way I can come up with on how to solve this.
My guess is that your login is using POST variables, it's pretty much standard.
To make this work you would have to allow the username and password to be supplied with GET. That is, sending them in the url like this:
http://test.com/login.php/asp?username=username&password=password
Since you haven't specified whether you use PHP or ASP.NET I will add info on how to get the value for both:
ASP.NET
Request.Querystring("username")
PHP
$_GET["username"];
EDIT based on comment
You are correct it is not possible to isolate separate webbrowser controls.
I would suggest you look into either WaTin to control separate IE instances, or Awsomium .NET, which i believe allows separate sessions in 1.7, though i haven't tested it.
Also be aware that since IE8 session cookies are shared across instanced by default, so you would need to run them with the -nomerge flag. WaTin supports this.
Based on the fact that you have not mentioned this in your question, i am presuming you are using IE7. If that is the case, and this application is not intended to be used on other machines, it should be possible to create a separate application with an embeded webbrowser control, then launch multiple insatances of that application from the main one, so you can add your own communication mechanism, but WaTin is probably a far better idea
OLD ANSWER:
It is very hard to work out what you want to do, but im guessing you want to create a winforms app, that lets you to choose a user account, and then open a browser and login to a website with that account.
Based on that assumption, my suggestion would be to have one button, and some way of selecting the account, say a comboBox, and a webbrowser control:
http://img198.imageshack.us/img198/888/66649645.jpg
Rather than 1 button per user account and trying to manipulate an external browser.
If this is indeed what you want to do, comment and i will edit my answer as required, and provide starting code if you need, but i cant do that without really undertanding what you need to do.

My application won't terminate

VB.NET program.
While developing on Visual Studio Express 2010, there are two buttons: Start Debugging, and Stop Debugging.
Well, while debugging, I close my application (the red X button). However, when I look back at Visual Studio, it seems to still be in debugging mode (the Start button is disabled, and the Stop button is enabled). So I have to manually press the Stop button.
I remember it was not like this before.
Perhaps it is because my application uses multiple forms or something? Then I am probably missing something rather important... Any ideas?
You've got something open somewhere. You can force the entire app to quit by adding
End
in the form's FormClosed event:
Private Sub Form1_FormClosed(sender As Object, e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
End
End Sub
Are you doing any threading? Shutting down your primary app leaving threads running will cause what you are seeing. Also app design can cause what you are seeing. You can start your vb.net app running a "main" procedure, but if you don't provide an exit for it, the app will continue to run.
Ensure that all hidden forms (if any) are closed, properly dispose all objects.
If you are hiding any form and forgot to close it in your application this scenario may happen. Or if you are using threading in your application and they are not terminating properly then also it happens.