B2BÍøÂçÈí¼þ

 ÕÒ»ØÃÜÂë
 Á¢¼´×¢²á ÉóºËÍøÕ¾ºÅ:QQ:896757558
ËÑË÷
²é¿´: 8|»Ø¸´: 0
´òÓ¡ ÉÏÒ»Ö÷Ìâ ÏÂÒ»Ö÷Ìâ

¸¡¶¯´°¿ÚµÄ¹ÜÀí²Ù×÷

[¸´ÖÆÁ´½Ó]

788

Ö÷Ìâ

793

Ìû×Ó

6428

»ý·Ö

abc

Rank: 9Rank: 9Rank: 9

»ý·Ö
6428
Ìøתµ½Ö¸¶¨Â¥²ã
Â¥Ö÷
·¢±íÓÚ 5 Ð¡Ê±Ç° | Ö»¿´¸Ã×÷Õß »ØÌû½±Àø |µ¹Ðòä¯ÀÀ |ÔĶÁģʽ
¹Ø±ÕcloseÓëÊÍ·ÅÄÚ´æ

µÚÒ»¸ö£º¶¨ÒåÒ»¸ö¹Ø±Õµ±Ç°´°¿ÚµÄº¯Êý

// ¶¨ÒåÒ»¸ö¹Ø±Õµ±Ç°´°¿ÚµÄº¯Êý
function close() {
    // ±¾Ê¾Àý´´½¨Ò»¸ö´øÓÐÒ»¸ö°´Å¥µÄ´°¿Ú£¬µã»÷°´Å¥¹Ø±Õµ±Ç°´°¿Ú
    // ³õʼ»¯Ò»¸öеĻ£¨´°¿Ú£©
    var ac = new activity();

    // ¼ÓÔز¼¾Ö´úÂ룬ʹÓà LinearLayout Ìæ»» vertical
    ac.loadXML(`
        <LinearLayout>
            <Button id="button1" text="µÚÒ»¸ö°´Å¥"/>
        </LinearLayout>
    `);

    // »ñÈ¡°´Å¥µÄʵÀý
    var btn = ac.findViewById("button1");

    // È·±£°´Å¥¶ÔÏó²»ÎªnullºóÔÙÉèÖõã»÷ʼþ
    if (btn) {
        // ÉèÖð´Å¥µÄµã»÷ʼþ¼àÌýÆ÷
        btn.setOnClickListener(function() {
            // ÔÚÐÂÏß³ÌÖÐÖ´ÐÐ JavaScript ´úÂë
            new thread().runJsCode(function fun() {
                // ʹÓà console.log() ´òÓ¡ÐÅÏ¢
                console.log('Ïß³ÌÖ´ÐдúÂë·ÀÖ¹Õ¼ÓÃUIÏß³Ì');
                // ¹Ø±Õ´°¿Ú
                ac.close();
            }, "-Ïß³ÌÃû");
        });
    } else {
        console.log("°´Å¥Î´ÕÒµ½£¬ÎÞ·¨ÉèÖõã»÷ʼþ¡£");
    }
}

// ʾÀýµ÷ÓÃ
close(); // µ÷Óùرմ°¿ÚµÄº¯Êý£¬ÏÔʾ´ø°´Å¥µÄ´°¿Ú
  1. º¯Êý¶¨Ò壺function close() ¶¨ÒåÁËÒ»¸öÃûΪ close µÄº¯Êý£¬ÓÃÓÚ´´½¨Ò»¸öд°¿Ú²¢ÉèÖð´Å¥µÄµã»÷ʼþ¡£
  2. ´°¿Ú³õʼ»¯£ºvar ac = new activity(); ´´½¨Ò»¸öеĻʵÀý£¬´ú±íÒ»¸öеĴ°¿Ú¡£
  3. ²¼¾Ö¼ÓÔØ£ºÊ¹Óàac.loadXML(...) ·½·¨¼ÓÔØ XML ¸ñʽµÄ²¼¾Ö£¬Ê¹ÓàLinearLayout ÈÝÆ÷°üº¬ÁËÒ»¸ö°´Å¥ Button¡£
  4. °´Å¥»ñÈ¡£ºvar btn = ac.findViewById("button1"); Í¨¹ý°´Å¥µÄ ID »ñÈ¡ÆäʵÀý¡£
  5. µã»÷ʼþÉèÖãº
    • ͨ¹ýÅжϠbtn ÊÇ·ñΪ¿Õ£¬È·±£°´Å¥´æÔÚ¡£
    • ʹÓàbtn.setOnClickListener(...) ÉèÖõã»÷ʼþ£¬µ±°´Å¥±»µã»÷ʱ£¬»áÖ´ÐÐÆäÖеĴúÂë¡£
  6. Ïß³ÌÖ´ÐУºÊ¹Óànew thread().runJsCode(...) Æô¶¯ÐÂÏß³ÌÀ´Ö´ÐдúÂë¡£

  7. ´°¿Ú¹Ø±Õ£ºac.close(); ¹Ø±Õµ±Ç°´°¿Ú¡£

