{"id":3541,"date":"2019-03-25T17:44:47","date_gmt":"2019-03-25T20:44:47","guid":{"rendered":"http:\/\/xexeu.elipse.com.br\/pt\/kb68628-bringing-a-program-at-runtime-to-the-foreground\/"},"modified":"2019-07-04T17:16:35","modified_gmt":"2019-07-04T20:16:35","slug":"kb68628-bringing-a-program-at-runtime-to-the-foreground","status":"publish","type":"post","link":"https:\/\/kb.elipse.com.br\/en\/kb68628-bringing-a-program-at-runtime-to-the-foreground\/","title":{"rendered":"KB-68628: Bringing a program at runtime to the foreground."},"content":{"rendered":"<div align=\"justify\">\n<p><strong>Question: <\/strong><\/p>\n<p>When a program is at run time, can I give it focus and bring it to the foreground via scripts?<\/p>\n<p><strong>Solution:<\/strong><\/p>\n<\/div>\n<p align=\"justify\">Yes. To do so, use the script below:<\/p>\n<p align=\"left\"><span style=\"color: #0000ff; font-family: Courier New;\">Sub<\/span><span style=\"font-family: Courier New;\"> CommandButton1_Click()<br \/>\n<span style=\"color: #009900;\">&#8216;Using Viewer method: ExecuteExternalApp<br \/>\n<\/span><span style=\"color: #0000ff;\">Set <\/span><span style=\"color: #000000;\">S<\/span>ervice = <span style=\"color: #990099;\">GetObject<\/span>(<span style=\"color: #ff0000;\">&#8220;winmgmts:&#8221;<\/span>)<\/span><\/p>\n<div align=\"left\"><\/div>\n<p align=\"left\"><span style=\"font-family: Courier New;\">strProgramPath = <span style=\"color: #ff0000;\">&#8220;C:\\Windows\\system32\\calc.exe&#8221;<\/span><\/span><\/p>\n<div align=\"left\"><\/div>\n<p align=\"left\"><span style=\"color: #0000ff; font-family: Courier New;\">For Each<\/span><span style=\"font-family: Courier New;\"> Process <span style=\"color: #0000ff;\">in <\/span>Service.InstancesOf(<span style=\"color: #ff0000;\">&#8220;Win32_Process&#8221;<\/span>)<br \/>\n<span style=\"color: #0000ff;\">If <\/span>Process.Name = <span style=\"color: #ff0000;\">&#8220;calc.exe&#8221;<\/span> <span style=\"color: #0000ff;\">Then<\/span><br \/>\nrunning = <span style=\"color: #0000ff;\">True<\/span><br \/>\n<span style=\"color: #0000ff;\">End If<br \/>\nNext<\/span><\/span><\/p>\n<div align=\"left\"><\/div>\n<p align=\"left\"><span style=\"color: #0000ff; font-family: Courier New;\">If <\/span><span style=\"font-family: Courier New;\">running <span style=\"color: #0000ff;\">Then<br \/>\n<\/span>\u00a0<span style=\"color: #990099;\">MsgBox <\/span><span style=\"color: #ff0000;\">&#8220;Calculator is already being executed!&#8221;<br \/>\n<\/span><br \/>\n<span style=\"color: #0000ff;\">Set <\/span>WshShell = <span style=\"color: #990099;\">CreateObject<\/span>(<span style=\"color: #ff0000;\">&#8220;WScript.Shell&#8221;<\/span>)<br \/>\nWshShell.AppActivate <span style=\"color: #ff0000;\">&#8220;calculator&#8221;<\/span><br \/>\nnewkeys = <span style=\"color: #ff0000;\">&#8220;% R&#8221;<\/span>\u00a0\u00a0\u00a0<span style=\"color: #009900;\"> &#8216;Maximiza objeto ativo<br \/>\n<\/span>\u00a0WshShell.SendKeys newkeys<br \/>\n<span style=\"color: #0000ff;\">Else<br \/>\n<\/span>\u00a0Application.ExecuteExternalApp strProgramPath, <span style=\"color: #ff0000;\">&#8220;&#8221;<\/span>, <span style=\"color: #ff0000;\">&#8220;&#8221;<\/span>, 1\u00a0\u00a0\u00a0 <span style=\"color: #009900;\">&#8216;Can be replaced by objShell.Run strProgramPath<br \/>\n<\/span><span style=\"color: #0000ff;\">End If<\/span><\/span><\/p>\n<div align=\"left\"><\/div>\n<p align=\"justify\"><span style=\"color: #0000ff;\"><span style=\"font-family: Courier New;\">End Sub<\/span><\/span><br \/>\n<span style=\"color: #0000ff;\"><br \/>\n<\/span><span style=\"color: #000000;\"><b>NOTE<\/b>: You can also issue this command with\u00a0 <b>Shell<\/b> object (see the application attached to this article).<br \/>\n<\/span><\/p>\n<h3 align=\"justify\">Attachments:<\/h3>\n<p><a href=\"\/wp-content\/uploads\/2019\/03\/OpenProg-2.zip\">OpenProg.zip<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Autor<br \/>\nLuiz Fernando Freire<\/p>\n","protected":false},"author":10,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0},"categories":[763],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v19.8 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>KB-68628: Bringing a program at runtime to the foreground. - Elipse Knowledgebase<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/kb.elipse.com.br\/en\/kb68628-bringing-a-program-at-runtime-to-the-foreground\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"KB-68628: Bringing a program at runtime to the foreground.\" \/>\n<meta property=\"og:description\" content=\"Autor Luiz Fernando Freire\" \/>\n<meta property=\"og:url\" content=\"https:\/\/kb.elipse.com.br\/en\/kb68628-bringing-a-program-at-runtime-to-the-foreground\/\" \/>\n<meta property=\"og:site_name\" content=\"Elipse Knowledgebase\" \/>\n<meta property=\"article:publisher\" content=\"http:\/\/www.facebook.com\/elipsesoftware\" \/>\n<meta property=\"article:published_time\" content=\"2019-03-25T20:44:47+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-07-04T20:16:35+00:00\" \/>\n<meta name=\"author\" content=\"Luiz Fernando Freire\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Luiz Fernando Freire\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/kb.elipse.com.br\/en\/kb68628-bringing-a-program-at-runtime-to-the-foreground\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/kb.elipse.com.br\/en\/kb68628-bringing-a-program-at-runtime-to-the-foreground\/\"},\"author\":{\"name\":\"Luiz Fernando Freire\",\"@id\":\"https:\/\/kb.elipse.com.br\/#\/schema\/person\/08861c3269f025e52ec10dbbad3036a9\"},\"headline\":\"KB-68628: Bringing a program at runtime to the foreground.\",\"datePublished\":\"2019-03-25T20:44:47+00:00\",\"dateModified\":\"2019-07-04T20:16:35+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/kb.elipse.com.br\/en\/kb68628-bringing-a-program-at-runtime-to-the-foreground\/\"},\"wordCount\":272,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/kb.elipse.com.br\/#organization\"},\"articleSection\":[\"Scripts\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/kb.elipse.com.br\/en\/kb68628-bringing-a-program-at-runtime-to-the-foreground\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/kb.elipse.com.br\/en\/kb68628-bringing-a-program-at-runtime-to-the-foreground\/\",\"url\":\"https:\/\/kb.elipse.com.br\/en\/kb68628-bringing-a-program-at-runtime-to-the-foreground\/\",\"name\":\"[:pt]KB-68628: Bringing a program at runtime to the foreground.[:en]KB-68628: Bringing a program at runtime to the foreground.[:] - Elipse Knowledgebase\",\"isPartOf\":{\"@id\":\"https:\/\/kb.elipse.com.br\/#website\"},\"datePublished\":\"2019-03-25T20:44:47+00:00\",\"dateModified\":\"2019-07-04T20:16:35+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/kb.elipse.com.br\/en\/kb68628-bringing-a-program-at-runtime-to-the-foreground\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/kb.elipse.com.br\/en\/kb68628-bringing-a-program-at-runtime-to-the-foreground\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/kb.elipse.com.br\/en\/kb68628-bringing-a-program-at-runtime-to-the-foreground\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"In\u00edcio\",\"item\":\"https:\/\/kb.elipse.com.br\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"KB-68628: Bringing a program at runtime to the foreground.\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/kb.elipse.com.br\/#website\",\"url\":\"https:\/\/kb.elipse.com.br\/\",\"name\":\"Elipse Knowledgebase\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/kb.elipse.com.br\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/kb.elipse.com.br\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/kb.elipse.com.br\/#organization\",\"name\":\"Elipse Software\",\"url\":\"https:\/\/kb.elipse.com.br\/\",\"sameAs\":[\"http:\/\/www.facebook.com\/elipsesoftware\"],\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/kb.elipse.com.br\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/kb.elipse.com.br\/wp-content\/uploads\/2019\/05\/schererelipse-com-br\/logoElipse.png\",\"contentUrl\":\"https:\/\/kb.elipse.com.br\/wp-content\/uploads\/2019\/05\/schererelipse-com-br\/logoElipse.png\",\"width\":161,\"height\":58,\"caption\":\"Elipse Software\"},\"image\":{\"@id\":\"https:\/\/kb.elipse.com.br\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/kb.elipse.com.br\/#\/schema\/person\/08861c3269f025e52ec10dbbad3036a9\",\"name\":\"Luiz Fernando Freire\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/kb.elipse.com.br\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/17dffa843d3208118522366c0b8d1ace?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/17dffa843d3208118522366c0b8d1ace?s=96&d=mm&r=g\",\"caption\":\"Luiz Fernando Freire\"},\"url\":\"https:\/\/kb.elipse.com.br\/en\/author\/fernando\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"KB-68628: Bringing a program at runtime to the foreground. - Elipse Knowledgebase","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/kb.elipse.com.br\/en\/kb68628-bringing-a-program-at-runtime-to-the-foreground\/","og_locale":"en_US","og_type":"article","og_title":"[:pt]KB-68628: Bringing a program at runtime to the foreground.[:en]KB-68628: Bringing a program at runtime to the foreground.[:] - Elipse Knowledgebase","og_description":"[:pt]Autor Luiz Fernando Freire[:en]Autor Luiz Fernando Freire[:]","og_url":"https:\/\/kb.elipse.com.br\/en\/kb68628-bringing-a-program-at-runtime-to-the-foreground\/","og_site_name":"Elipse Knowledgebase","article_publisher":"http:\/\/www.facebook.com\/elipsesoftware","article_published_time":"2019-03-25T20:44:47+00:00","article_modified_time":"2019-07-04T20:16:35+00:00","author":"Luiz Fernando Freire","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Luiz Fernando Freire","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/kb.elipse.com.br\/en\/kb68628-bringing-a-program-at-runtime-to-the-foreground\/#article","isPartOf":{"@id":"https:\/\/kb.elipse.com.br\/en\/kb68628-bringing-a-program-at-runtime-to-the-foreground\/"},"author":{"name":"Luiz Fernando Freire","@id":"https:\/\/kb.elipse.com.br\/#\/schema\/person\/08861c3269f025e52ec10dbbad3036a9"},"headline":"KB-68628: Bringing a program at runtime to the foreground.","datePublished":"2019-03-25T20:44:47+00:00","dateModified":"2019-07-04T20:16:35+00:00","mainEntityOfPage":{"@id":"https:\/\/kb.elipse.com.br\/en\/kb68628-bringing-a-program-at-runtime-to-the-foreground\/"},"wordCount":272,"commentCount":0,"publisher":{"@id":"https:\/\/kb.elipse.com.br\/#organization"},"articleSection":["Scripts"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/kb.elipse.com.br\/en\/kb68628-bringing-a-program-at-runtime-to-the-foreground\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/kb.elipse.com.br\/en\/kb68628-bringing-a-program-at-runtime-to-the-foreground\/","url":"https:\/\/kb.elipse.com.br\/en\/kb68628-bringing-a-program-at-runtime-to-the-foreground\/","name":"[:pt]KB-68628: Bringing a program at runtime to the foreground.[:en]KB-68628: Bringing a program at runtime to the foreground.[:] - Elipse Knowledgebase","isPartOf":{"@id":"https:\/\/kb.elipse.com.br\/#website"},"datePublished":"2019-03-25T20:44:47+00:00","dateModified":"2019-07-04T20:16:35+00:00","breadcrumb":{"@id":"https:\/\/kb.elipse.com.br\/en\/kb68628-bringing-a-program-at-runtime-to-the-foreground\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/kb.elipse.com.br\/en\/kb68628-bringing-a-program-at-runtime-to-the-foreground\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/kb.elipse.com.br\/en\/kb68628-bringing-a-program-at-runtime-to-the-foreground\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"In\u00edcio","item":"https:\/\/kb.elipse.com.br\/en\/"},{"@type":"ListItem","position":2,"name":"KB-68628: Bringing a program at runtime to the foreground."}]},{"@type":"WebSite","@id":"https:\/\/kb.elipse.com.br\/#website","url":"https:\/\/kb.elipse.com.br\/","name":"Elipse Knowledgebase","description":"","publisher":{"@id":"https:\/\/kb.elipse.com.br\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/kb.elipse.com.br\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/kb.elipse.com.br\/#organization","name":"Elipse Software","url":"https:\/\/kb.elipse.com.br\/","sameAs":["http:\/\/www.facebook.com\/elipsesoftware"],"logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/kb.elipse.com.br\/#\/schema\/logo\/image\/","url":"https:\/\/kb.elipse.com.br\/wp-content\/uploads\/2019\/05\/schererelipse-com-br\/logoElipse.png","contentUrl":"https:\/\/kb.elipse.com.br\/wp-content\/uploads\/2019\/05\/schererelipse-com-br\/logoElipse.png","width":161,"height":58,"caption":"Elipse Software"},"image":{"@id":"https:\/\/kb.elipse.com.br\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/kb.elipse.com.br\/#\/schema\/person\/08861c3269f025e52ec10dbbad3036a9","name":"Luiz Fernando Freire","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/kb.elipse.com.br\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/17dffa843d3208118522366c0b8d1ace?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/17dffa843d3208118522366c0b8d1ace?s=96&d=mm&r=g","caption":"Luiz Fernando Freire"},"url":"https:\/\/kb.elipse.com.br\/en\/author\/fernando\/"}]}},"_links":{"self":[{"href":"https:\/\/kb.elipse.com.br\/en\/wp-json\/wp\/v2\/posts\/3541"}],"collection":[{"href":"https:\/\/kb.elipse.com.br\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kb.elipse.com.br\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kb.elipse.com.br\/en\/wp-json\/wp\/v2\/users\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/kb.elipse.com.br\/en\/wp-json\/wp\/v2\/comments?post=3541"}],"version-history":[{"count":4,"href":"https:\/\/kb.elipse.com.br\/en\/wp-json\/wp\/v2\/posts\/3541\/revisions"}],"predecessor-version":[{"id":7449,"href":"https:\/\/kb.elipse.com.br\/en\/wp-json\/wp\/v2\/posts\/3541\/revisions\/7449"}],"wp:attachment":[{"href":"https:\/\/kb.elipse.com.br\/en\/wp-json\/wp\/v2\/media?parent=3541"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kb.elipse.com.br\/en\/wp-json\/wp\/v2\/categories?post=3541"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kb.elipse.com.br\/en\/wp-json\/wp\/v2\/tags?post=3541"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}