Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Up/Down Key not working in Onenote 2016 for Autohotkey

I mapped alt+i/k to Up/down key using Autohotkey, with the following code:

!i:: Send {up}
!k:: Send {down}

These remappings work with every application except Onenote 2016. I checked it online and found some discussions in the following links:

https://autohotkey.com/board/topic/15307-up-and-down-hotkeys-not-working-for-onenote-2007/

https://autohotkey.com/board/topic/41454-remap-key-doesnt-work-in-ms-onenote/

They suggest to use sendplay or sendraw, but these didn't work for me. Can anyone help me with this?

like image 695
Jason Avatar asked May 25 '17 00:05

Jason


5 Answers

It works if you use SendPlay and run AHK script with UI Access

This is your script with Send changed to SendPlay:

!i::SendPlay {up}
!k::SendPlay {down}

It emulates and as you expect. Tested with OneNote 2016 on Windows 10.

How to enable SendPlay: (which initially does nothing in Windows 10)

  1. Save the above mappings into AHK file. I used file updown.ahk with only these two lines.

  2. Right-click the above AHK file and from its context menu, select Run with UI Access (this actually does the trick)

Troubleshooting:

  • The item Run with UI Access is missing from context menu of AHK file

    1. Make sure your AutoHotKey is installed using the installer into Program Files directory. AutoHotKey documentation says UIA is only effective if the file is in a trusted location i.e. a Program Files sub-directory.

    2. In installer options, be sure to check the last item as shown below.  
      enter image description here

    Tip: if your AutoHotKey is already installed, it is sufficient just to re-run the installer (Installer.ahk found in location of AutoHotKey executables) and check the option. (No need to uninstall and install anew.)

  • SendPlay still does not work?

    1. See the FAQ topic How do I work around problems caused by User Account Control (UAC) available either online or inside local AHK help file. (They are the same.)

    2. Similar topic also describing limitations is Run with UI Access (available online or in local help).

like image 122
miroxlav Avatar answered Nov 14 '22 22:11

miroxlav


Simplest way.

!i::ControlSend, OneNote::DocumentCanvas1, {Up}, ahk_exe ONENOTE.EXE

Found on the ahk forums here (original) and here (citing original I think) . Verified working on Windows 10 1803 with OneNote 2016 (desktop version).

like image 22
wgrant Avatar answered Oct 02 '22 14:10

wgrant


It seems that Autohotkey has issues with OneNote. Doing some trial and error I found that doing:

Send {CTRL DOWN}{UP}{CTRL UP}

simulates the up key but not completely.

like image 3
R. Schifini Avatar answered Nov 14 '22 22:11

R. Schifini


It seems that many have had problems with OneNote.

https://autohotkey.com/boards/viewtopic.php?f=5&t=25925

https://autohotkey.com/board/topic/49216-interference-between-microsoft-onenote-and-autohotkey/

However, some have suggested that having AHK open before running the Onenote resolves this problem. Surface Pro users don't seem to have any problems regarding AHK interacting with Onenote. May I ask what computer you use?

Hope it helps!

like image 2
S.L Avatar answered Nov 14 '22 23:11

S.L


My solution:

if (winactive("ahk_exe onenote.exe"))
{
    vk_code = 0xA0
    dllcall("keybd_event","UChar", vk_code, "UChar", 0, "UInt", 0, "Ptr", 0 )
    vk_code = 0x26
    dllcall("keybd_event","UChar", vk_code, "UChar", 0, "UInt", 0, "Ptr", 0 )
    vk_code = 0x26
    dllcall("keybd_event","UChar", vk_code, "UChar", 0, "UInt", 0x0002, "Ptr", 0 )
    vk_code = 0xA0
    dllcall("keybd_event","UChar", vk_code, "UChar", 0, "UInt", 0x0002, "Ptr", 0 )
}
else
    send  {blind}{up}
like image 2
guest Avatar answered Nov 14 '22 22:11

guest