µÚ¶þ¸ö£º¶¨ÒåÒ»¸ö¹Ø±ÕÓ¦Óõĺ¯Êý

// ¶¨ÒåÒ»¸ö¹Ø±ÕÓ¦Óõĺ¯Êý
function closeApp(arg0) {
    // Õâ¸öº¯ÊýµÄ×÷ÓÃÊǹرÕÖ¸¶¨Ãû³ÆµÄÓ¦ÓÃ
    // ²ÎÊý£º
    // String arg0: ÐèÒª¹Ø±ÕµÄÓ¦ÓðüÃû (package name)

    // ¼ì²é´«ÈëµÄ°üÃûÊÇ·ñΪ¿Õ
    if (arg0 != "") {
        // ÕâÀï¿ÉÒÔ¼ÓÈë¹Ø±ÕÓ¦ÓõÄÂß¼­£¬±ÈÈçͨ¹ý API ¹Ø±ÕÓ¦ÓÃ
        console.log("ÕýÔڹرÕÓ¦ÓÃ: " + arg0);
        // ¹Ø±ÕÓ¦ÓõÄÏà¹ØÂß¼­´úÂë
        // ʾÀý£ºµ÷ÓÃϵͳ API À´¹Ø±ÕÓ¦Óã¨ÀýÈç Android ÉϵÄÏà¹ØÂß¼­£©
    } else {
        // Èç¹û°üÃûΪ¿Õ£¬Êä³öÌáʾÐÅÏ¢
        console.log("δÌṩ°üÃû£¬ÎÞ·¨¹Ø±ÕÓ¦Óá£");
    }
}

// ʾÀýµ÷ÓÃ
app.closeApp("com.liubowang.drawingboard"); // µ÷ÓùرÕÓ¦Óõĺ¯Êý£¬¹Ø±Õ°üÃûΪ "com.liubowang.drawingboard" µÄÓ¦ÓÃ

// Èô²»Ìṩ°üÃûµÄÇé¿ö
app.closeApp(""); // Õ⽫Êä³öδÌṩ°üÃûµÄÌáʾ
  1. º¯Êý¶¨Ò壺

    • function closeApp(arg0)£º¶¨ÒåÁËÒ»¸öÃûΪ closeApp µÄº¯Êý£¬½ÓÊÜÒ»¸ö²ÎÊý arg0£¬¸Ã²ÎÊýÊÇÐèÒª¹Ø±ÕµÄÓ¦ÓõİüÃû£¬Í¨³£ÒÔ×Ö·û´®ÐÎʽÌṩ¡£
  2. ²ÎÊý˵Ã÷£º

    • String arg0: ×÷ΪÊäÈ룬Õâ¸ö²ÎÊý´ú±íÒª¹Ø±ÕµÄÓ¦ÓõİüÃû£¬Àý×ÓÈç "com.liubowang.drawingboard"¡£
  3. °üÃû¼ì²é£º

    • if (arg0 != ""): ¸ÃÌõ¼þÅжÏÓï¾äÓÃÀ´¼ì²é´«ÈëµÄ²ÎÊý arg0 ÊÇ·ñΪ¿Õ¡£Èç¹û°üÃû²»Îª¿Õ£¬±íʾÓÐÓÐЧµÄÓ¦ÓÃÐèÒª¹Ø±Õ¡£
  4. Êä³ö¹Ø±ÕÐÅÏ¢£º

    • console.log("ÕýÔڹرÕÓ¦ÓÃ: " + arg0);: ½«¹Ø±ÕÓ¦ÓõÄÐÅÏ¢´òÓ¡µ½¿ØÖÆ̨£¬ÓÐÖúÓÚµ÷ÊÔºÍÈ·ÈϲÙ×÷¡£
  5. ¹Ø±ÕÓ¦ÓõÄÂß¼­£º

    • Õâ¸ö²¿·Ö¿ÉÒÔ°üº¬Êµ¼ÊµÄ´úÂëÂß¼­£¬ÓÃÓڹرÕÓ¦Ó᣾ßÌåʵÏÖ½«ÒÀÀµÓÚ²»Í¬Æ½Ì¨µÄ API¡£ÀýÈ磬ÔÚ Android ÖУ¬¿ÉÒÔʹÓÃijЩϵͳµ÷ÓÃÀ´½áÊø½ø³Ì¡£
    • ʾÀýÖÐÌáµ½µÄ android.os.Process.killProcess(android.os.Process.myPid()); ÊÇÒ»ÖֹرÕÓ¦Óýø³ÌµÄ·½Ê½£¬¾ßÌåÐèÒª¸ù¾Ýʵ¼ÊÒµÎñ³¡¾°À´¾ö¶¨ÊÇ·ñʹÓá£
  6. ´¦Àí¿Õ°üÃû£º

    • Èç¹û arg0 Îª¿Õ£¬º¯Êý½«Ö´ÐРconsole.log("δÌṩ°üÃû£¬ÎÞ·¨¹Ø±ÕÓ¦Óá£");£¬·´À¡¸øÓû§Î´ÌṩÓÐЧµÄ°üÃû£¬´Ó¶ø±ÜÃâÖ´ÐÐÎÞЧ»ò´íÎóµÄ²Ù×÷¡£
  7. ʾÀýµ÷Óãº

    • app.closeApp("com.liubowang.drawingboard"); ÊÇʵ¼Êµ÷Óú¯ÊýµÄ·½Ê½£¬³¢ÊԹرÕÖ¸¶¨µÄÓ¦Óá£
    • app.closeApp(""); ÊÇÒ»¸öʾÀý£¬±íÃ÷Èç¹û²»´«Èë°üÃû£¬½«ÌáʾÓû§Î´Ìṩ°üÃûµÄ´íÎó¡£

