Jump to content

ClearScreen with hotkeyset


LoggSar
 Share

Recommended Posts

Hi there

I´m new to Autoit and still heavy learning...

 

I would like to use some Linux-Shortcuts and own Shortcuts under Windows.

First are opening an command window with the ScrollLock and clear the command window with CTRL L

This is my Script:

 

;^ = ctrl, ! = alt
HotKeySet("{scrolllock}", "HStart")
    Func HStart()
        Run('cmd /T:07 /K CD /D D:\Tools')
    EndFunc

HotKeySet("^l", "HCls")
    Func HCls()
        Run('cls')
    EndFunc

For $i = 1 to 20
    WinWaitActive("Windows Security")
    SendKeepActive("Windows Security")
    ;Send Alt+I to Install Prompted Driver
    Send("!i")
    Sleep(500)
Next

 

The Scrolllock is working, but not the ^l (even if I try 'cmd /c cls')

Why not?

 

Thx

 

Link to comment
Share on other sites

1. never and I say NEVER use "Send" to automate. Use ControlSend.

2. Your "for" statement is wrong. You are not able to exit the loop. You have $i=1 and that value will never change. You need to add before "Next" the following line: $i=$i+1

3. Put your hotkey sets first in your script, your loop in the middle and your functions below.

4. Your "For" statement is not part of a function and will only run once when you kick off your script. Put it inside a function.

5. Why do you need to run a shortcut? Just run the exe file you wish to run. A shortcut is nothing more than a pointer to the exe.

Link to comment
Share on other sites

Hi Bert

Quote

1. never and I say NEVER use "Send" to automate. Use ControlSend.

When I´ve seen this correct - the difference between Send and ControlSend is that ControlSend is exacter?

I´ve found the Send in the autoit-docs - at the bottom of https://www.autoitscript.com/autoit3/docs/functions/ControlSend.htm - but probably you´re right - exacter is better.

 

Quote

2. Your "for" statement is wrong. You are not able to exit the loop. You have $i=1 and that value will never change. You need to add before "Next" the following line: $i=$i+1

I haven't seen this because I use it only once. But thanks.

Quote

5. Why do you need to run a shortcut? Just run the exe file you wish to run. A shortcut is nothing more than a pointer to the exe.

Shortcut? Which Shortcut?

 

My script looks like this - and its working


 

;^ = ctrl, ! = alt
HotKeySet("{scrolllock}","HStart")
    Func HStart()
        Run('cmd /T:07 /K CD /D %systemdrive%\Tools')
    EndFunc

HotKeySet("^l","HCls")
    Func HCls()
        ;ControlSend("[CLASS:ConsoleWindowClass]", "", "", "cls")
        Send("cls")
        Send("{Enter}")
    EndFunc

DrvInst()

Func Drvinst()
    For $i = 1 to 10
        WinWaitActive("Windows Security")
        SendKeepActive("Windows Security")
        sleep(1000)
        ;Send Alt+I to Install Prompted Driver
        ControlSend("[CLASS:#32770]","&Install","Button1","!i")
        $i=$i+1
    Next
EndFunc

 

 

 

 

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