See the top rated post in this thread. Click here

Page 1 of 2 12 LastLast
Results 1 to 10 of 19

Thread: AutoHotKey scripts

  1. #1
    AUGI Addict truevis's Avatar
    Join Date
    2004-07
    Location
    Massachusetts, USA
    Posts
    1,191
    Login to Give a bone
    0

    Default AutoHotKey scripts

    I've been finding AutoHotKey (AHK) excellent for automating repetitive Revit tasks. I'm going to share some of the scripts I've been using for my consulting work.

    Writing an AHK script usually starts with using AutoScriptWriter II that comes with the AHK install. I go through the motions of the task I want to automate and it records some of the things I did. I then paste that text into my text editor (I'm liking PSPad.).

    Things like mouse clicks obviously depend on one's screen resolution. There is a function to find a bitmap onscreen (to click on) but I haven't needed that yet.

    When I'm recording I use the keyboard as much as possible. E.g.: Alt-Enter = Element Properties.

    Reading the AHK help file obviously helps.

    These lines go at the top of the AHK file:
    Code:
    #SingleInstance force
    SetBatchLines, 10ms	; Slows the script down to 10ms per line, helps prevent it going to fast for Revit to handle
    Here's a script where I select a solid in the family editor, hit F7, and it sets the solid's material to a new parameter called "Material". I had to do it for many families and each F7 saves me many keystrokes. The "MouseClick" line would have to be modified depending on one's screen size.

    Code:
    F7::  ; hotkey  for adding Material parameter to solid
    WinWait, Revit
    WinWaitActive, Revit
    Sleep, 100
    Send, {ALTDOWN}{ENTER}{ALTUP}
    WinWait, Element Properties, Instance Parameters 
    IfWinNotActive, Element Properties, Instance Parameters , WinActivate, Element Properties, Instance Parameters 
    WinWaitActive, Element Properties, Instance Parameters 
    MouseClick, left,  411,  430
    Sleep, 100
    WinWait, Associate Family Parameter, &Existing family par
    IfWinNotActive, Associate Family Parameter, &Existing family par, WinActivate, Associate Family Parameter, &Existing family par
    WinWaitActive, Associate Family Parameter, &Existing family par
    Send, {ALTDOWN}d{ALTUP}
    WinWait, Parameter Properties, (Cannot appear in sc
    IfWinNotActive, Parameter Properties, (Cannot appear in sc, WinActivate, Parameter Properties, (Cannot appear in sc
    WinWaitActive, Parameter Properties, (Cannot appear in sc
    Send, Material{TAB}m{ENTER}{ENTER}{ENTER}
    return
    Last edited by truevis; 2008-07-30 at 12:40 PM.

  2. #2
    AUGI Addict truevis's Avatar
    Join Date
    2004-07
    Location
    Massachusetts, USA
    Posts
    1,191
    Login to Give a bone
    0

    Default Re: AutoHotKey scripts

    Here's a script that makes F3 do a Purge Unused:
    Code:
    F3::  ; hotkey Purge Unused
    #Persistent
    ToolTip, Purging Unused...
    SetTimer, RemoveToolTip, 1500
    WinWait, Revit
    IfWinNotActive, Revit
    WinWaitActive, Revit
    Sleep, 100
    Send, !fuu{ENTER}{ENTER}
    return 
    RemoveToolTip:
    SetTimer, RemoveToolTip, Off
    ToolTip
    return

  3. #3
    AUGI Addict truevis's Avatar
    Join Date
    2004-07
    Location
    Massachusetts, USA
    Posts
    1,191
    Login to Give a bone
    0

    Default Re: AutoHotKey scripts

    This script maps F5 to do a Save As to a filename that's been copied to the Windows clipboard first. It also sets some options. I've been using it because I have a list of families to make, and often one is based on another. Thus, a quick Save As is the first step.

    Code:
    F5::  ; hotkey
    WinWait, Revit
    IfWinNotActive, Revit
    WinWaitActive, Revit
    ClipWait
    MsgBox, 4, , %clipboard% `nDo you want to continue? (Press YES or NO)
    IfMsgBox No
        return
    Sleep, 100
    Send, !fa
    WinWait, Save As, Previous folder(Alt+
    IfWinNotActive, Save As, Previous folder(Alt+, WinActivate, Save As, Previous folder(Alt+
    WinWaitActive, Save As, Previous folder(Alt+
    Sleep, 100
    Send, ^v!p
    WinWait, File Save Options, &Make this a Central
    IfWinNotActive, File Save Options, &Make this a Central, WinActivate, File Save Options, &Make this a Central
    WinWaitActive, File Save Options, &Make this a Central
    Sleep, 200
    Send, !g
    Sleep, 200
    Send, {ENTER}
    WinWait, Save As, Previous folder(Alt+
    IfWinNotActive, Save As, Previous folder(Alt+, WinActivate, Save As, Previous folder(Alt+
    WinWaitActive, Save As, Previous folder(Alt+
    Sleep, 100
    Send, !s
    return
    Last edited by truevis; 2008-07-30 at 12:44 PM.

  4. #4
    NavisWorks Moderator david.kingham's Avatar
    Join Date
    2004-07
    Location
    Fort Collins, CO
    Posts
    1,329
    Login to Give a bone
    1

    Default Re: AutoHotKey scripts

    Here's one I put together using the ImageSearch function.
    Creates shortcuts for the Filter button (Win + 1) Finish Sketch (Win + 2) and Quit Sketch (Win + 3)
    Images I used are attached too, I had to crop them down pretty small because they have a transparency, so if you got the area around the icon it wouldn't work on some computers because the background color may be different
    Code:
    SetTitleMatchMode 2
    #IfWinActive Revit Architecture 2009
    WinGetPos RevitX, RevitY, RevitWidth, RevitHeight, Revit Architecture 2009
    #1::
    ImageSearch FilterX, FilterY, 0,0,RevitWidth,RevitHeight, Q:\Revit\Files\AHK\Revit\filtercrop.png
    Click %FilterX%, %FilterY%
    #2::
    ImageSearch FinishSketchX, FinishSketchY, 0,0,RevitWidth,RevitHeight, Q:\Revit\Files\AHK\Revit\finishsketchcrop.png
    Click %FinishSketchX%, %FinishSketchY%
    #3::
    ImageSearch QuitSketchX, QuitSketchY, 0,0,RevitWidth,RevitHeight, Q:\Revit\Files\AHK\Revit\quitsketchcrop.png
    Click %QuitSketchX%, %QuitSketchY%
    
    return
    Attached Images Attached Images

  5. #5
    NavisWorks Moderator david.kingham's Avatar
    Join Date
    2004-07
    Location
    Fort Collins, CO
    Posts
    1,329
    Login to Give a bone
    0

    Default Re: AutoHotKey scripts

    And this one to open the View Range by hitting F2

    Code:
    #SingleInstance force
    SetTitleMatchMode 2
    
    #IfWinActive Revit, Detail Level
    {
        F2::
            {
                {
                    Send {Alt}vv{Altup}
                }
        WinWaitActive Element Properties
                {
                    Click 405, 485
                    Click 300, 470
                }
            }
        return
    }

  6. #6
    AUGI Addict truevis's Avatar
    Join Date
    2004-07
    Location
    Massachusetts, USA
    Posts
    1,191
    Login to Give a bone
    0

    Default Re: AutoHotKey scripts

    Quote Originally Posted by david.kingham View Post
    Here's one I put together using the ImageSearch function....
    Excellent example. I'd use
    Code:
    #IfWinActive Revit
    to make it work with all Revit flavors.

    I could not get your images. Maybe try attaching them in a .ZIP.

  7. #7
    I could stop if I wanted to
    Join Date
    2008-01
    Location
    UK
    Posts
    305
    Login to Give a bone
    0

    Default Re: AutoHotKey scripts

    this is great, i will try have a go but im looking forward to more hot key scripts.

    here are those images in a zip to
    Attached Files Attached Files

  8. #8
    AUGI Addict truevis's Avatar
    Join Date
    2004-07
    Location
    Massachusetts, USA
    Posts
    1,191
    Login to Give a bone
    0

    Default Re: AutoHotKey scripts

    Here's part of a script I did today that sets selected column heights. I mapped win-1 to 4 to set heights for each common level range on a big structural project I've been working on. Sure saved me a lot of clicking today! Choosing the levels from a large pull-down list is tedious but win AHK, it goes click {HOME}{DOWN 4}{ENTER}, etc.

    It was also useful when I was populating columns up a grid intersection as I'd Copy/Paste Aligned Same Place, and then hit the appropriate shortcut key to send the new column up.

    Code:
    ;SETS LEVELS OF SELECTED COLUMNS
    #1:: ; level 0+
    WinWait, Revit 
    IfWinNotActive, Revit, WinActivate, Revit 
    WinWaitActive, Revit 
    Send, {ALTDOWN}{ENTER}{ALTUP}
    WinWait, Element Properties, Instance Parameters 
    IfWinNotActive, Element Properties, Instance Parameters , WinActivate, Element Properties, Instance Parameters 
    WinWaitActive, Element Properties, Instance Parameters 
    MouseClick, left,  391,  324
    Sleep, 100
    Send, {HOME}{DOWN  4}{ENTER}
    WinWait, Element Properties, Instance Parameters 
    IfWinNotActive, Element Properties, Instance Parameters , WinActivate, Element Properties, Instance Parameters 
    WinWaitActive, Element Properties, Instance Parameters 
    Send, {TAB}0
    MouseClick, left,  393,  353
    Sleep, 100
    Send, {HOME}{DOWN  10}{ENTER}
    WinWait, Element Properties, Instance Parameters 
    IfWinNotActive, Element Properties, Instance Parameters , WinActivate, Element Properties, Instance Parameters 
    WinWaitActive, Element Properties, Instance Parameters 
    Send, {TAB}4{ENTER  2}
    return
    Last edited by truevis; 2008-08-01 at 04:03 AM.

  9. #9
    AUGI Addict DaveP's Avatar
    Join Date
    2002-12
    Location
    St Paul, MN
    Posts
    1,569
    Login to Give a bone
    0

    Default Re: AutoHotKey scripts

    I'm a simple kind of guy.
    I just rolled this one out to the office.
    All it does is answer that annoying "This Central File has been copied" message.
    We make new Local Copies every morning, so you have to answer that every day.

    Code:
    #Persistent
    SetTimer, MsgBoxCheck, 1000
    MsgBoxCheck:
    If WinExist("Revit", "This Central File has been copied or moved from", "ahk_class #32770")
    {
       WinClose
    }
    That's all it does - just answer that one message
    And, to be honest, I stole it from Dave Baldacchino's "Transparent Local file" script.
    http://forums.augi.com/showthread.ph...ght=make+local

  10. #10
    AUGI Addict truevis's Avatar
    Join Date
    2004-07
    Location
    Massachusetts, USA
    Posts
    1,191
    Login to Give a bone
    0

    Default Re: AutoHotKey scripts

    I'd posted one about how to remove the username from the INI: http://forums.augi.com/showpost.php?...96&postcount=5

    I was watching Olympic judo last night and wanted to magnify the commentary on nbcolympics.com, so I used an AHK script to magnify the screen. It is really something! I'm wondering if it could be used with Revit for anything? http://www.autohotkey.com/forum/topic11700.html

Page 1 of 2 12 LastLast

Similar Threads

  1. AutoHotkey - View Range
    By iankids in forum Revit Architecture - Tips & Tricks
    Replies: 2
    Last Post: 2011-02-05, 02:23 PM
  2. AutoHotKey for Revit 2010
    By truevis in forum Revit - R & D Lounge
    Replies: 3
    Last Post: 2009-06-29, 11:38 AM
  3. AutoHotKey for Revit lab proposed for AU 2009
    By truevis in forum Revit - R & D Lounge
    Replies: 2
    Last Post: 2009-05-08, 02:58 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •