Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

AHK BBCodeWriter v7.0.2 - An offline BBCode Editor


  • Please log in to reply
65 replies to this topic
AGermanUser
  • Members
  • 82 posts
  • Last active: Apr 07 2010 06:06 PM
  • Joined: 12 Feb 2005
Welcome to the presentation of my Offline BBCode Editor skript based on Autohotkey script language. :mrgreen:

Posted Image

Description:

It's a small BBCode Editor that lets you write a forum posting offline including all bbcode formatting options. Other features:
[*:3b3kpork]Save and load your postings.
[*:3b3kpork]Resizable GUI.
[*:3b3kpork]Add signatures to your postings. (possible workaround for 255 char limit within some boards.)
[*:3b3kpork]Supports language english/german via Ini file. Create your own language file and simply copy it to the 'lang' subfolder.
[*:3b3kpork]Preview mode to see how your posting will look like.
[*:3b3kpork]Support for ten user-defined BBCodes.
[*:3b3kpork]F-Key (F1, F2, ...) Hotkeys for easier formatting. Including well known Alt hotkeys from phpbb.
[*:3b3kpork]Tag compose mode - add more than one bbcode tag by using Ctrl key

At the moment the script is specialised for the phpbb forum, but it can be adjusted for any other forum.
Due to using RegEx inside the script, your version of Autohotkey has to be 1.0.46+ when you want to use the source files.

If you have created a language file on your own, feel free to share it with the community. I'll add it to a future release if you're interested.

Tag compose mode:
Some words about the new compose mode. Imagine you want to apply more than one tag at once - make use of the Ctrl key.
E.g. you want a word bold and italic formatted. Highlight the word, press Ctrl, press the bold button, release the Ctrl key and press italic button. Voilà. This also works without highlighting a word. In this case the caret is moved inside the tags to start writing.

As long as you hold the ctrl key, the tags are copied to clipboard. The first button press without holding the Ctrl key will paste the collected tags.
Give it a try. :)

Preview:
The user d-man discovered a way to speed up displaying of the preview window. Instead of using a browser as preview application he proposes to use MSHTA.exe within your windows\system32 folder. MSHTA loads much faster than any browser window.

In order to use MSHTA.exe simply open preferences via File Menu and specify C:\Windows\system32\MSHTA.exe as your prefered browser.

Enclosed Hotkeys:[*:3b3kpork]F1 - Bold
[*:3b3kpork]F2 - Italic
[*:3b3kpork]F3 - Underline
[*:3b3kpork]F4 - Quote
[*:3b3kpork]F5 - Code
[*:3b3kpork]F6 - URL
[*:3b3kpork]F7 - Unordered List
[*:3b3kpork]F8 - List Element
[*:3b3kpork]F9 - FontColor
[*:3b3kpork]F10 - Image
[*:3b3kpork]F12 - Smileys
Some further details can be found on the new AHK BBCodeWriter documentary homepage:
:arrow: AHK BBCodeWriter Homepage


Download & Installation:

You can it download it here:
:arrow: BBCodeWriter v7.0.2 Compiled + NSIS Installer
:arrow: BBCodeWriter v7.0.2 Sourcecode

Old version
BBCodeWriter v6.6 Compiled + NSIS Installer
BBCodeWriter v6.6 Sourcecode

Attention: Some users reported that BBCodeWriter contains a virus. This is a false postive from your virus scanner. Let me assure you BBCodeWriter is free of viruses. Your scanner reports a virus because of Autohotkey using upx.exe.

:!: Sourcecode:
Simply extract the zip file to a folder and run "main.ahk". :mrgreen:

:!: NSIS Installer:
I created a new NSIS installer. The small bug of the former installer is fixed. If you don't want a start menu entry, simply uncheck the corresponding box during install.

The new installer also creates an entry within your control panel's software list. In this way you can uninstall AHK BBCodeWriter very easily. It also comes with an uninstall.exe. Uninstalling AHK BBCodeWriter doesn't delete the programs folder including all your signatures and saved postings. If you want to get rid of them too, simply delete the remaining folder in your explorer.


The Scripts:

Take a look at the scripts if you like:[*:3b3kpork]main.ahk
[*:3b3kpork]functions.ahk
[*:3b3kpork]hotkeys.ahk
[*:3b3kpork]BBCodeEditor.ahk
[*:3b3kpork]BBCodePreview.ahkChangelog:

