REM Macro for the Lua version of Notesorg, (C) 2007 Silas S. Brown. REM Translate this using OPL, and set Macro5 to use the OPO (macro type: Macro) REM Run the macro to organise the contents of C:\Documents\Word REM (works if all the text is the same font etc) REM Licensed under the Apache License, Version 2.0 (the "License"); REM you may not use this file except in compliance with the License. REM You may obtain a copy of the License at REM REM http://www.apache.org/licenses/LICENSE-2.0 REM REM Unless required by applicable law or agreed to in writing, software REM distributed under the License is distributed on an "AS IS" BASIS, REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. REM See the License for the specific language governing permissions and REM limitations under the License. Include "System.oxh" Include "Lua5.oxh" PROC Macro: LOCAL state&,r% FgDoc%:("C:\Documents\Word") SendKey:("Ct+Fn+Up") SendString:("~SOF€÷") SendKey:("Ct+Fn+Down") SendString:("~EOF€×÷") SendKey:("Ct+e") :REM exit pause 15 REM The Lua version of notesorg is written without 'print' REM statements, otherwise it will create a STDOUT window REM every time the macro is run, and these can build up unless you close them from REM the "Open files/programs" dialogue. Closing any one will close all the others and REM also Macro5 which then needs to be restarted. On at least some versions REM of Macro5, you can add to the end of this macro the lines REM FgApp%:("C:\System\Apps\Macro5\Macro5.app") REM SendKey:("Ct+e") REM hence causing it to exit Macro5 after every run, which will prevent the leaks REM but you'll still need to restart Macro5 manually. REM However, it's probably simpler not creating the STDOUT windows REM in the first place. But the user needs to be given some indication REM that things are in progress, especially if the System screen REM is being shown. GetFocus: BUSY "Organising (do not touch keyboard)" state&=LuaOpen&: r%=Lua&:(state&,"dofile('C:\\System\\notesorg.lua')") LuaClose:(state&) BUSY OFF : ReleaseFocus: IF r% : RETURN : ENDIF : REM Lua error FgDoc%:("C:\Documents\Word") pause 5 SendKey:("Ct+a"):SendKey:("Del") SendKey:("Menu"):SendKey:("Up"):SendKey:("Up"):SendKey:("Right"):SendKey:("Up"):SendKey:("Up"):SendKey:("Enter") pause 10 SendKey:("Down"):SendKey:("Ct+Fn+Left"):SendKey:("Up"):SendKey:("Tab") pause 5 SendString:("sorted.out.txt") SendKey:("Enter"):SendKey:("Enter") pause 5 SendKey:("Ct+Fn+Up") DELETE "C:\sorted.out.txt" ENDP