Sign in to follow this  
Followers 0
ploylitarynode

Running AU3 script from Keystroke

9 posts in this topic

Is there a way to run a script from a keystroke? Say I wanted to hit alt+ctrl+p to launch a script. How would I go about doing that?

thanks,

-Ploxy

Share this post


Link to post
Share on other sites

#2 ·  Posted (edited)

You could run a script in the background with HotKeySet() to activate a function or call another script.

:idea:

P.S. You can also set a hot key in Windows via the properties of a shortcut. See FileCreateShortcut() in the help file.

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

You could run a script in the background with HotKeySet() to activate a function or call another script.

:idea:

I am completely new to the AU3. Is there an example of doing this? I will take a gander at some examples. In the forums.

thanks for the quick response.

:)

-ploxy

Share this post


Link to post
Share on other sites

I am completely new to the AU3. Is there an example of doing this? I will take a gander at some examples. In the forums.

thanks for the quick response.

:idea:

-ploxy

HotKeySet("{F1}","MyFunction")

While 1
    Sleep(2000)
WEnd

Func MyFunction()
    ; Some Functions
    
EndFunc

However, the script must already be loaded, but once F1 is pressed it will load that function.

Share this post


Link to post
Share on other sites

HotKeySet("{F1}","MyFunction")

While 1
    Sleep(2000)
WEnd

Func MyFunction()
    ; Some Functions
    
EndFunc

However, the script must already be loaded, but once F1 is pressed it will load that function.

Awesome. Thank you very much.

-ploxy

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Okay so I tried some tinkering.

And now I am getting an error that says I am missing an EndFunc for _WinWaitActivate($title,$text,$timeout=0)

HotKeySet("{a}{v}{p}","MyFunction")

While 1
    Sleep(2000)
WEnd

Func MyFunction()

Opt("WinWaitDelay",100)
Opt("WinDetectHiddenText",1)
Opt("MouseCoordMode",0)

_WinWaitActivate("TradeStation 8.7 - Untitled Desktop: 1 - Untitled Workspace:  1","TradeStation RadarSc")
Send("{ALTDOWN}{TAB}{TAB}{ALTUP}")
_WinWaitActivate("Microsoft Excel - Book1","Status Bar")
MouseMove(46,249)
MouseDown("left")
MouseMove(40,449)
MouseUp("left")
Send("{CTRLDOWN}c{CTRLUP}{ALTDOWN}{TAB}{ALTUP}")
_WinWaitActivate("TradeStation 8.7 - Untitled Desktop: 1 - Untitled Workspace:  1","TradeStation RadarSc")
Send("{CTRLDOWN}v{CTRLUP}{ALTDOWN}{ALTUP}")

Func _WinWaitActivate($title,$text,$timeout=0)
    WinWait($title,$text,$timeout)
    If Not WinActive($title,$text) Then WinActivate($title,$text)
    WinWaitActive($title,$text,$timeout)
EndFunc
EndFunc

any thoughts on what I am doing wrong?

-Ploxy

Edited by ploylitarynode

Share this post


Link to post
Share on other sites

Remove the last EndFunc...

Share this post


Link to post
Share on other sites

You can't declare a function inside a function! :idea:

hahah I am moron thanks.

Been a long day / week

it works!

-Ploxy

Share this post


Link to post
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
Sign in to follow this  
Followers 0