18.05.2007
+ fixed bug in RenameHelper routine - wrong highlighting when 'Hide known extension' is active (thx cuzabis)
16.05.2007
+ fixed bug in BBCodePreview.ahk - BBCode tags within url tags weren't displayed (thx Pastilhas)
24.04.2007
+ fixed minor typo in HandleMessage function - functions.ahk
+ added the hotkeys known from within the phpbb software - hotkeys.ahk
+ updated BtnEditSig subroutine - editing signatures sets window title; easier saving with Ctrl+S - BBCodeEditor.ahk
+ updated BtnUrlDesc subroutine - highlighted text within EdtComment is used as link text (thx roundtrip)
+ updated GuiClose subroutine - Use GuiControlGet instead of ControlGetPos - Use associated variable instead of ClassNN
+ updated ChkSig, ShowTip and RebuildGui1 suboutine - use controls' assosciated variables instead of ClassNN
+ replaced old 'IfWinActive' method within hotkeys with #IfWinActive directive - BBCodeEditor.ahk
+ several cosmetic indentation changes inside main.ahk, BBCodeEditor.ahk, functions.ahk
+ updated Titans Anchor function to v3.4.2
+ added 'Default' option to 'Submit' button within FontGUI
+ added Custom BBCode button bar - can be deactivated under 'Preferences'
+ added ComposeMode capabilities for Custom buttons
+ updated HandleMessage function to support more than one URL inside About GUI
+ added Ctrl-Shift-End hotkey for restoring BBCodeWriter.ini - hotkeys.ahk
+ fixed list bug in BBCodePreview.ahk - wrong parsing in case of more than one 'not-nested' list (thx SLMB)
+ updated AboutGUI - Link to BBCodeWriter thread changes depending on the used language
+ added "Clear history" button to 'Preference GUI' - clears list of recent files in File Menu
22.08.2006
+ added another part to statusbar - shows used tags within ComposeMode
+ removed drag&drop support - too many side effect/bugs - sorry for that
+ updated MsgBox when exiting script - clipboard won't be restored anymore
+ added 'Check for updates' option to HelpMenu
+ fixed BtnSend subroutine - Window lost WinTitle when pushing 'Copy' button (thx roundfile)
20.08.2006
+ changed preview.html in BBCodePreview.ahk - new logo to get smaller header (thx Mart)
+ fixed some minor errors in html code and style.css
+ using #IfWinActive directive inside hotkeys.ahk instead of old method
+ removed "clipboard flush" when starting the script - disadvantages outweighed the benefits
+ added drag&drop support for edit control (thx laszlo)
+ updated "Credits GUI"
+ updated OpenRecentFile subroutine - shows error if file cannot be found/was deleted
+ updated FontSize GUI - easier formatting with buttons instead of DropDownList - similar to ColorGUI
18.07.2006
+ fixed bug in 'SavePosting' subroutine (Ctrl+S) - Gui1 title length not hardcoded anymore (thx jballi)
06.07.2006
+ updated compose mode - control key (Ctrl) is now magic key for compose mode


Please post any errors you find because the script may be buggy. :) (especially the preview routine)

polyethene
  • Members
  • 5519 posts
  • Last active: May 17 2015 06:39 AM
  • Joined: 26 Oct 2012
Good script. I like the preview option.

toralf
  • Moderators
  • 4035 posts
  • Last active: Aug 20 2014 04:23 PM
  • Joined: 31 Jan 2005
Hi AGU,

Very nice job. Well structured and documented.
I found one thing in the main.ahk that might at some point cause trouble:
; Include script for creating HTML Preview
#Include functions.ahk
#Include %A_ScriptDir%\phpbb\BBCodeEditor.ahk 
#Include %A_ScriptDir%\phpbb\BBCodePreview.ahk

; Create Main Window
GoSub, CreateMainGui
Return
You are lucky, because functions.ahk and BBCodePreview.ahk only contain functions but no auto-exec-section with a return.
Because I'm sure that the last gosub is never executed. Test it with
; Create Main Window
MsgBox, Am I right?
GoSub, CreateMainGui
Return
Your auto-exec-section stops inside the BBCodeEditor.ahk, because it contains a return after the CreateMainGui routine.

To prevent future misbehavior you should reorganize the lines to:
;execute autoexec of BBCodeEditor.ahk
GoSub, AutoExecBBCodeEditor
;*** you need to add a RETURN in the file after the autoexec section ***

; Create Main Window
GoSub, CreateMainGui
Return
; end of auto exec

; Include script for creating HTML Preview
#Include functions.ahk
AutoExecBBCodeEditor:
#Include %A_ScriptDir%\phpbb\BBCodeEditor.ahk 
#Include %A_ScriptDir%\phpbb\BBCodePreview.ahk
Or something like that. Maybe even taking the autoexec section part from BBCodeEditor.ahk into the main.ahk script.
Ciao
toralf
 
