[Solved] Names of three basic commands in Customize>Keyboard

Creating a macro - Writing a Script - Using the API

[Solved] Names of three basic commands in Customize>Keyboard

Postby JerryO » Sat Dec 29, 2018 5:36 am

I've searched the forums and can't find the answer to this: What are the names for three basic commands in the Customize>Keyboard dialog in Open Office Writer? The commands are:

-Delete (the one-character delete you get when you press the delete key [not the backspace key-- the "del" key])
-Scroll the screen up one line (the action you get when you click the downward arrow in the window's scroll bar)
-Scroll the screen down one line (the action you get when you click the upward arrow in the window's scroll bar)

I'm trying to map those functions to keyboard commands, but can't find their descriptions under any of the categories.

Yes, I know the delete function is already a keyboard command. I want to assign it to one that requires less reach. :-)

I can use the macro recorder for the delete key, but the macro recorder won't record the mouse click for the screen shifts.

Thanks for any help you can offer here!

Jerry
Last edited by Hagar Delest on Sun Apr 07, 2019 11:46 am, edited 1 time in total.
Reason: tagged solved
OpenOffice 4.1.5 on Windows 10
JerryO
 
Posts: 12
Joined: Sat Dec 29, 2018 5:16 am

Re: Names of three basic commands in Customize>Keyboard

Postby JeJe » Sat Dec 29, 2018 10:38 am

If no-one has better solutions. Here are macros to do these. You can assign shortcuts to the macros.

Scrolling macro from this thread.

viewtopic.php?f=20&t=84963

To repeat the cautions I wrote there:
On my system (Windows 8, latest OO) it only does anything once there's been an edit and save. A negative increment before that will cause a crash. Problems when a new window is opened too. But here is the viewdata way. 192 seems to work as a number for a line increment - may be specific to my system/document, I don't know.

*USE AT OWN RISK*

Code: Select all   Expand viewCollapse view

Sub DeleteSelection()
dim oVC
oVC= thiscomponent.currentcontroller.viewcursor
ovc.string =""
End Sub

sub scrolldown()
scrollincrement 192
end sub

sub scrollup()
scrollincrement -192
end sub

sub scrollincrement(increment as long) 'TOO BUGGY NEEDS A SAVE TO WORK. Doesn't work or crash before that
   dim vdata
   dim vdParts,a
   vdata = thisComponent.getCurrentController.getViewdata
   a = 0
   vdParts = Split(vdata(a), ";")
   vdParts(4)= clng(vdParts(4))+increment
   vdParts(6)= clng(vdParts(6))+increment
   vdata(a) = join(vdParts, ";")
   thisComponent.getCurrentController.restoreViewdata(vdata)
end sub
Openoffice 4.1.2
Windows 8
JeJe
Volunteer
 
Posts: 629
Joined: Wed Mar 09, 2016 2:40 pm

Re: Names of three basic commands in Customize>Keyboard

Postby JeJe » Sat Dec 29, 2018 1:41 pm

Yes, I know the delete function is already a keyboard command. I want to assign it to one that requires less reach. :-)


If occurs to me that it might be the Wordstar shortcuts that you're trying to implement - as these include line scrolling. If so I made a partial effort towards that a while ago here:

viewtopic.php?f=47&t=92053&p=436862&hilit=wordstar#p436862
Openoffice 4.1.2
Windows 8
JeJe
Volunteer
 
Posts: 629
Joined: Wed Mar 09, 2016 2:40 pm

Re: Names of three basic commands in Customize>Keyboard

Postby JerryO » Sun Dec 30, 2018 1:08 am

Thanks, JeJe! I am indeed trying to implement some of the old Wordstar keyboard commands. Just the cursor movement ones (Control-A, S, D, F, etc.) and delete-a-word (Control-T) and so forth. I've used those commands for a third of a century now and they're burned into my muscle memory. I had to hack the Windows registry to put the Control key back beside the A, but that worked like a charm. I was able to get all the commands I commonly use to work as either keyboard remaps or as macros within OO, but the shift-page-up and shift-page-down commands still elude me.

I'm not really up to speed yet on the macro editor in OO, but I looked at an old MS Word installation to see what my macros there looked like. Here's what I found. (I use the Shift-PageUp and Shift-PageDown key combinations rather than the Wordstar Control-W and Control-Z.)

Code: Select all   Expand viewCollapse view
Sub ShfPgUp()
'
' ShfPgUp Macro
'
    ActiveWindow.ActivePane.SmallScroll Down:=1
End Sub
-------------------
Sub ShfPgDn()
'
' ShfPgDn Macro
'
    ActiveWindow.ActivePane.SmallScroll Down:=-1
End Sub


Does OO's editor use "SmallScroll Down"? If so, that might solve the bug in your scrolling macros.

