[Win only] Small PowerShell script for context-sensitive searching in Microsoft Learn and the PureBasic Forums

Share your advanced PureBasic knowledge/code with the community.
User avatar
Kurzer
Enthusiast
Enthusiast
Posts: 692
Joined: Sun Jun 11, 2006 12:07 am
Location: Near Hamburg

[Win only] Small PowerShell script for context-sensitive searching in Microsoft Learn and the PureBasic Forums

Post by Kurzer »

Hi everyone,

I used to work with the small but old PureBasic IDE tool "Alt-F1.exe", which allowed searching for the word under the cursor via Google and in the PureBasic forums. That tool was handy, but it required an external EXE file.
I’ve now replaced it with a pure PowerShell script which means it works entirely with Windows’ built-in tools, no extra program needed.

Setup in the PureBasic IDE:

- Open Tools / Configure Tools
- Click Add a new tool
- Enter the following values:

Name: e.g. WinAPI Search
Command line: powershell.exe
Arguments: (This is where the PowerShell script below goes)
Event: Menu or Shortcut
Shortcut: e.g. Alt + F1
Hidden start: enable this option so the PowerShell window doesn’t pop up.

PowerShell Script (single line, directly insertable)

Code: Select all

-NoProfile -ExecutionPolicy Bypass -Command "$w='%WORD'; $q=[uri]::EscapeDataString($w); $exe='C:\Program Files\SRWare Iron (64-Bit)\chrome.exe'; $u1='https://learn.microsoft.com/search/?terms='+$q+'&scope=Desktop'; $u2='https://www.purebasic.fr/english/search.php?keywords='+$q; $u3='https://www.purebasic.fr/german/search.php?keywords='+$q; Start-Process -FilePath $exe -ArgumentList ('--new-window ' + '"'+$u1+'" "'+$u2+'" "'+$u3+'"')"
Notes on customization:

In the line

Code: Select all

$exe='C:\Program Files\SRWare Iron (64-Bit)\chrome.exe'
you should enter the path and filename of your preferred browser.
(Of course, this could be chrome.exe, brave.exe, vivaldi.exe, or any other Chromium-based browser.)

The three URLs ($u1, $u2, $u3) define the pages that open simultaneously:

- Microsoft Learn – provides API documentation for Windows functions
- PureBasic English Forum – searches for the current keyword
- PureBasic German Forum – searches for the same keyword

You can easily replace these with other search engines or forums if you like.

The parameter

Code: Select all

--new-window
ensures that the results open in a new browser window with three tabs.
That way, you can simply close the entire results window afterwards, without affecting your existing browser session.

I’ve attached a few screenshots and a short demo video showing it in action.
Maybe it’ll be useful for some of you, especially if you often work with Windows API calls.

Have fun trying it out!
Kurzer


Image


Image


Image
PB 6.12 x64, OS: Win 11 24H2 x64, Desktopscaling: 150%, CPU: I7 12700 H, RAM: 32 GB, GPU: Intel(R) Iris(R) Xe Graphics | NVIDIA GeForce RTX 3070, User age in 2025: 57y
"Happiness is a pet." | "Never run a changing system!"
ZX80
Enthusiast
Enthusiast
Posts: 370
Joined: Mon Dec 12, 2016 1:37 pm

Re: [Win only] Small PowerShell script for context-sensitive searching in Microsoft Learn and the PureBasic Forums

Post by ZX80 »

Kurzer

Excellent ! Thanks a lot for sharing. Very useful.
Post Reply