I use the latest AHK version (1.1.15+)
Please ask questions in forum on ahkscript.org. Why?
For online reference please use these Docs.

AGU
  • Guests
  • Last active:
  • Joined: --

Because I'm sure that the last gosub is never executed.

I see your point. You're right.

Maybe even taking the autoexec section part from BBCodeEditor.ahk into the main.ahk script.

I placed that section there, because I wanted some kind of modular design. In case someone wants to adjust the script for his/her favorite forum/board you just have to create another folder in %A_ScriptDir%, copy "BBCodeEditor.ahk" and "BBCodePreview" in that new folder and change the #Include Directive in the main.ahk script.
This is the reason why I moved the code to "BBCodeEditor.ahk". Cause the button variables, Font colors, FontSizes are phpbb specific.

Therefore I would prefer your first solution and would add another label "AutoExecBBCodeEditor" in BBCodeEditor.ahk. What do you think about it? And what about that design/modular thing?

toralf
  • Moderators
  • 4035 posts
  • Last active: Aug 20 2014 04:23 PM
  • Joined: 31 Jan 2005
I like the design, moduls, nameing conventions, comments, indentation. I could read the code easily.

The only thing I could spot is that the section on BtnAddSmileyXX actions could be easily simplified.
Ciao
toralf
 
I use the latest AHK version (1.1.15+)
Please ask questions in forum on ahkscript.org. Why?
For online reference please use these Docs.

roundfile
  • Members
  • 6 posts
  • Last active: Jul 19 2007 04:49 PM
  • Joined: 03 Nov 2005
Hi AGU,

This is an excellent and very useful script! Thank you for sharing it. :D

I wanted a larger edit window so I made the following changes to make the height of the edit window configurable. There may be a better way to do the same thing but this may be a worthwile enhancement.

To main.ahk is added
;Number of rows (lines) displayed in the edit window
NumEditRows = 25
BBCodeEditor.ahk is modified to be:
Gui, Add, Edit, vEdtComment xs ys+30 r%NumEditRows% w600 Section
  
  OffsetLowerBtns := (NumEditRows+1) * 13 
  
  Gui, Add, Button, gBtnSend xs+238 ys+%OffsetLowerBtns% w60, &Copy

Thanks again, this is a wonderful script!

-roundfile

AGU
  • Guests
  • Last active:
  • Joined: --
@roundfile

I wanted a larger edit window so I made the following changes..

I like your idea. :) I'll add your code to the script. Maybe I'll add another menu entry "preferences" and a gui that lets the user change the number of rows by saving it to an ini file. I'll have a look on this. :D

@toralf

The only thing I could spot is that the section on BtnAddSmileyXX actions could be easily simplified.

Do you mean it that way?

; List of Smileys for Smiley GUI
ListOfSmileys = :D.:).:(.:o.:shock:.:?.8).:lol:.:x.:P.:oops:.:cry:.:evil:.:twisted:.:roll:.:wink:.:!:.:?:.:idea:.:arrow:.:|.:mrgreen:
StringSplit, ArrayOfSmileys, ListOfSmileys, .
BtnAddSmiley1:
  SmileyNumber = 1
  GoSub, AddSmiley
Return
AddSmiley:
  Smiley = ArrayOfSmileys%SmileyNumber%
  Clipboard := %Smiley%
  Gui, 1:-Disabled
  Gui, 4:Destroy
  GuiControl, 1:Focus, EdtComment
  Send, ^v
  Clipboard =
Return
Or dio you see a better/shorter way?

AGU
  • Guests
  • Last active:
  • Joined: --
@toralf
;execute autoexec of BBCodeEditor.ahk
GoSub, AutoExecBBCodeEditor
;*** you need to add a RETURN in the file after the autoexec section ***

; Create Main Window
GoSub, CreateMainGui
Return
; end of auto exec

; Include script for creating HTML Preview
#Include functions.ahk
AutoExecBBCodeEditor:
#Include %A_ScriptDir%\phpbb\BBCodeEditor.ahk
#Include %A_ScriptDir%\phpbb\BBCodePreview.ahk
Don't know why, but I doesn*t work.

;*** you need to add a RETURN in the file after the autoexec section ***
You mean BBCodeEditor.ahk, right? After adding a return after the autoexec section in BBCodeEditor.ahk running the script results in not appearing of the main gui.

Wouldn't deleting of
; Create Main Window
GoSub, CreateMainGui
Return
in main.ahk be a solution?