I'm impressed with what you did get to work! You even got the "Quick" and "Block" menu deadkeys. Amazing work!

Thanks,
Jerry
OpenOffice 4.1.5 on Windows 10
JerryO
 
Posts: 12
Joined: Sat Dec 29, 2018 5:16 am

Re: Names of three basic commands in Customize>Keyboard

Postby JeJe » Sun Dec 30, 2018 4:01 pm

I've used the freeware KeyTweak for remapping keys which seems to work well:

https://keytweak.en.softonic.com/

I don't use Wordstar shortcuts myself but have been working on an extension for screenwriters and was going to implement the Wordstar shortcuts just for completeness... as a small number of people still want to use them... but its been a low priority. I may go back to it sometime.

OO and Microsoft Word don't use the same commands - there may be a simple and safe command for scrolling a line up or a down in OO - but I was unable to find one.
Openoffice 4.1.2
Windows 8
JeJe
Volunteer
 
Posts: 629
Joined: Wed Mar 09, 2016 2:40 pm

Re: Names of three basic commands in Customize>Keyboard

Postby JerryO » Sun Dec 30, 2018 11:24 pm

JeJe wrote:OO and Microsoft Word don't use the same commands - there may be a simple and safe command for scrolling a line up or a down in OO - but I was unable to find one.

Another thought: is there a Windows keyboard command for the same function? I've searched for one and not found it, but that doesn't mean it doesn't exist. I'm new to Windows and am still learning my way around.

A side note: I ran into the "crash on macro edit" problem last night. The crash ate all my macros but two. They weren't my earliest two, either. I checked the Forum and found a topic from 2015 about this:

https://forum.openoffice.org/en/forum/viewtopic.php?f=20&t=75578

...so it's an old problem that either hasn't been fixed or was fixed and is broken again.
OpenOffice 4.1.5 on Windows 10
JerryO
 
Posts: 12
Joined: Sat Dec 29, 2018 5:16 am

Re: Names of three basic commands in Customize>Keyboard

Postby JeJe » Tue Jan 01, 2019 2:32 pm

No, there's no Windows keyboard command for scrolling up or down in an application.
Openoffice 4.1.2
Windows 8
JeJe
Volunteer
 
Posts: 629
Joined: Wed Mar 09, 2016 2:40 pm

Re: Names of three basic commands in Customize>Keyboard

Postby JeJe » Tue Jan 01, 2019 3:45 pm

This is still use at own risk, but

Scrolling appears to work from the off if the storecomponent macro (which save the document) is run when the document is opened - eg by going to

Tools / Customise / Events

and setting the Opendocument Event - to run the storeComponent macro below

I've also modified the scrollincrement sub to exit if its already at the top and put in an error handler - that might or might not avoid the crashing.

Code: Select all   Expand viewCollapse view
sub storeComponent
thiscomponent.store
end sub

sub scrollincrement(increment as long) 'TOO BUGGY NEEDS A SAVE TO WORK. Doesn't work or crash before that
   dim vdata
   dim vdParts,a
   on error goto hr
   vdata = thisComponent.getCurrentController.getViewdata
   a = 0
   vdParts = Split(vdata(a), ";")
   if vdParts(4) =0 and increment <=0 then exit sub
   vdParts(4)= clng(vdParts(4))+increment
   vdParts(6)= clng(vdParts(6))+increment
   vdata(a) = join(vdParts, ";")
   thisComponent.getCurrentController.restoreViewdata(vdata)
   exit sub
   hr:
end sub

Openoffice 4.1.2
Windows 8
JeJe
Volunteer
 
Posts: 629
Joined: Wed Mar 09, 2016 2:40 pm

Re: Names of three basic commands in Customize>Keyboard

Postby JeJe » Wed Mar 27, 2019 5:57 pm

getAccessibleContext gives access to the scrollbars for a window - these macros work for me in OOWriter:

Code: Select all   Expand viewCollapse view

sub doLineDown()
   doscrollEvent 0
end sub

sub doLineUp()
   doscrollEvent 1
end sub
sub doScreenDown()
   doscrollEvent 2
end sub

sub doScreenUp()
   doscrollEvent 3
end sub

sub doscrollEvent(i)
   comp =thiscomponent.currentcontroller.frame.getcomponentwindow
   compchild=comp.getAccessibleContext.getAccessibleChild(0)
   Vsbar=compchild.getAccessibleContext.getAccessibleChild(6)
   Vsbar.getAccessibleContext.doAccessibleAction(i)
end sub



Openoffice 4.1.2
Windows 8
JeJe
Volunteer
 
Posts: 629
Joined: Wed Mar 09, 2016 2:40 pm

Re: Names of three basic commands in Customize>Keyboard

Postby JerryO » Wed Mar 27, 2019 8:56 pm