µÚÈý¸ö£º¹Ø±ÕfloatUIËùÓд°¿Ú

// ¶¨ÒåÒ»¸ö¼òµ¥µÄ FloatWindow ¹¹Ô캯ÊýÀ´Ä£Ä⸡¶¯´°¿Ú
function FloatWindow(name) {
    this.name = name;
    console.log(this.name + " ´°¿ÚÒÑ´ò¿ª");
}

FloatWindow.prototype.close = function() {
    console.log(this.name + " ´°¿ÚÒѹرÕ");
};

// ¶¨ÒåÒ»¸ö floatUI ¹¹Ô캯ÊýÀ´¹ÜÀí¸¡¶¯´°¿Ú
function floatUI() {
    this.windows = [];
}

floatUI.prototype.addWindow = function(name) {
    var window = new FloatWindow(name);
    this.windows.push(window);
};

floatUI.prototype.closeAll = function() {
    this.windows.forEach(function(window) {
        window.close();
    });
    this.windows = []; // Çå¿Õ´°¿ÚÊý×é
    console.log("ËùÓд°¿ÚÒѹرÕ");
};

// ´´½¨Ò»¸ö floatUI ʵÀý²¢Ìí¼ÓһЩ¸¡¶¯´°¿Ú
var ui = new floatUI();
ui.addWindow("´°¿Ú1");
ui.addWindow("´°¿Ú2");
ui.addWindow("´°¿Ú3");

// ¹Ø±ÕËùÓи¡¶¯´°¿Ú
ui.closeAll();
  1. ¶¨Òå FloatWindow ¹¹Ô캯Êý

    function FloatWindow(name) {
        this.name = name;
        console.log(this.name + " ´°¿ÚÒÑ´ò¿ª");
    }
    
*   µ±ÄãʹÓà `new FloatWindow(name)` ´´½¨Ò»¸öÐÂʵÀýʱ£¬»áÔÚ¿ØÖÆ̨Êä³ö´°¿ÚÒÑ´ò¿ªµÄÐÅÏ¢¡£
  1. ¶¨Òå FloatWindow µÄ close ·½·¨

    FloatWindow.prototype.close = function() {
        console.log(this.name + " ´°¿ÚÒѹرÕ");
    };
    
*   µ±Äãµ÷Óà `window.close()` ·½·¨Ê±£¬»áÔÚ¿ØÖÆ̨Êä³ö´°¿ÚÒѹرյÄÐÅÏ¢¡£
  1. ¶¨Òå floatUI ¹¹Ô캯Êý

    function floatUI() {
        this.windows = [];
    }
    
*   µ±ÄãʹÓà `new floatUI()` ´´½¨Ò»¸öÐÂʵÀýʱ£¬»á³õʼ»¯Ò»¸ö¿ÕÊý×é `windows` ÓÃÓÚ´æ´¢¸¡¶¯´°¿Ú¶ÔÏó¡£
  1. ¶¨Òå floatUI µÄ addWindow ·½·¨

    floatUI.prototype.addWindow = function(name) {
        var window = new FloatWindow(name);
        this.windows.push(window);
    };
    
