Jump to content

Define series of commands to use as shorthand


Go to solution Solved by Nine,

Recommended Posts

Hello, I'm super new to AutoIT and I'm working on a making a series of commands to clean up one of my large excel files this includes the reuse of the same commands:

                        Send("+{SPACE}") ;select row
                        Sleep(100)
                        Send("{F10}") ;opens hotkey menu
                        Sleep(100)
                        Send("h") ;opens home menu
                        Sleep(100)
                        Send("d") ;opens delete menu
                        Sleep(100)
                        Send("r") ;deletes row

and I was wondering if there was a way to define that group of commands (i,e. "DEL COMMAND" = [then type out those commands once]) so instead of copying/pasting the command multiple times I could just type the defining term of DEL COMMAND or whatever defining term. 

A while/do/for loop won't work because there's inconsistent down/over keys that need to happen between sets of the DEL COMMAND. 

 

Link to comment
Share on other sites

  • Solution
Posted (edited)

When you post code, use the method shown in the link.

Put all statements into a func and link the function with a HotKeySet , something like this :

HotKeySet("{F8}", DelCommand)

While Sleep(100)
WEnd

Func DelCommand()
  Send("+{SPACE}") ;select row
  Sleep(100)
  Send("{F10}")                       ;opens hotkey menu
  Sleep(100)
  Send("h")                       ;opens home menu
  Sleep(100)
  Send("d")                       ;opens delete menu
  Sleep(100)
  Send("r")                       ;deletes row
EndFunc   ;==>DelCommand

ps. you could also use Excel UDF, to perform those tasks instead of sending keys, which would make your script way more reliable.

Edited by Nine
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...