It's been a while since I played with the macro editor. Could you give me a quick refresher on how to implement this code and assign keyboard commands to the various events? Ideally Shift-PageUp would scroll the text downward a line (shifting the view upward in the document), and Shift-PageDown would scroll the text upward a line.

Many thanks!
Jerry
OpenOffice 4.1.5 on Windows 10
JerryO
 
Posts: 12
Joined: Sat Dec 29, 2018 5:16 am

Re: Names of three basic commands in Customize>Keyboard

Postby JeJe » Wed Mar 27, 2019 10:22 pm

Copy the code into a module
Go to Tools / Macros /organise macros /openoffice basic
The MyMacros/Standard Library would be a good place.

Then go to Writer's Tools menu/customise/Keyboard tab and choose your shortcut using the "category" list box to find the macro
Openoffice 4.1.2
Windows 8
JeJe
Volunteer
 
Posts: 629
Joined: Wed Mar 09, 2016 2:40 pm

Re: Names of three basic commands in Customize>Keyboard

Postby JerryO » Thu Mar 28, 2019 9:07 am

Thanks! Soon as I get a chance I'll give it a try.
OpenOffice 4.1.5 on Windows 10
JerryO
 
Posts: 12
Joined: Sat Dec 29, 2018 5:16 am

Re: Names of three basic commands in Customize>Keyboard

Postby JerryO » Sat Apr 06, 2019 10:00 am

I finally got a chance to try those macros. Alas, I couldn't get them to work. I successfully copied them into the standard library and linked keyboard commands to them, but only one macro ("dolinedown") worked, and that took me to the end of the file. The others generated an error window that said "BASIC runtime error, An exception occurred, Type: com.sun.star.lang.IndexOutOfBoundsExceptionMessage" and the last line of the bottom macro was highlighted.

Figuring out what's amiss here is beyond my knowledge level. I don't expect you to put in time debugging this, especially since it's working on your system, but if the symptoms I report suggest something obvious, let me know what it is.

Thanks,
Jerry
OpenOffice 4.1.5 on Windows 10
JerryO
 
Posts: 12
Joined: Sat Dec 29, 2018 5:16 am

Re: Names of three basic commands in Customize>Keyboard

Postby JeJe » Sat Apr 06, 2019 12:46 pm

Thanks... I've played around a bit and Im guessing you have rulers showing whereas I didn't when I discovered what worked on mine. If you change the 6 in the third line to an 8 it works with rulers showing.

Its also different with web view instead of print layout. Needs some code to check for these but if you have rulers showing all the time the 6 to 8 change should do it...

Code: Select all   Expand viewCollapse view
   comp =thiscomponent.currentcontroller.frame.getcomponentwindow
   compchild=comp.getAccessibleContext.getAccessibleChild(0)
   Vsbar=compchild.getAccessibleContext.getAccessibleChild(8)
   Vsbar.getAccessibleContext.doAccessibleAction(i)


Openoffice 4.1.2
Windows 8
JeJe
Volunteer
 
Posts: 629
Joined: Wed Mar 09, 2016 2:40 pm

Re: Names of three basic commands in Customize>Keyboard

Postby JeJe » Sat Apr 06, 2019 12:53 pm

The scrollbar is the last item whether rulers are showing or not so this simple fix looks to work for either, and web view as well:

Code: Select all   Expand viewCollapse view
   comp =thiscomponent.currentcontroller.frame.getcomponentwindow
   compchild=comp.getAccessibleContext.getAccessibleChild(0)
   Vsbar=compchild.getAccessibleContext.getAccessibleChild(compchild.getAccessibleContext.getAccessibleChildcount -1)
   Vsbar.getAccessibleContext.doAccessibleAction(i)


Openoffice 4.1.2
Windows 8
JeJe
Volunteer
 
Posts: 629
Joined: Wed Mar 09, 2016 2:40 pm

Re: Names of three basic commands in Customize>Keyboard

Postby JerryO » Sun Apr 07, 2019 12:04 am

Woot! The edited macro set works like a charm, in print view or web view, with ruler visible or not. Many thanks, JeJe!

I love that the new PageUp and PageDown actually move the page no matter where the cursor is. It was driving me crazy to have the PageUp and PageDown commands behave differently depending on how far down the page the cursor was. Now it's predictable, and I can keep reading without having to hunt for the line I was on every time I page up or down. And being able to shift the page up and down a line at a time is one of the functions I use all the time in my other word processors, so it's great to have it functioning here, too.

I can't pretend to understand how these macros work, but thanks for posting them!

Jerry
OpenOffice 4.1.5 on Windows 10
JerryO
 
Posts: 12
Joined: Sat Dec 29, 2018 5:16 am

Re: [Solved] Names of three basic commands in Customize>Keyb