*   µ±Äãµ÷Óà `ui.addWindow(name)` ·½·¨Ê±£¬»á´´½¨Ò»¸öÐ嵀 `FloatWindow` ¶ÔÏ󣬲¢½«ÆäÌí¼Óµ½ `ui.windows` Êý×éÖС£Í¬Ê±£¬`FloatWindow` µÄ¹¹Ô캯Êý»áÔÚ¿ØÖÆ̨Êä³ö´°¿ÚÒÑ´ò¿ªµÄÐÅÏ¢¡£
  1. ¶¨Òå floatUI µÄ closeAll ·½·¨

    floatUI.prototype.closeAll = function() {
        this.windows.forEach(function(window) {
            window.close();
        });
        this.windows = []; // Çå¿Õ´°¿ÚÊý×é
        console.log("ËùÓд°¿ÚÒѹرÕ");
    };
    
*   µ±Äãµ÷Óà `ui.closeAll()` ·½·¨Ê±£¬»á±éÀú `ui.windows` Êý×éÖеÄÿ¸ö `FloatWindow` ¶ÔÏ󣬲¢µ÷ÓÃÆä `close` ·½·¨À´¹Ø±Õ´°¿Ú¡£Ã¿¸ö´°¿Ú¹Ø±Õʱ£¬`FloatWindow` µÄ `close` ·½·¨»áÔÚ¿ØÖÆ̨Êä³ö´°¿ÚÒѹرյÄÐÅÏ¢¡£×îºó£¬Çå¿Õ `ui.windows` Êý×飬²¢ÔÚ¿ØÖÆ̨Êä³öËùÓд°¿ÚÒѹرյÄÐÅÏ¢¡£

Ö´Ðйý³Ì

  1. ´´½¨ floatUI ÊµÀý

    var ui = new floatUI();
    
*   ¿ØÖÆ̨Êä³ö£ºÎÞ£¨ÒòΪ `floatUI` ¹¹Ô캯ÊýÖÐûÓÐÊä³öÐÅÏ¢£©
  1. Ìí¼Ó¸¡¶¯´°¿Ú

    ui.addWindow("´°¿Ú1");
    ui.addWindow("´°¿Ú2");
    ui.addWindow("´°¿Ú3");
    
*   ¿ØÖÆ̨Êä³ö£º

        ´°¿Ú1 ´°¿ÚÒÑ´ò¿ª
        ´°¿Ú2 ´°¿ÚÒÑ´ò¿ª
        ´°¿Ú3 ´°¿ÚÒÑ´ò¿ª
  1. ¹Ø±ÕËùÓи¡¶¯´°¿Ú

    ui.closeAll();
    
*   ¿ØÖÆ̨Êä³ö£º

        ´°¿Ú1 ´°¿ÚÒѹرÕ
        ´°¿Ú2 ´°¿ÚÒѹرÕ
        ´°¿Ú3 ´°¿ÚÒѹرÕ
        ËùÓд°¿ÚÒѹرÕ

×ܽá

ÔÚÖ´ÐРui.addWindow("´°¿Ú1")¡¢ui.addWindow("´°¿Ú2") ºÍ ui.addWindow("´°¿Ú3") Ê±£¬¿ØÖÆ̨»áÊä³öÿ¸ö´°¿ÚÒÑ´ò¿ªµÄÐÅÏ¢¡£È»ºóÔÚÖ´ÐРui.closeAll() Ê±£¬¿ØÖÆ̨»áÊä³öÿ¸ö´°¿ÚÒѹرյÄÐÅÏ¢£¬×îºóÊä³öËùÓд°¿ÚÒѹرյÄÐÅÏ¢¡£Èç¹ûÄãûÓп´µ½´ò¿ª´°ÌåµÄÊä³ö£¬¿ÉÄÜÊÇ¿ØÖÆ̨ûÓÐÏÔʾÕâЩÐÅÏ¢£¬»òÕßÄãÔÚÖ´ÐдúÂëʱûÓÐ×¢Òâµ½ÕâЩÊä³ö¡£

µÚËĸö£ºHUI½»»¥Ä£¿é¹Ø±Õ

// ¶¨Òå HUI Ä£¿é
var HUI = {
    name: "HUI½»»¥Ä£¿é",
    isOpen: false, // Ä£¿éÊÇ·ñ¿ªÆô

    // ´ò¿ªÄ£¿é
    open: function() {
        this.isOpen = true;
        console.log(this.name + " ÒÑ´ò¿ª");
        // ÕâÀïÓ¦¸ÃÊǵ÷ÓÃÏÔʾ´°¿ÚµÄÂß¼­
        // ±ÈÈç¿ÉÄÜÊÇʹÓÃij¸ö¿ò¼ÜµÄÏÔʾ´°¿Ú·½·¨
    },

    // ¹Ø±ÕÄ£¿é
    close: function() {
        if (this.isOpen) {
            this.isOpen = false;
            console.log(this.name + " ÒѹرÕ");
            // ÕâÀïÓ¦¸ÃÊǵ÷ÓÃÒþ²Ø´°¿ÚµÄÂß¼­
            // ±ÈÈç¿ÉÄÜÊÇʹÓÃij¸ö¿ò¼ÜµÄÒþ²Ø´°¿Ú·½·¨
        } else {
            console.log(this.name + " ÒÑ´¦ÓڹرÕ״̬");
        }
    }
};

