Showing posts with label VB.NET. Show all posts
Showing posts with label VB.NET. Show all posts

Thursday 7 June 2012

Invoking JavaScript function from WinForms

I've been working on application that needs to load page and display it in WebBrowser control. Requirement was to allow interaction between WinForms application and web page.
Here I will show a sample application where JavaScript function is called from WinForms application.
For this Blog I will be using Google Web elements , Google Web Elements allow you to easily add your favorite Google products to your website.
Process can be described by following steps:
Create Windows Forms application
Drop WebBrowser control into Form
Create Html with JavaScript function you want to call
Calling JavaScript function from WinForms application isn't so difficult.
.NET WebBrowser control has property Document which gets an HtmlDocument representing the Web page currently displayed in the WebBrowser control.
Well this javascript part is not well written ,maybe my Web God-Like Buddy (Rustan)) can clean this mess..lol
anyway here's the script
JAVASCRIPT
  1. <script type="text/javascript">
  2. google.load("elements", "1", {packages: "keyboard"});
  3. var kbd;
  4. function onLoad() {
  5. var content = document.getElementById('content');
  6. // Create the HTML for out text area
  7. content.innerHTML = '<div>' +
  8. 'Demo of Invoking JavaScript using .NET' +
  9. '.</div>' +
  10. '<textarea id="t1" cols="47" rows="7"></textarea>';
  11. kbd = new google.elements.keyboard.Keyboard(
  12. [google.elements.keyboard.LayoutCode.ENGLISH],
  13. ['t1']);
  14. }
  15. function ChangeLayout() {
  16. var LayOut=document.getElementById('txtLang').value;
  17. kbd.setLayout(LayOut);
  18. }
  19. function toggleVisible() {
  20. if (kbd.isVisible()) {
  21. kbd.setVisible(false);
  22. } else {
  23. kbd.setVisible(true);
  24. }
  25. }
  26. google.setOnLoadCallback(onLoad);
  27. </script>
So how can you call JavaScript functions in your WebBrowser control? Call the InvokeScript method on the HtmlDocument.
.NET CODE (winforms)
  1. Sub SHOW_HIDE_VIR_KEYBOARD()
  2. With Me.WBrowser
  3. .Document.InvokeScript("toggleVisible", New Object() {""}) 'call the javascript from the .htm files
  4. End With
  5. End Sub
  6. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdShow.Click
  7. SHOW_HIDE_VIR_KEYBOARD()
  8. End Sub
  9. Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
  10. With Me.WBrowser
  11. .Document.GetElementById("txtLang").InnerText = Trim(Me.ComboBox1.Text) 'parse data from winforms to Htm files
  12. .Document.InvokeScript("ChangeLayout", New Object() {""}) 'call the javascript from the .htm files
  13. End With
  14. End Sub
Conclusions:
With the ability to call JavaScript from .NET App you can now embed and extend web applications into native applications with ease. A native application gives you more control over the environment and access to computer resources that you cannot access from a web page. You can Mashup web applications with computer hardware or software in new and interesting ways.
For the complete sample please download the demo project
For questions just Contact me @ the Addresses below:
Download Code: 
Sample Project
Facebook Fan Page



comments

Wednesday 6 June 2012

.NET Code (Sending and Receiving SMS using AT Commands via GSM Phone )

You can request for the Demo version or obtain the full source code of .NET SMS Server (pure AT commands, no OCX or dll) , just contact me @ the addresses below.







comments

.NET TV Tuner (Digital/Cable/Analog )



By 2015 all analog/Cable TV will be replalced by Digital TVs using Digital Signal like in Japan and other advance countries
The NTC decided that the Philippines will use and adopt the ISDB-T, finally.
So geek-gadgets people can watch live HD Channels for  free and Paid (PPV) from their PSP, Mobile Phones ,Tablets and ofcource PC and Laptops.
Sources:
I decided to do a research in order to interface and  create a Windows based Digital TV Tuner using .NET and COM32 components. 

Hardware Requirements:
1)Digital TV Tuner Installed (in my case I used Pixel View and Encore TV Tuners)
Programming Requirements:
1)MSVidCtl (COM32 Components)
sample Codes still in BETA.

Thanks and Enjoy!!! HAppy Coding!!!
Download Code: 
Sample Project
Facebook Fan Page




comments

INPOUT32.dll under .NET (Sending Data via parallel port )



Sample how to send data to LPT or printer port using INPOUT32.dll from Lakeview Research..
This time .NET version , very handy and quite stable under Windows XP.
Good for Software-Hardware Engineers and design projects.
  1. Option Strict Off
  2. Option Explicit On
  3. Module InpOut32_Declarations
  4. 'Inp and Out declarations for port I/O using inpout32.dll.
  5. Public Declare Function Inp Lib "inpout32.dll" Alias "Inp32" (ByVal PortAddress As Short) As Short
  6. Public Declare Sub Out Lib "inpout32.dll" Alias "Out32" (ByVal PortAddress As Short, ByVal Value As Short)
  7. End Module
DLL downlload links

Paste the INPOUT32.dll to C:\Windows\System\
Thanks and Enjoy!!! HAppy Coding!!!
Download Code: 
Sample Project
Facebook Fan Page


comments

.NET Language Translator using Google Translate API


This is a sample app written in .NET on how to use the Google Translate API.

Can be ported to your existing App or even use as a Client Google Translator (Windows version)

Feature:
  • Support all functions of Google Ajax Language API.
  • CLS compatible. It can be used by any .NET languages (VB.NET, C++/CLI etc.)

Google Translate API for .NET 

Description:
Provides a simple, unofficial, .NET Framework API for using Google Ajax Language API service.

    TODO:
    Download API from Google then ,make a reference to your project (Silverlight, C#, .NET, WPF, etc)
    Then make an instance in order to call the API.

    Thanks and Enjoy!!! HAppy Coding!!!
    Download Code: 
    Sample Project
    Facebook Fan Page




    comments

    Sending SMS using SMS Gateway !!

    As requested here's my sample of Sending SMS using SMS gateway (HTTP). No need for SIM, Modems or even load.. All we need is an account from Clickatell  and Buy Credits using Paypal or CC from the Best SMS Gateway (Clickatell).
    This SMS Gateway is using by Big Companies like Easy Forex, T-MAC, Global Forex Trading, Money Bookers, etc,, Even me , Im using this Superb SMS services ,(",) (too bad its too expensive,,lol)
    The Clickatell's HTTP API supports PHP, .NET, JAVA, Python, Ruby, Cold Fusion etc
    so all programmers will benefits to this, not only Windows based programmers but also Non-windows platform based..

    Download Code: 
    Sample Project
    Facebook Fan Page



    comments

    KeyLogger (hacking tool) .NET



    Simple Key Logger that can capture username and password inputted by the user of the hosted machine.
    Demo Features:
    Log all the key activity of the user,
    Capture username, email and password
    Can be minimized to system tray for security
    Password Protected.
    Full Project
    Web browser mod e(capture only username and password if the using is typing on the web browser)
    Can be export to .txt or .xls files
    parse all unwanted char,etc
    USB mode, autoplay (no need to execute the program itself)
    etc..
    Note:
    THis is only for study only, dont use this to hack accounts.

    Download Sample Project

    Facebook Fan Page




    comments