AGU
  • Guests
  • Last active:
  • Joined: --
:oops: :oops: :oops: forgot to move
; Create Main Window
GoSub, CreateMainGui
Return

above the #Include directives.

Now it works. :D

toralf
  • Moderators
  • 4035 posts
  • Last active: Aug 20 2014 04:23 PM
  • Joined: 31 Jan 2005
ListOfSmileys = :D.:).:(.:o.:shock:.:?.8).:lol:.:x.:P.:oops:.:cry:.:evil:.:twisted:.:roll:.:wink:.:!:.:?:.:idea:.:arrow:.:|.:mrgreen:
StringSplit, ArrayOfSmileys, ListOfSmileys, .
That is a good way, but I would use a Tab (or sometimg else, e.g. `n) to separate the items, since a . can be in a smiley. When you want to use a `n you can use a continueation section so that it is easy to maintain.

How about this: Only one routine for all smiley buttons?
...
  Gui, 4:Add, Button, gBtnAddSmiley vBtnAddSmiley1 xs ys+20 h22 w22 +%BS_ICON%
...

BtnAddSmiley:
  StringTrimLeft, SmileyNumber, A_GuiControl  12
  Smiley = ArrayOfSmileys%SmileyNumber%
  GoSub, 4GuiClose

  ;see remarks below
  GuiControl, 1:Focus, EdtComment
  Clipboard := %Smiley%
  Send, ^v
  Clipboard =
Return
Maybe use ControlSend, and I do not think you need Clipboard, the strings are short. Just set key delay low.
Ciao
toralf
 
I use the latest AHK version (1.1.15+)
Please ask questions in forum on ahkscript.org. Why?
For online reference please use these Docs.

AGU
  • Guests
  • Last active:
  • Joined: --

... you can use a continueation section so that it is easy to maintain.

Can you tell me how to do it with a continuation section? I tried it, but it doesn't work for me.

Method #1 only works with "and", "or", ||, &&, a comma, or a period at the beginning of the line.
Method #2 has difficulties with the parantheses inside the smileys. Tried to escape the smiley parantheses - but doesn't work.

I like your solution with A_GuiControl and one routine for all buttons.

toralf
  • Moderators
  • 4035 posts
  • Last active: Aug 20 2014 04:23 PM
  • Joined: 31 Jan 2005
I meant method #2, I do not know what problem you mean with "difficulties with the parantheses inside the smileys"

this works
ListOfSmileys =
 (LTrim
    :D
    :)
    :(
    :o
    :shock:
    :?
    8)
    :lol:
    :x
    :P
    :oops:
    :cry:
    :evil:
    :twisted:
    :roll:
    :wink:
    :!:
    :?:
    :idea:
    :arrow:
    :|
    :mrgreen:
  )
StringSplit, ArrayOfSmileys, ListOfSmileys, `n
Loop, %ArrayOfSmileys0%
  {
    Item := ArrayOfSmileys%A_Index%
    String = %String%|%item%
  }
MsgBox, %ListOfSmileys%`n============`n%String%

Ciao
toralf
 
I use the latest AHK version (1.1.15+)
Please ask questions in forum on ahkscript.org. Why?
For online reference please use these Docs.

polyethene
  • Members
  • 5519 posts
  • Last active: May 17 2015 06:39 AM
  • Joined: 26 Oct 2012
A richedit control would be nice for wysiwyg editing..

AGU
  • Guests
  • Last active:
  • Joined: --

I do not know what problem you mean with "difficulties with the parantheses inside the smileys"

:oops: forgot LTrim within the parantheses.

Your code works well and it's definitely easier maintainable. :D

Concering one routine for all smiley buttons:
...
Gui, 4:Add, Button, gBtnAddSmiley vBtnAddSmiley1 xs ys+20 h22 w22 +%BS_ICON%
...

BtnAddSmiley:
  StringTrimLeft, SmileyNumber, A_GuiControl, 12
  Smiley := ArrayOfSmileys%SmileyNumber%
  GoSub, 4GuiClose
  GuiControl, 1:Focus, EdtComment
  Control, EditPaste, %Smiley%, Edit1, %ScriptName%
Return
did it for me. I even hadn't to set key delay low. Control, EditPaste is obviously very fast with edit controls. Code is much shorter now, cause I could delete this whole bunch of BtnAddSmileyXX code blocks. Thanks again for this good tip. :D

AGU
  • Guests
  • Last active:
  • Joined: --
@Titan

A richedit control...

Haven't heard of this and can't find anything about it in the docs. Where can I find it?