openCanvas 5.5 Toolbar (Inspired from Photoshop toolbar thread) - NEED HELP

Discussion in 'Software' started by basicleader, Oct 16, 2012.

Thread Status:
Not open for further replies.
  1. lblb

    lblb Scribbler - Standard Member Senior Member

    Messages:
    1,198
    Likes Received:
    242
    Trophy Points:
    81
    I see what you mean. Steve and I encountered this before and I'm not sure we were ever able to solve it directly except to first press the button (the gui diappears), lift the pen, then put the it back on the screen while the function is still on. Still, that works quite nicely.
    I'll try again later: it's meeting time!
     
  2. basicleader

    basicleader Pen Pal - Newbie

    Messages:
    34
    Likes Received:
    3
    Trophy Points:
    15
    I'm done with my toolbar, I'll update the zip file on my mediafire so you can get it and have a try, it is just a pleasure drawing using only my pen and nothing else on my diy cintiq =D Thanks again for all your kind help, I'd never had done it without it! Enjoy!!!

    Edit: I have editted my first post with all the necessary informations to try out the toolbar! Please have a go and tell me if you see anything that can be improved! Thanks again for everything!!! =)
     
    Last edited: Jan 10, 2013
  3. lblb

    lblb Scribbler - Standard Member Senior Member

    Messages:
    1,198
    Likes Received:
    242
    Trophy Points:
    81
    Good! Yeah, I think Steve B and thatcomicsguy have found that this can of toolbar can really increase their productivity.

    I know that you’re down but I thought I could suggest a few new options for you to explore. See the code below. Just launch it and see what you think. Here are the changes that I made (obviously, I didn’t include your last changes):

    - I eliminated all the blinking. The blinking occurred for two reasons:
    1) Whenever you have "Gui, Show" the Gui steals the focus when it appears. So instead of using Gui show/hide, I used Winmove to move it in and out of sight. Moving a Gui doesn’t make it steal the focus. So to do that I added (1) setwindelay and setmousedelay at the top of the script; (2) when the toolbar is launched the Gui is shown at coordinates -2000/-2000; (3) look at the mbutton remap: it now uses Winmove instead of winshow/hide.
    2) Whenever you click a button on the Gui, the Gui steals the focus (hence the need for WinActivate in the code for each button). But when a gui has style +E0x08000000, that doesn’t happen (see the line “Gui +LastFound +AlwaysOnTop -caption +ToolWindow +E0x08000000”)​

    - The undo/redo and zoom in/out will repeat as long as you keep the pen on them.

    - If you right-click on flip horizontal, it’s flip vertical (for that I set flip vertical to be Ctrl+g in the OpenCanvas settings). Right-click on zoom in is F7; on zoom out is F8.

    Anyway, just trying to share a few ideas that Steve and I use with our toolbars.


    Code:
    ;-------openCanvas toolbar script------------------
    
    SetBatchLines -1 ; Ensures a fast operating script
    SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
    SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
    Menu Tray, icon, Start_Icon.ico ; Recommended in order to you use your own Tray icon file.
    
    #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
    ;#Warn ; Recommended for catching common errors.
    #Persistent ; Recommended to make it run indefinitely.
    #SingleInstance force  ; Recommended for only one instance of script running.
    
    SetWinDelay, 0
    SetMouseDelay,0
    
    ;-------GUI script 1-------
     
    Gui +LastFound +AlwaysOnTop -caption +ToolWindow +E0x08000000
    Gui, Color, 000000
    Gui, Font, s14, Calibri
    Gui, Margin, 0, 0
    WinSet, TransColor, 000000
    
    
    ;-------Buttons-------
    
    Gui, Add, Picture, x0 y0 w30 h30 Gcut, png/cut.png
    Gui, Add, Picture, x0 y30 w30 h30 Gcopy, png/copy.png
    Gui, Add, Picture, x0 y60 w30 h30 Gpaste, png/paste.png
    Gui, Add, Picture, x0 y90 w30 h30 Gdelete, png/delete.png
    Gui, Add, Picture, x30 y0 w30 h30 Gmovel, png/movel.png
    Gui, Add, Picture, x30 y30 w30 h30 Gselect, png/select.png
    Gui, Add, Picture, x30 y60 w30 h30 Gtrasnsform, png/transform.png
    Gui, Add, Picture, x30 y90 w30 h30 Gdeselect, png/deselect.png
    Gui, Add, Picture, x60 y0 w30 h30 Gundo, png/undo.png
    Gui, Add, Picture, x60 y90 w30 h30 Gprevd, png/prevd.png
    Gui, Add, Picture, x90 y0 w30 h30 Gredo, png/redo.png
    Gui, Add, Picture, x90 y90 w30 h30 Gnextd, png/nextd.png
    Gui, Add, Picture, x120 y0 w30 h30 vflipvertical Gfliph, png/fliph.png
    flipvertical = rb1
    Gui, Add, Picture, x120 y30 w30 h30 vzin Gzin, png/zin.png
    zin = rb2
    Gui, Add, Picture, x120 y60 w30 h30 vzout Gzout, png/zout.png
    zout = rb3
    Gui, Add, Picture, x120 y90 w30 h30 Gsuma, png/suma.png
    
    Gui, Show, X-2000 Y-2000, OpenCanvas_Toolbar
    
    ;-------AR-like Script-----
    
    GroupAdd, TOOLS, ahk_class TDockFloatForm
    GroupAdd, TOOLS, ahk_class TToolForm
    hello = 1
    Settimer, check, 30
    
    Return
    
    GroupAdd, TOOLS, ahk_class TDockFloatForm
    GroupAdd, TOOLS, ahk_class TToolForm
    
    Settimer, check, 30
    
    Return
    
    
    check:
    getKeyState, State, LButton
    if State = D
    {
    	MouseGetPos,,, win, 
    	WinGetClass, cl, ahk_id %win%
    	if (cl = "TMainForm")
    	{
    		Winhide, ahk_group TOOLS
    		KeyWait, Lbutton, U
    	}
    	Else
    	{
    		Winshow, ahk_group TOOLS
    	}
    }
    if State = U
    Winshow, ahk_group TOOLS
    return
    
    
    ;-------AR-like Script-----
    
    
    ;-------Gui script 2-------
    
    mbutton::
    If hello = 1
    {
    CoordMode, Mouse, Screen
    MouseGetPos, xpos, ypos
    WinMove, OpenCanvas_Toolbar ahk_class AutoHotkeyGUI,, % xpos - 89, % ypos - 59
    hello = 0
    return
    }
    If hello = 0
    {
    WinMove, OpenCanvas_Toolbar ahk_class AutoHotkeyGUI,, -2000, -2000
    hello = 1
    }
    return
    
    ;-------End of GUI script-------
    
    
    fliph:
    ifWinExist ahk_class TMainForm
    WinActivate ahk_class TMainForm
    send, ^{r}
    Return
    
    flipv:
    ifWinExist ahk_class TMainForm
    WinActivate ahk_class TMainForm
    send, ^!{r}
    Return
    
    prevd:
    ifWinExist ahk_class TMainForm
    WinActivate ahk_class TMainForm
    send, ^{F6}
    Return
    
    nextd:
    ifWinExist ahk_class TMainForm
    WinActivate ahk_class TMainForm
    send, +^{F6}
    Return
    
    tools:
    ifWinExist ahk_class TMainForm
    WinActivate ahk_class TMainForm
    send, ^{à}
    Return
    
    oC:
    ifWinExist ahk_class TMainForm
    WinActivate ahk_class TMainForm
    Return
    
    suma:
    ifWinExist ahk_class SUMATRA_PDF_FRAME
    WinActivate ahk_class SUMATRA_PDF_FRAME 
    return
    
    tab:
    ifWinExist ahk_class TMainForm
    WinActivate ahk_class TMainForm
    send {Tab}
    return
    
    undo:
    ifWinExist ahk_class TMainForm
    WinActivate ahk_class TMainForm
    loop
    {
    Send ^z
    Sleep 100
    getKeyState, State, LButton
    if State = U
    break
    }
    return
    
    redo:
    ifWinExist ahk_class TMainForm
    WinActivate ahk_class TMainForm
    loop
    {
    Send ^y
    Sleep 100
    getKeyState, State, LButton
    if State = U
    break
    }
    return
    
    zin:
    ifWinExist ahk_class TMainForm
    WinActivate ahk_class TMainForm
    loop
    {
    send, ^!{NumpadAdd}
    Sleep 100
    getKeyState, State, LButton
    if State = U
    break
    }
    return
    
    zout:
    ifWinExist ahk_class TMainForm
    WinActivate ahk_class TMainForm
    loop
    {
    send, ^!{NumpadSub}
    Sleep 100
    getKeyState, State, LButton
    if State = U
    break
    }
    return
    
    trasnsform:
    ifWinExist ahk_class TMainForm
    WinActivate ahk_class TMainForm
    send, ^t
    return
    
    delete:
    ifWinExist ahk_class TMainForm
    WinActivate ahk_class TMainForm
    send, {Del}
    return
    
    select:
    ifWinExist ahk_class TMainForm
    WinActivate ahk_class TMainForm
    send, m
    return
    
    cut:
    ifWinExist ahk_class TMainForm
    WinActivate ahk_class TMainForm
    send, ^x
    return
    
    copy:
    ifWinExist ahk_class TMainForm
    WinActivate ahk_class TMainForm
    send, ^c
    return
    
    paste:
    ifWinExist ahk_class TMainForm
    WinActivate ahk_class TMainForm
    send, ^v
    return
    
    movel:
    ifWinExist ahk_class TMainForm
    WinActivate ahk_class TMainForm
    send, v
    return
    
    deselect:
    ifWinExist ahk_class TMainForm
    WinActivate ahk_class TMainForm
    send, ^d
    return
    
    GuiContextMenu:
    {
    x := %A_GuiControl%
    if (x = "rb1")
    {
    send ^g
    return
    }
    else
    if (x = "rb2")
    {
    send {F7}
    return
    }
    else
    if (x = "rb3")
    {
    send {F8}
    return
    }
    
    }
    Return
    
    ;-------End of the openCanvas toolbar script-------
    
    
    ESC::
    ;ifWinExist ahk_class TMainForm
    ;WinActivate ahk_class TMainForm
    ;send, ^{q}
    ExitApp
    Return
     
  4. basicleader

    basicleader Pen Pal - Newbie

    Messages:
    34
    Likes Received:
    3
    Trophy Points:
    15
    Yosh! lblb, thank you very much for sharing these possibilities, of course, I added some to my script, I didn't include the right button option as I find the gui appearance balanced for now, I didn't want to get rid of it, but I studied the way you make it happen, and I keep this in a part of my mind for probable future enhancement. Here is the last script with the changes I borrowed from you:

    Code:
    ;-------openCanvas toolbar script------------------
    
    
    SetBatchLines -1 ; Ensures a fast operating script
    SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
    SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
    Menu Tray, icon, Start_Icon.ico ; Recommended in order to you use your own Tray icon file.
    
    #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
    ;#Warn ; Recommended for catching common errors.
    #Persistent ; Recommended to make it run indefinitely.
    #SingleInstance force  ; Recommended for only one instance of script running.
    
    SetWinDelay, 0
    SetMouseDelay,0
    
    ;-------GUI script---------
    
     
    Gui +LastFound +AlwaysOnTop -caption +ToolWindow +E0x08000000
    Gui, Color, 000000
    Gui, Font, s14, Calibri
    Gui, Margin, 0, 0
    WinSet, TransColor, 000000
    
    
    ;---------Buttons----------
    
    
    Gui, Add, Picture, x0 y0 w30 h30 Gcut, png/cut.png
    Gui, Add, Picture, x0 y30 w30 h30 Gcopy, png/copy.png
    Gui, Add, Picture, x0 y60 w30 h30 Gpaste, png/paste.png
    Gui, Add, Picture, x0 y90 w30 h30 Gdelete, png/delete.png
    Gui, Add, Picture, x30 y0 w30 h30 Gmovel, png/movel.png
    Gui, Add, Picture, x30 y30 w30 h30 Gselect, png/select.png
    Gui, Add, Picture, x30 y60 w30 h30 Gtrasnsform, png/transform.png
    Gui, Add, Picture, x30 y90 w30 h30 Gdeselect, png/deselect.png
    Gui, Add, Picture, x60 y0 w30 h30 Gundo, png/undo.png
    Gui, Add, Picture, x60 y90 w30 h30 Gprevd, png/prevd.png
    Gui, Add, Picture, x90 y0 w30 h30 Gredo, png/redo.png
    Gui, Add, Picture, x90 y90 w30 h30 Gnextd, png/nextd.png
    Gui, Add, Picture, x120 y0 w30 h30 Gmoveall, png/moveall.png
    Gui, Add, Picture, x120 y30 w30 h30 Gzin, png/zin.png
    Gui, Add, Picture, x120 y60 w30 h30 Gzout, png/zout.png
    Gui, Add, Picture, x120 y90 w30 h30 Gbrush, png/brush.png
    Gui, Add, Picture, x150 y0 w30 h30 Gfliph, png/fliph.png
    Gui, Add, Picture, x150 y30 w30 h30 Gz100, png/z100.png
    Gui, Add, Picture, x150 y60 w30 h30 Gzfit, png/zfit.png
    Gui, Add, Picture, x150 y90 w30 h30 Gexit, png/exit.png
    
    Gui, Show, X-2000 Y-2000, OpenCanvas_Toolbar
    
    ;-------AR-like Script-----
    
    
    GroupAdd, TOOLS, ahk_class TDockFloatForm
    GroupAdd, TOOLS, ahk_class TToolForm
    
    Settimer, check, 30
    
    Return
    
    
    check:
    getKeyState, State, LButton
    if State = D
    {
    	MouseGetPos,,, win, 
    	WinGetClass, cl, ahk_id %win%
    	if (cl = "TMainForm")
    	{
    		Winhide, ahk_group TOOLS
    		KeyWait, Lbutton, U
    	}
    	Else
    	{
    		Winshow, ahk_group TOOLS
    	}
    }
    if State = U
    Winshow, ahk_group TOOLS
    return
    
    
    ;-------AR-like Script-----
    
    ;-------Gui script 2-------
    
    
    Mbutton::
    CoordMode, Mouse, Screen
    MouseGetPos, xpos, ypos
    WinMove, OpenCanvas_Toolbar ahk_class AutoHotkeyGUI,, % xpos - 89, % ypos - 59
    ;SendInput {space up}
    Sleep 200
    Loop
    {
    Keywait, Mbutton, u
    break
    }
    WinMove, OpenCanvas_Toolbar ahk_class AutoHotkeyGUI,, -2000, -2000
    return
       
    
    ;-----End of GUI script-----
    
    ;-----Buttons Functions-----
    
    cut:
    ifWinExist ahk_class TMainForm
    WinActivate ahk_class TMainForm
    send, ^x
    return
    
    copy:
    ifWinExist ahk_class TMainForm
    WinActivate ahk_class TMainForm
    send, ^c
    return
    
    paste:
    ifWinExist ahk_class TMainForm
    WinActivate ahk_class TMainForm
    send, ^v
    return
    
    delete:
    ifWinExist ahk_class TMainForm
    WinActivate ahk_class TMainForm
    send, {Del}
    return
    
    movel:
    ifWinExist ahk_class TMainForm
    WinActivate ahk_class TMainForm
    send, v
    return
    
    select:
    ifWinExist ahk_class TMainForm
    WinActivate ahk_class TMainForm
    send, m
    return
    
    trasnsform:
    ifWinExist ahk_class TMainForm
    WinActivate ahk_class TMainForm
    send, ^t
    return
    
    deselect:
    ifWinExist ahk_class TMainForm
    WinActivate ahk_class TMainForm
    send, ^d
    return
    
    undo:
    ifWinExist ahk_class TMainForm
    WinActivate ahk_class TMainForm
    loop
    {
    Send ^z
    Sleep 100
    getKeyState, State, LButton
    if State = U
    break
    }
    return
    
    prevd:
    ifWinExist ahk_class TMainForm
    WinActivate ahk_class TMainForm
    send, ^{F6}
    Return
    
    redo:
    ifWinExist ahk_class TMainForm
    WinActivate ahk_class TMainForm
    loop
    {
    Send ^y
    Sleep 100
    getKeyState, State, LButton
    if State = U
    break
    }
    return
    
    nextd:
    ifWinExist ahk_class TMainForm
    WinActivate ahk_class TMainForm
    send, +^{F6}
    Return
    
    moveall:
    ifWinExist ahk_class TMainForm  
    WinActivate ahk_class TMainForm
    WinMove, OpenCanvas_Toolbar ahk_class AutoHotkeyGUI,, -2000, -2000
    send {space down}
    sleep 1000
    KeyWait, Lbutton, U
    send {space up}
    sleep 10
    Return
    
    zin:
    ifWinExist ahk_class TMainForm
    WinActivate ahk_class TMainForm
    loop
    {
    send, ^!{NumpadAdd}
    Sleep 100
    getKeyState, State, LButton
    if State = U
    break
    }
    return
    
    zout:
    ifWinExist ahk_class TMainForm
    WinActivate ahk_class TMainForm
    loop
    {
    send, ^!{NumpadSub}
    Sleep 100
    getKeyState, State, LButton
    if State = U
    break
    }
    return
    
    brush:
    ifWinExist ahk_class TMainForm
    WinActivate ahk_class TMainForm
    WinMove, OpenCanvas_Toolbar ahk_class AutoHotkeyGUI,, -2000, -2000
    send {ctrl down}{alt down} 
    sleep 1000
    KeyWait, Lbutton, U
    send {ctrl up}{alt up}
    sleep 10
    Return
    
    fliph:
    ifWinExist ahk_class TMainForm
    WinActivate ahk_class TMainForm
    send, ^{r}
    Return
    
    z100:
    ifWinExist ahk_class TMainForm
    WinActivate ahk_class TMainForm
    send, {F7}
    return
    
    zfit:
    ifWinExist ahk_class TMainForm
    WinActivate ahk_class TMainForm
    send, {F8}
    return
    
    exit:
    ifWinExist ahk_class TMainForm
    WinActivate ahk_class TMainForm
    send, ^{q}
    ExitApp
    Return
    
    ;-------End of the openCanvas toolbar script-------
    
    
    ESC::
    ExitApp
    Return
    Hopefully, I haven't forgotten anything! =)
    It's amazing you've got much experience even in improving the speed and efficiency of the script (to me, it's like the most important part of computer programs and too often overlooked)! I'm glad you have been helpin me all along with this script! Thank you again lblb! (I'll update the mediafire file too of course!)
     
  5. lblb

    lblb Scribbler - Standard Member Senior Member

    Messages:
    1,198
    Likes Received:
    242
    Trophy Points:
    81
    This looks great! Excellent job!
    The repeating zoom in/out is especially smooth in this program: keeping the pen on these buttons makes zooming look very natural even if this is not a native function per say. And it's fun after you've worked a bit to rewind all the way back with the automatic undo and watch it come alive with the automatic redo! It's pretty cool when AHK allows you to add these functions that are not normally available!

    Earlier I suggested using the mbutton toggle because I always have problems with my middle button but your strategy to automatically hide/show the toolbar is very cool and much better (less clicks!) than what I suggested.

    - There is a typo in the "transform" label that makes this button unusable
    - My bad: you can actually delete "SetMouseDelay,0". I was using it to test mousemove commands but finally didn't include them so this line is unnecessary

    Another thing that Steve seemed to prefer was to change the right-click form color picker to the hand tool (I guess in many cases moving the canvas will be more useful than a color picker). Maybe that's something you could look into. Maybe also you can look into the tray menu: for our toolbars, right-clicking on the tray menu icon opens a menu with a few useful functions. If you're ever interested in the latter (left- or right-click on tray icon menus), just tell me and I'll tell you where to look as it is a bit convoluted to get to the code for this in our files.
     
  6. basicleader

    basicleader Pen Pal - Newbie

    Messages:
    34
    Likes Received:
    3
    Trophy Points:
    15
    Hey lblb! I corrected everything, thanks for the checkup! =)

    Another news, last version of oC just came out on their website! Try it out! It actually has a very nice new toolbar but on my small screen, it stills eats too much place for keeping it for use! I told the openCanvas team about our toolbar, I hope they try it out, they might find interesting ideas to improve openCanvas even more!

    As you can see, the toolbar adds some nice features, reset display, reset rotation, and rotation buttons, unfortunately, I think (I checked very quickly) but those buttons don't have hotkeys. Such a shame, because I wanted those features so bad on my own toolbar =D. Hopefully they'll be assignable buttons in the future!! =)
     
  7. lblb

    lblb Scribbler - Standard Member Senior Member

    Messages:
    1,198
    Likes Received:
    242
    Trophy Points:
    81
    Alright, wanna try something? It may not work...

    Download the zip file below and put the ahk file in your toolbar folder and the bmp files in your png subfolder

    Do this in this order:
    - Launch oC
    - Load up an image on which to draw
    - Make sure that the small oC window that has the Navigator shows the Navigator
    - Launch the script you just doanloaded. You should see a small gui with three buttons.
    - Click on the bottom button and drag and drop the icon onto the window in oC that has the navigator
    - Can you now rotate the canvas by leaving your pen on the two rotate buttons?

    Edit: By the way, this will only work in oC 5.5. I haven't looked at the other yet.
     

    Attached Files:

    Last edited: Jan 11, 2013
  8. Steve B

    Steve B Moderator Moderator

    Messages:
    3,420
    Likes Received:
    584
    Trophy Points:
    181
    Hey basic leader,
    Having used other art programs, what's the appeal of Oc? It just offer something that you really like, that other art programs don't offer. ??? Since its not freeware, I'm particularly curious.

    I have to admit, having this toolbar available to use it make sme want to try it more. All things are easier on a tablet pc when youv got a good dedicated AHK toolbar to use!! :)

    Lblb- you rock too!
     
  9. basicleader

    basicleader Pen Pal - Newbie

    Messages:
    34
    Likes Received:
    3
    Trophy Points:
    15
    Hey Steve B! I'm happy you feel like trying out our toolbar !

    As far as oC is concerned, it's more of a "being used to it since old version" feeling that made me choose it over the rest. Second reasons would be that I made myself a diy portable cintiq running an old eeepc Atom-powered on winXP lite, the only softwares that atom could handle well were SAI and oC, so I chose oC because it's still being developped and I got as good results on it as on SAI. For a while I was still using other softwares occasionally, but lastly, oC has added more and more functions, and the one I use a lot now that I'm working on a webcomics is the perspective rulers tool, it runs fast, and help me like hell in preparing precise backgrounds. So when I look at it now, it's the most interesting and complete program for me, when you're really drawing oriented only.

    lblb, I wanna try your last stuffs for sure! I'd surely learn interesting new things out of it! Unfortunately, I'm back to work tomorrow after this nice holidays! So I'll have far less time to experiment on AHK!!! I'll still try out what you prepared tomorrow =)

    oh by the way, I just tried the last toolbar on my winXP, and I got a problem with the winmove function! By having the gui show first out of the screen, it doesn't come up when I click the middle button! :T So I tried showing inside the screen from the start and it works! Then, after I click the middle button for the first time, it starts working correctly from then on. So it's ok for now, but it could be nicer :)

    Thanks!
     
    Last edited: Jan 12, 2013
  10. lblb

    lblb Scribbler - Standard Member Senior Member

    Messages:
    1,198
    Likes Received:
    242
    Trophy Points:
    81
    I don't have WinXP around but it is very possible that things will run a bit differently As could be the case with Win8. Does it work if you first show it on the screen then winmove it out of the way?
     
Thread Status:
Not open for further replies.

Share This Page