Postby JeJe » Sun Apr 07, 2019 9:09 pm

oops, I just noticed I mixed up the down and up integer values... this should be right...

Code: Select all   Expand viewCollapse view
sub doLineUp()
   doscrollEvent 0
end sub

sub doLineDown()
   doscrollEvent 1
end sub

sub doScreenUp()
   doscrollEvent 2
end sub

sub doScreenDown()
   doscrollEvent 3
end sub


sub doscrollEvent(i)
   comp =thiscomponent.currentcontroller.frame.getcomponentwindow
   compchild=comp.getAccessibleContext.getAccessibleChild(0)
   Vsbar=compchild.getAccessibleContext.getAccessibleChild(compchild.getAccessibleContext.getAccessibleChildcount -1)
   Vsbar.getAccessibleContext.doAccessibleAction(i)
end sub




Edit:corrected doScreenDown function
Last edited by JeJe on Mon Apr 08, 2019 12:57 am, edited 1 time in total.
Openoffice 4.1.2
Windows 8
JeJe
Volunteer
 
Posts: 629
Joined: Wed Mar 09, 2016 2:40 pm

Re: [Solved] Names of three basic commands in Customize>Keyb

Postby JerryO » Sun Apr 07, 2019 10:38 pm

No worries; I just attached the keyboard commands to the functions I wanted, so the old code is working fine. I'll update it, though, so the labeling is accurate.

I notice in the new code that there's no (3); the doscrollEvents are numbered 0, 1, 2, and 4 now. Any reason for that? It's working fine with 3 instead of 4. (At least it seems to be.)

Jerry
OpenOffice 4.1.5 on Windows 10
JerryO
 
Posts: 12
Joined: Sat Dec 29, 2018 5:16 am

Re: [Solved] Names of three basic commands in Customize>Keyb

Postby JeJe » Mon Apr 08, 2019 1:04 am

Thanks for that... I am getting really sloppy!

I spent part of today writing a little scroller extension that uses that code - I may develop it into something further. (you scroll up or down line or screen depending on where you press on a button - further right the faster you go)

And I noticed the code doesn't work in LibreOffice so I may look at that sometime too.

Thanks for all the corrections!

Edit: Scroller extension deleted and given own thread here...

viewtopic.php?f=21&t=97630
Last edited by JeJe on Mon Apr 08, 2019 1:44 pm, edited 1 time in total.
Openoffice 4.1.2
Windows 8
JeJe
Volunteer
 
Posts: 629
Joined: Wed Mar 09, 2016 2:40 pm

Re: [Solved] Names of three basic commands in Customize>Keyb

Postby JerryO » Mon Apr 08, 2019 4:27 am

Thanks for the macros! This is really going to make using Open Office a lot more pleasant.

Jerry
OpenOffice 4.1.5 on Windows 10
JerryO
 
Posts: 12
Joined: Sat Dec 29, 2018 5:16 am

Re: [Solved] Names of three basic commands in Customize>Keyb

Postby JeJe » Mon Apr 08, 2019 1:47 pm

Thanks, Hopefully last post. Here's a version of the doscrollEvent sub that seems to work with LibreOffice as well - may be a little slower on OO though.

Code: Select all   Expand viewCollapse view
sub doscrollEvent(i)
   dim found as boolean
   found = false
   comp =thiscomponent.currentcontroller.frame.getcomponentwindow
   compchild=comp.getAccessibleContext.getAccessibleChild(0)
   on error resume next
   for j = 0 to compchild.getAccessibleContext.getAccessibleChildcount -1
      with compchild.getAccessibleContext.getAccessibleChild(j)
         if .getAccessibleContext.getAccessibleName = "Vertical scroll bar" then found = true
         if found then
            .getAccessibleContext.doAccessibleAction(i)
            exit for
         end if
      end with
   next
end sub


Simple scroller extension I wrote from this moved here:
viewtopic.php?f=21&t=97630
Openoffice 4.1.2
Windows 8
JeJe
Volunteer
 
Posts: 629
Joined: Wed Mar 09, 2016 2:40 pm

Re: [Solved] Names of three basic commands in Customize>Keyb

Postby JerryO » Wed Apr 10, 2019 3:48 am

I haven't tried LibreOffice yet. I'm pretty happy with OO and I'm not as adventurous with software as I used to be, so I may just stick with OO, especially now that I've got the keyboard commands I want.

I wish it was easier to make suggestions for OO, though. There are several maddening features I would love to see changed, but the process of creating a Bugzilla account, searching the archives for prior bug and suggestion reports, then writing it up in the approved format, then voting for it and coaxing others to vote for it...it's too much trouble.
JerryO
 
Posts: 12
Joined: Sat Dec 29, 2018 5:16 am


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 7 guests