// ʾÀý£º´ò¿ª HUI Ä£¿é
HUI.open(); // ´ò¿ª´°¿Ú

// ʾÀý£º¹Ø±Õ HUI Ä£¿é
HUI.close(); // ¹Ø±Õ´°¿Ú

Õâ¶Î´úÂëµÄÖ÷ҪĿµÄÊÇ´´½¨Ò»¸ö¼òµ¥µÄ¹ÜÀíÄ£¿é£¬ÒÔ±ã¿ØÖÆÆä´ò¿ªºÍ¹Ø±Õ״̬¡£open ºÍ close ·½·¨·Ö±ðÓÃÓÚ¹ÜÀíÄ£¿éÏÔʾµÄÂß¼­¡£ËäÈ»´úÂëÖеÄÏÔʾºÍÒþ²ØÂß¼­ÐèÒª¸ù¾Ýʵ¼ÊʹÓõĿò¼Ü»òÉ豸ÓèÒÔʵÏÖ£¬µ«»ù±¾µÄÂß¼­½á¹¹ÒѾ­Íê³É¡£ÕâʹµÃ´úÂëÔÚ×éÖ¯·½Ê½ÉÏÇåÎú£¬²¢ÌṩÁËÒ»¸öλÓÚ½«À´¿ÉÄÜÌí¼Ó½çÃ湦ÄܵĻù´¡¡£

µÚËĸö£º JsWebView Ä£¿éä¯ÀÀÆ÷¹Ø±Õ

// ¶¨Òå JsWebView Àà
function JsWebView(url) {
    this.url = url;
    this.isOpen = false;

    // ´ò¿ª WebView
    this.open = function() {
        this.isOpen = true;
        console.log("WebView ´ò¿ª£¬¼ÓÔØ URL: " + this.url);
        // ÕâÀï¿ÉÒÔÌí¼Óʵ¼Ê´ò¿ª WebView µÄ´úÂë
    };

    // ¹Ø±Õ WebView
    this.close = function() {
        if (this.isOpen) {
            this.isOpen = false;
            console.log("WebView ÒѹرÕ");
            // ÕâÀï¿ÉÒÔÌí¼Óʵ¼Ê¹Ø±Õ WebView µÄ´úÂë
        } else {
            console.log("WebView ÒÑ´¦ÓڹرÕ״̬");
        }
    };
}

// ´´½¨ JsWebView ʵÀý
var myWebView = new JsWebView("https://example.com");

// ´ò¿ª WebView
myWebView.open();

// ¹Ø±Õ WebView
myWebView.close();

¶¨Òå JsWebView Àà

function JsWebView(url)£º¹¹Ô캯Êý½ÓÊÜÒ»¸ö URL£¬ÓÃÓÚ¼ÓÔØÄÚÈÝ¡£
this.url£º´æ´¢´«ÈëµÄ URL¡£
this.isOpen£º¸ú×Ù WebView µÄ´ò¿ª×´Ì¬£¬³õʼֵΪ false¡£

´ò¿ª WebView

this.open = function()£ºÒ»¸ö·½·¨ÓÃÓÚ´ò¿ª WebView¡£
½« isOpen ÉèÖÃΪ true£¬²¢Êä³ö WebView ´ò¿ªºÍ¼ÓÔØµÄ URL ÐÅÏ¢¡£
¿ÉÔÚ´Ë´¦²åÈëʵ¼Ê´ò¿ª WebView µÄ´úÂë¡£

¹Ø±Õ WebView

this.close = function()£ºÒ»¸ö·½·¨ÓÃÓÚ¹Ø±Õ WebView¡£
¼ì²é isOpen ״̬£¬Èç¹û WebView ´ò¿ª£¬ÔòÉèÖÃΪ false ²¢Êä³öÒѹرյÄÐÅÏ¢£»Èç¹ûÒѹرգ¬ÔòÊä³öÒÑ´¦ÓڹرÕ״̬µÄÐÅÏ¢¡£
¿ÉÔÚ´Ë´¦²åÈëʵ¼Ê¹Ø±Õ WebView µÄ´úÂë¡£

´´½¨ÊµÀý²¢µ÷ÓÃ

