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. basicleader

    basicleader Pen Pal - Newbie

    Messages:
    34
    Likes Received:
    3
    Trophy Points:
    15
    I'm back! Just to give you the link to download my toolbar:

    HTML:
    http://www.mediafire.com/download.php?s2ywzof7v4iqfzm
    I got rid of the buttons I don't need as long as the artrage-like script is working! (yeah.. I'm having troubles right now cause the script doesn't run anymore but I gotta reboot after this..!)
     
  2. lblb

    lblb Scribbler - Standard Member Senior Member

    Messages:
    1,198
    Likes Received:
    242
    Trophy Points:
    81
    Cool, I'll have a look and write back.

    For your ArtRage-like script, you need to add #Persistent at the top (because by commenting out the two remaps, nothing makes the script stay on after being launched)
     
  3. basicleader

    basicleader Pen Pal - Newbie

    Messages:
    34
    Likes Received:
    3
    Trophy Points:
    15
    Oh yes! Forgotten about the #Persistent ! Thanks again... xT
    In the end, I ended up playing around the toolbar script which of course runs fine, and added the artrage-like scripting at the right part so that it works perfectly using only this one toolbar script, here is the code if you wanna see where I've put it, and if there might be a better place to put it maybe! At least, for now it works! =)

    Edit: Just noticed I forgot to get rid of the functions of the buttons I had deleted... Now it's done!

    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.
    
    
    ;-------GUI script 1-------
    
     
    Gui +LastFound +AlwaysOnTop -caption +ToolWindow 
    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 Gfliph, png/fliph.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 Gsuma, png/suma.png
    
    
    ;-------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
    xvalue = -89 
    yvalue = -59
    xpos2 := (xpos + xvalue)
    ypos2 := (ypos + yvalue)
    Gui, Show, X%XPos2% Y%YPos2%
    Sleep 200
    Loop
    {
    Keywait, mbutton, u
    break
    }
    Gui, Hide
    return
    
    
    ;-----End of GUI script-----
    
    ;-----Buttons Functions-----
    
    
    fliph:
    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
    
    suma:
    ifWinExist ahk_class SUMATRA_PDF_FRAME
    WinActivate ahk_class SUMATRA_PDF_FRAME 
    return
    
    undo:
    ifWinExist ahk_class TMainForm
    WinActivate ahk_class TMainForm
    send, ^z
    return
    
    redo:
    ifWinExist ahk_class TMainForm
    WinActivate ahk_class TMainForm
    send, ^y
    return
    
    zin:
    ifWinExist ahk_class TMainForm
    WinActivate ahk_class TMainForm
    send, ^!{NumpadAdd}
    return
    
    zout:
    ifWinExist ahk_class TMainForm
    WinActivate ahk_class TMainForm
    send, ^!{NumpadSub}
    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
    
    ;-------End of the openCanvas toolbar script-------
    
    
    ESC::
    ;ifWinExist ahk_class TMainForm
    ;WinActivate ahk_class TMainForm
    ;send, ^{q}
    ExitApp
    Return
     
    Last edited: Jan 10, 2013
  4. lblb

    lblb Scribbler - Standard Member Senior Member

    Messages:
    1,198
    Likes Received:
    242
    Trophy Points:
    81
    Looks good!

    Ok, I understand what your other question is. Yeah, that may be difficult to do because once the gui is shown you have to take the pen off of the screen to then push the buttons. It's doable (and we can try stuff if you're interested), but maybe a simple toggle could be simpler? One middle-click shows the toolbar and it stays shown until you middle-click again (and/or you could add a button on the toobar to hide the toolbar). This could be more practical for you as it can allow you to launch more than one command before the Gui disappears (just a thought). You can try with this:

    1) Add

    Code:
    hello = 1 
    at the top of your script

    2) Then replace your mbutton remap to this:

    Code:
    mbutton::
    If hello = 1
    {
    CoordMode, Mouse, Screen
    MouseGetPos, xpos, ypos
    Gui, Show, % "x" . xpos - 89 . "y" . ypos - 59
    hello = 0
    return
    }
    If hello = 0
    {
    Gui, Hide
    hello = 1
    }
    return
    Also, notice how I've shortened your variable handling to show the Gui under the cursor.

    What do you think?
     
  5. basicleader

    basicleader Pen Pal - Newbie

    Messages:
    34
    Likes Received:
    3
    Trophy Points:
    15
    Liked the idea, and loved it after trying it out^^ I guess I am interested in adding two new buttons, one to use the hand tool (space) and another one to resize my brush (Ctrl+Alt). I took a picture of the new toolbar gui with the added buttons, but I don't have the final pictures yet, just to let you see! I had no problems with the new Zoom buttons, but yeah, now I'm working on making the hand tool and brush resize buttons work! =)

    trial.jpg
     
  6. basicleader

    basicleader Pen Pal - Newbie

    Messages:
    34
    Likes Received:
    3
    Trophy Points:
    15
    It seems like once the gui is onscreen, there's no easy way to make use of the "space" hand tool or the "Ctrl+Alt" hotkey :T No success so far !
    I tried remap, ifs, keywait, *remap/up, but as soon as the gui is on, I can only activate the hotkey and keep it down, then I need to click again in order to use it, but that's just the same as if I had mapped my button to the real hand tool and not the space hand tool! I'll take a break and try again later!
     
  7. lblb

    lblb Scribbler - Standard Member Senior Member

    Messages:
    1,198
    Likes Received:
    242
    Trophy Points:
    81
    I'm not sure what you mean... can you post your g-label code for the two new buttons (i.e. just the commands)? Also, could you add something like "Gui, Hide" before sending the actual command (I'm not sure if that's related to your problem)?
     
  8. basicleader

    basicleader Pen Pal - Newbie

    Messages:
    34
    Likes Received:
    3
    Trophy Points:
    15
    Oh I just came up with the idea of putting a gui hide line so I came back! I haven't kept any of the lines I've tried, they did only 10% of what I wanted so... I guessed it wasn't the right way to follow, sorry about this! =D Well, trying the gui hide and updating soon =)
     
  9. basicleader

    basicleader Pen Pal - Newbie

    Messages:
    34
    Likes Received:
    3
    Trophy Points:
    15
    I tried something like this to see if it could work :

    Code:
    moveall:
    ifWinExist ahk_class TMainForm  
    WinActivate ahk_class TMainForm
    Gui, Hide
    Send {space Down}
    Sleep 200
    Loop
    {
    Keywait, Lbutton, u
    break
    }
    Send {Space Up}
    return 
    But eventhough the gui disappears, the command doesn't activate the opencanvas function I wanna use...

    I'll try to explain more clearly which function I'm trying to implement:
    In my openCanvas Preferences/Tools tab, I unchecked "use Hand Control".
    Now if I push the spacebar and keep it down, instead of the new oC Hand Control, I get the old simple hand tool which is this little hand on the screen. Then, if I use the leftbutton of my mouse and drag it anywhere, it moves the drawing around following my moves.

    I'm actually trying to get this result, by clicking on one of my toolbar button and drag from there to move the drawing around. Gotta go for now, need to pick up my sister at the dock! Later!
     
  10. basicleader

    basicleader Pen Pal - Newbie

    Messages:
    34
    Likes Received:
    3
    Trophy Points:
    15
    Still playing around, but couldn't make it happen yet, to illustrate even more what I want, check out this code:

    Code:
    MButton::
    SendInput {Space down}
    SendInput {lbutton down}
    keywait, Mbutton     ; wait for key release
    SendInput {Space up}  ; 'release' other keys
    SendInput {lbutton up}  ; 'release' other keys
    return
    This script gives the middle click exactly the hand tool function of openCanvas. I'm still trying to have one of my toolbar button to get exactly the same function, something like this (which obviously cannot work but illustrate well what I'm trying to achieve =)):

    Code:
    moveall:
       SendInput {Space down}
       SendInput {lbutton down}
       keywait, mouseleftbutton, up     ; wait for me taking away my stylus and so release the lbutton
       SendInput {Space up}  
       SendInput {lbutton up}
    return
    Thanks for your help ! Let's keep trying!!! YOSH!
     
Thread Status:
Not open for further replies.

Share This Page