Author Topic: MPLAB X online Code Assistance  (Read 1298 times)

0 Members and 1 Guest are viewing this topic.

Offline dope40Topic starter

  • Newbie
  • Posts: 2
  • Country: bg
MPLAB X online Code Assistance
« on: September 14, 2017, 05:53:24 pm »
Hi,

So i recently needed to use Visual Studio 2013 for a while , and while using it i grew very fond of the auto-code-sugest-complete thingy it has  ( Code Assistance in MPLAB IDE ) .
This is a quick post describing how i " made " the same for MPLAB X IDE v3.45 .







Disclaimer : This i made for me , so its tailored for my needs . It's not perfect , or good for that matter  . It uses Autohotkey to automatically press Ctrl + Space after every alphanumeric key input . But i do find it very useful , so if someone else finds it useful ... great , if not .... you can just close the tab :)  .


OK, so here is the Autohotkey code .

Code: [Select]
Loop, 26
Hotkey, % Chr(96 + A_index), AnyKey
Loop, 10
Hotkey, % A_Index - 1, AnyKey


AnyKey:
#IfWinActive ahk_class SunAwtFrame
Send %A_ThisHotkey%
Sleep, 50
Send ^{space}


SC027::
#IfWinActive ahk_class SunAwtFrame
Send {;}
Send {esc}

 
How does it work :

The first part of the code makes all letters and numbers hotkeys .

Quote
Loop, 26
Hotkey, % Chr(96 + A_index), AnyKey
Loop, 10
Hotkey, % A_Index - 1, AnyKey


Then when one of them is pressed

Quote
AnyKey:

 it checks if its pressed inside the MPLAB text editor window ( so it does not work in other programs or windows ) 

quick note : if it doesn't work for you , use the Active Window Info to view the ahk_class , and replace it in the code .

Quote
#IfWinActive ahk_class SunAwtFrame


And if its in the correct window it just resend what you pressed followed by Ctrl + Space .

Quick note : The delay , between the resending of the key and the Ctrl + Space  , is to prevent the key you pressed to "bind " to Ctrl .
i.e if you type ANSELA fast enough , the last A binds to the  Ctrl key , and you end up highlighting  the whole document .

Quote
Send %A_ThisHotkey%
Sleep, 50
Send ^{space}

The last parts is for times when you assign values since it still suggest , so you need to press escape to close it and then press enter for a new line . Since that can be very annoying , every time you press the semi-colon it automatically presses escape for you , after sending said semi-colon   .



 
Quote
SC027::
#IfWinActive ahk_class SunAwtFrame
Send {;}
Send {esc}



And that's it , you just open the .ahk file when you launch your IDE .

I am sure it can be done better , but taking in consideration it took more time to write this post , than to make it  , i am pleased with the result .

P.S  One last thing to note is that most of the time there is no Code Documentation (  http://microchipdeveloper.com/mplabx:code-documentation ) , so the window its completely useless . unfortunately there is no way to disable it . Or i couldn't find it anyway .








 
« Last Edit: September 15, 2017, 04:54:55 pm by dope40 »
 
The following users thanked this post: thm_w, Fire Doger


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf