Example showing how to read from the Windows Registry

Share your macros, knowledge, solutions, services, ...
Post Reply
Petr
Posts: 106
Joined: Tue Oct 18, 2016 1:12 pm

Example showing how to read from the Windows Registry

Post by Petr » Fri Nov 25, 2016 1:19 pm

This example reads from "HKEY_CURRENT_USER\Software" Windows registry key and lists its content in Notepad window.

Code: Select all

<#> Start of the macro
<#> Only commands takes effect in the macro, new lines and other text is ignored
<cmds>

<#> Read registry keys in to array vKey[] 
<reg_enumsubkeys>("HKEY_CURRENT_USER\Software","vKey","vNumOfKeys")

<#> If no key 
<if_num>("vNumOfKeys==0")

   <#> Show message
   <msg>(-100,-100,"No keys found under HKEY_CURRENT_USER\Software.","Message",1)

   <#> Exit macro
   <exitmacro>

<endif>

<#> Start Notepad and make it active window
<execappex>("notepad.exe","","",0,0)

<#> Wait while Notepad not opened
<waitfor>("WIN","OPEN","[*- Notepad|Notepad|#164|#18]",15,0)

<#> Activate Notepad window
<actwin>("[*- Notepad|Notepad|#164|#18]",0,0,"no")

<#> If Notepad window is active - on top 
<if_win>("[*- Notepad|Notepad|#164|#18]","ACT",0)

   <#> For each line in array vKey[]  
   <begloop>(vNumOfKeys)

      <#> Write current line of array vKey[] in to Notepad
      <varout>("vKey[_vLoopCounter0]",0)

      <#> Create new line (like Enter)
      <newline>

   <endloop>

<endif>

<#> End of the macro

Post Reply