var myWebView = new JsWebView(¡°https://example.com")£º´´½¨ JsWebView µÄʵÀý£¬²¢´«ÈëÒ»¸ö URL¡£
µ÷Óà open() ·½·¨´ò¿ª WebView£¬²¢µ÷Óà close() ·½·¨¹Ø±Õ WebView¡£

¸ÃʾÀýչʾÁËÈçºÎ´´½¨Ò»¸ö¼òµ¥µÄ JsWebView À࣬Äܹ»´ò¿ªºÍ¹Ø±Õ WebView¡£Äú¿ÉÒÔ½«Æä×÷Ϊ»ù´¡£¬¸ù¾Ý¾ßÌåÐèÇóÀ©Õ¹»òÕß¼¯³Éµ½ÆäËû JAVA/JavaScript ´úÂëÖÐÈ¥¡£ÔÚʵ¼ÊÓ¦ÓÃÖУ¬¡±´ò¿ª¡± ºÍ ¡°¹Ø±Õ¡± µÄÂß¼­»á¸ù¾ÝʹÓõÄƽ̨½øÐÐʵ¼Êʵʩ¡£

µÚÎå¸ö£º ¹Ø±ÕÈÕÖ¾´°¿Ú

// ¼ÙÉè logWindow ¶ÔÏóÒѾ­´æÔÚ£¬²¢°üº¬ÓÐ close ·½·¨
var logWindow = {
    isOpen: false,

    open: function() {
        this.isOpen = true;
        console.log("ÈÕÖ¾´°¿ÚÒÑ´ò¿ª");
    },

    close: function() {
        if (this.isOpen) {
            this.isOpen = false;
            console.log("ÈÕÖ¾´°¿ÚÒѹرÕ");
        } else {
            console.log("ÈÕÖ¾´°¿ÚÒÑ´¦ÓڹرÕ״̬");
        }
    }
};

// ʹÓÃʾÀý
logWindow.open();   // ´ò¿ªÈÕÖ¾´°¿Ú
logWindow.close();  // ¹Ø±ÕÈÕÖ¾´°¿Ú
logWindow.close();  // ³¢ÊÔÔٴιرÕ

µÚÁù¸ö£ºÊÍ·Å YOLO

¸´ÖÆ// OCR ²¿·Ö
let img = screen.screenShotFull();
let ocrres = img.paddleOCR(640, [0, 0, 1, 1]);
printl(ocrres); // ´òÓ¡ OCR ½á¹û

// ²éÕÒº¬ÓÐ "qq" µÄÎÄ×ÖÄ¿±ê
var qqrect = ocrres.findIncludeText("qq");
if (qqrect) {
    qqrect.hidClick(); // µã»÷ÕÒµ½µÄÄ¿±ê
} else {
    printl("ûÓÐÕÒµ½°üº¬ 'qq' µÄÎı¾"); // ÌáʾδÕÒµ½
}

// YOLO ²¿·Ö
// ³õʼ»¯ yolov5
var yolo = new yoloV5();

// ¼ÓÔزå¼þÎļþ¼ÐÀïµÄʶ±ð¿â
var labelPath = project.getResourcesPath() + 'close.txt';
var paramPath = project.getResourcesPath() + 'close.param';
var binPath = project.getResourcesPath() + 'close.bin';

// ¼ÓÔØÄ£ÐÍ
var model = yolo.loadModel(labelPath, paramPath, binPath, 4, false);

if (model != null) {
    printl('Ä£ÐͼÓÔØʧ°Ü');
} else {
    var img = screen.screenShotFull(); // ÔٴνØͼ
    var res = yolo.detectPercent(img, [0, 0, 1, 1], 0.4, 0.45, 640);
    printl(res); // ´òÓ¡¼ì²â½á¹û

    if (res != null && res.length > 0) {
        // ÎÞÕÏ°­µã»÷
        // res[0].click(); // Èç¹ûÓмì²â½á¹û£¬¿ÉÒÔµã»÷µÚÒ»¸ö
    } else {
        printl("ûÓмì²âµ½Ä¿±ê"); // Ìáʾδ¼ì²âµ½
    }
}

// ÊÍ·Å YOLO
yolo.Close();

OCR£¨¹âѧ×Ö·ûʶ±ð£©ºÍ YOLO£¨You Only Look Once£¬¶ÔÏó¼ì²âËã·¨£©À´´¦ÀíͼÏñ£¬²éÕÒÎı¾ºÍÄ¿±ê¡£ÒÔÏÂÊÇ´úÂëµÄÖð²½½âÊÍ£º

1. OCR ²¿·Ö

let img = screen.screenShotFull(); // ½ØÈ¡Õû¸öÆÁÄ»
let ocrres = img.paddleOCR(640, [0, 0, 1, 1]); // ʹÓà PaddleOCR ½øÐÐÎÄ×Öʶ±ð
printl(ocrres); // ´òÓ¡ OCR ½á¹û
  • screen.screenShotFull()£º½ØÈ¡µ±Ç°ÆÁÄ»µÄÍêÕûͼÏñ²¢¸³Öµ¸ø±äÁ¿ img¡£
  • img.paddleOCR(640, [0, 0, 1, 1])£ºÍ¨¹ý PaddleOCR ¶Ô½ØÈ¡µÄͼƬ½øÐÐÎÄ×Öʶ±ð¡£640 ÊÇʶ±ðͼÏñµÄ³ß´ç£¬[0, 0, 1, 1] ÊÇʶ±ðÇøÓòµÄ²ÎÊý¡£
  • printl(ocrres)£º½«Ê¶±ð½á¹û´òÓ¡µ½¿ØÖÆ̨£¬ÒÔ±ã²é¿´Ê¶±ðµÄÎı¾¡£

    // ²éÕÒº¬ÓÐ ¡°qq¡± µÄÎÄ×ÖÄ¿±ê
    var qqrect = ocrres.findIncludeText(¡°qq¡±);
    if (qqrect) {

    qqrect.hidClick(); // µã»÷ÕÒµ½µÄÄ¿±ê
    

    } else {

    printl("ûÓÐÕÒµ½°üº¬ 'qq' µÄÎı¾"); // ÌáʾδÕÒµ½
    

    }

  • ocrres.findIncludeText("qq")£ºÔÚ OCR ½á¹ûÖвéÕÒ°üº¬×Ö·û ¡°qq¡± µÄÎı¾£¬·µ»ØÏàÓ¦µÄÎı¾¿òÇøÓò¡£
  • if (qqrect)£º¼ì²éÕÒµ½µÄÄ¿±ê¿ò qqrect ÊÇ·ñ´æÔÚ¡£
    • Èç¹û´æÔÚ£¬Ôòµ÷ÓàhidClick() ·½·¨Ä£Äâµã»÷¸ÃÎı¾Ä¿±ê¡£
    • Èç¹û²»´æÔÚ£¬ÔòÊä³ö¡±Ã»ÓÐÕÒµ½°üº¬ ¡®qq¡¯ µÄÎı¾¡±µÄÌáʾÐÅÏ¢¡£

2. YOLO ²¿·Ö

// ³õʼ»¯ yolov5
var yolo = new yoloV5(); // ´´½¨ YOLO ʵÀý

// ¼ÓÔزå¼þÎļþ¼ÐÀïµÄʶ±ð¿â
var labelPath = project.getResourcesPath() + 'close.txt';
var paramPath = project.getResourcesPath() + 'close.param';
var binPath = project.getResourcesPath() + 'close.bin';
  • new yoloV5()£º´´½¨Ò»¸öÐ嵀 YOLO ʵÀý£¬ÓÃÓÚ¶ÔÏó¼ì²â¡£
  • ¼ÓÔØʶ±ð¿â£ºÍ¨¹ý getResourcesPath() ·½·¨»ñÈ¡Ä£ÐÍÎļþµÄ·¾¶£¬²¢½«±êÇ©¡¢²ÎÊýºÍ¶þ½øÖÆÎļþ·¾¶·ÖÅä¸ø labelPath¡¢paramPath ºÍ binPath ±äÁ¿¡£

    // ¼ÓÔØÄ£ÐÍ
    var model = yolo.loadModel(labelPath, paramPath, binPath, 4, false);

    if (model != null) {

    printl('Ä£ÐͼÓÔØʧ°Ü'); // Èç¹û model ²»Îª null£¬±íʾ¼ÓÔØʧ°Ü
    

    } else {

    var img = screen.screenShotFull(); // ÔٴνØͼ
    var res = yolo.detectPercent(img, [0, 0, 1, 1], 0.4, 0.45, 640); // ½øÐжÔÏó¼ì²â
    printl(res); // ´òÓ¡¼ì²â½á¹û
    
    if (res != null && res.length > 0) {
        // ÎÞÕÏ°­µã»÷
        // res[0].click(); // Èç¹ûÓмì²â½á¹û£¬¿ÉÒÔµã»÷µÚÒ»¸ö
    } else {
        printl("ûÓмì²âµ½Ä¿±ê"); // Ìáʾδ¼ì²âµ½
    }
    

    }

  • yolo.loadModel(...)£º¼ÓÔØ YOLO Ä£ÐÍ£¬Ê¹ÓÃ֮ǰ׼±¸µÄ±êÇ©¡¢²ÎÊýºÍ¶þ½øÖÆÎļþ¡£
  • if (model != null)£º¼ì²éÄ£ÐͼÓÔØÊÇ·ñ³É¹¦¡£Èç¹û·µ»ØµÄ model ²»Îª null£¬ÔòÊä³ö¡±Ä£ÐͼÓÔØʧ°Ü¡±¡£
  • screen.screenShotFull()£ºÔٴνØÈ¡ÆÁÄ»½øÐжÔÏó¼ì²â¡£
  • yolo.detectPercent(...)£ºÔÚÖ¸¶¨ÇøÓòÄÚ½øÐжÔÏó¼ì²â£¬·µ»Ø¼ì²â½á¹û¡£
  • printl(res)£º´òÓ¡¼ì²â½á¹û¡£
  • if (res != null && res.length > 0)£º¼ì²é¼ì²â½á¹ûÊý×éÊÇ·ñÓÐÄÚÈÝ¡£
    • Èç¹û´æÔÚ¼ì²â½á¹û£¬×¢ÊͲ¿·ÖÌáµ½¿ÉÒÔµã»÷µÚÒ»¸öÄ¿±ê¡£
    • Èç¹ûûÓмì²âµ½Ä¿±ê£¬Êä³ö¡±Ã»Óмì²âµ½Ä¿±ê¡±µÄÌáʾÐÅÏ¢¡£

3. ÊÍ·Å×ÊÔ´

// ÊÍ·Å YOLO
yolo.Close(); // ÊÍ·Å YOLO Ä£Ð͵Ä×ÊÔ´
  • yolo.Close()£ºÊÍ·Å YOLO Ä£ÐÍÕ¼ÓõÄ×ÊÔ´£¬ÒÔÇåÀíÄÚ´æºÍÆäËûʹÓá£

»Ø¸´

ʹÓõÀ¾ß ¾Ù±¨

±¾°æ»ý·Ö¹æÔò

¹Ø±Õ

QQ|»ÓªÏúÈí¼þ×ÛºÏÌÖÂÛ|»ÓªÏúÈí¼þÓÐÎʱشð|»ÓªÏúÈí¼þ½Ì³ÌרÇø|»ÓªÏúÈí¼þPOST½Å±¾·ÖÏí|»ÓªÏúÈí¼þÆÕͨ½Å±¾·ÖÏí|»ÓªÏúÈí¼þÈí¼þ×ÊѶ|»ÓªÏúÈí¼þ¾«Æ·Èí¼þ|»ÓªÏúÈí¼þ¸üй«¸æ|ÓªÏúÈí¼þ|B2BÈí¼þ|B2BÍøÂçÈí¼þ ( ¾©ICP±¸09078825ºÅ )±¾ÍøÕ¾¿ª·¢µÄÓªÏúÈí¼þÊÇÒ»¿îеÄÍøÂçÓªÏúÈí¼þ£¬Õâ¿îÓªÏú¿ÉÒÔÈ¥ÍøÕ¾Èí¼þ£¬²©¿ÍÈí¼þ£¬B2BÈí¼þ£¬·ÖÀàÐÅÏ¢Íø·¢Ìù£¬¿ÉÒÔÇÀɳ·¢£¬¿ÉÒÔµ½°Ù¶ÈÎÄ¿âÉÏ´«WORDÎĵµ£¬¿ÉÒÔµ½Ò»Ð©ÊÇÏà²áÍøÕ¾×Ô¶¯ÉÏ´«Í¼Æ¬£¬Õâ¸ö×Ô¶¯·¢ÌûÈí¼þ×Ô´øÔÆÖ©Ö룬¼Ó¿ìÊÕ¼£¬ÓÐ6ÖÖ¶Ô½Ó´òÂë½Ó¿Ú£¬·½±ã£¬Ð§Âʸߣ¬Ëٶȿ죬¶øÇÒ¶ÔÍ϶¯µÄÑéÖ¤ÂëÈ«ÍøµÚÒ»¼Ò¶À¼ÒÖ§³Ö£¬È«²¿Ô­´´¼¼Êõ£¬¶À¼ÒÑз¢£¬Õý°æÔ­´´´ø°æȨÈí¼þ¡£Ñ¡ÔñÍòÄÜÓªÏúÈí¼þ£¬¾ÍÑ¡ÔñÁËÒ»ÖÖ׬ǮµÄЧÂÊ£¬´ÓûÓб»³¬Ô½¹ý£¬Ò»Ö±ÔÚŬÁ¦Ñз¢Ð¼¼Êõ¡£·Å·ÉÃÎÏ룬½â·ÅË«ÊÖ£¬À´µã´´Ò⣬³É¾ÍÄãµÄÃÎÏ룬¾ÍÔÚÍòÄÜÓªÏúÈí¼þ¿ªÊ¼

map2

GMT+8, 2025-1-22 12:03 , Processed in 0.122871 second(s), 32 queries .

¿ìËٻظ´ ·µ»Ø¶¥²¿ ·µ»ØÁбí