Jump to content
Sign in to follow this  
cBaraN

[Mini] Python Open Link (Chrome)

Recommended Posts

Userinterface/PythonApplicationModule.cpp

// Add
#include <Shellapi.h>
  
// Search
PyObject* appExit(PyObject* poSelf, PyObject* poArgs)
{
    CPythonApplication::Instance().Exit();
    return Py_BuildNone();
}
  
// Add
PyObject * appOpenWebBrowser(PyObject * poSelf, PyObject * poArgs)
{
    char * szURL;

    if (!PyTuple_GetString(poArgs, 0, &szURL))
        return Py_BuildException();

    char * getChormeURL;
    _snprintf(getChormeURL, sizeof(getChormeURL), "%s  --non-incognito", szURL);

    ShellExecuteA(0, 0, "chrome.exe", getChormeURL, 0, SW_SHOWMAXIMIZED);

    return Py_BuildNone();
}
  
// Search
{ "Exit",                        appExit,                        METH_VARARGS },

// Add
{ "OpenURL",                    appOpenWebBrowser,                METH_VARARGS },
  
For Ex:
app.OpenURL('www.norsmt2.com')

 

  • Love 1

Share this post


Link to post

Nice, but what should I do if I don't have chrome?

  • Love 2

Share this post


Link to post
ShellExecute(NULL, "open", getChormeURL, NULL, NULL, SW_SHOWNORMAL);

And it will open in your default browser.

  • Love 2

Share this post


Link to post
4 hours ago, Helia01 said:

Nice, but what should I do if I don't have chrome?

Wait. He is going to show us how to automatically download and install chrome&set it as a default browser.

Share this post


Link to post
2 minutes ago, Caramelito said:

Wait. He is going to show us how to automatically download and install chrome&set it as a default browser.

@Johnny69 how? Is going to execute chrome.exe.

If chrome is your default browser Is going to open chrome.

Just change his line with that and test it, you will see.

Share this post


Link to post
		import os
		os.system("start "" https://www.google.com/")

That would make a deal without  any C++ code

Share this post


Link to post

And you have a developer tag.😑 I love this site

  • Love 2

Share this post


Link to post
vor 5 Minuten schrieb Mali61:

And you have a developer tag.😑 I love this site

 

GetChorme 🤔

  • Love 1

Share this post


Link to post
7 hours ago, Helia01 said:

Nice, but what should I do if I don't have chrome?

You can edit, this is just for example.

3 hours ago, filipw1 said:

		import os
		os.system("start "" https://www.google.com/")

That would make a deal without  any C++ code

Of course, it makes sense to use python, but some users are having problems. (Client crash etc..)

52 minutes ago, Mali61 said:

And you have a developer tag.😑 I love this site

Tag dont matter, you can live happier only if you focus on your own life. Unless you try to make bad comments.

46 minutes ago, Syriza said:

 

GetChorme 🤔

im sorry sometimes i write variables once and always copy and paste xD

 

#NOTE: I can't help and log in because of my personal business. But a little code, I wanted to give this example, you can change the logic and use it in a healthy way.

  • Love 2

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.