Sign in to follow this  
Followers 0
Echoze

Newbie Question

10 posts in this topic

hello everyone. i'm pretty much new to autoit and scripting altogether so please bear with me. i've been practicing by creating little simple scripts. my question is, is it possible to assign a hotkey to launch a script that was compiled to an .exe file?

...thanks

Share this post


Link to post
Share on other sites



You can set a hotkey that will run a function in a script while it is running. That function might start another script or do whatever. Please explain further if that isn't enough information.

Share this post


Link to post
Share on other sites

maybe

; Press Esc to terminate script, Pause/Break to "pause"

Global $Paused
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{ESC}", "Terminate")
HotKeySet("+!d", "ShowMessage")  ;Shift-Alt-d
HotKeySet("{F9}", "Run_my_Program")

;;;; Body of program would go here ;;;;
While 1
    Sleep(100)
WEnd
;;;;;;;;

Func TogglePause()
    $Paused = NOT $Paused
    While $Paused
        sleep(100)
        ToolTip('Script is "Paused"',0,0)
    WEnd
    ToolTip("")
EndFunc

Func Terminate()
    Exit 0
EndFunc

Func ShowMessage()
    MsgBox(4096,"","This is a message.")
EndFunc

Func Run_my_Program()
    Run("notepad.exe")
EndFunc

based from "hotkeyset" in help

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

@Valuater I like that pause function. I've been using this to pause my scripts.

Func Toggle()
    If $isPaused Then
        ...
        ...
        ...
        $isPaused = 0
    Else
        ...
        ...
        ...
        $isPaused = 1
    EndIf
EndFunc   ;==>Toggle

Share this post


Link to post
Share on other sites

You can set a hotkey that will run a function in a script while it is running. That function might start another script or do whatever. Please explain further if that isn't enough information.

thank you for your time and help..to be more specific..for example.. i wrote a simple little script that would do a printscreen of the any active open app. on my desktop, paste it into wordpad, set it up as landscape and print it out.. Is it possible to setup a hotkey instead of doubleclicking on the .exe icon each time i want to run the script? from what im gathering from your response is that i would have to create another script that would setup a hotkey to launch that particular script?

Share this post


Link to post
Share on other sites

HI,

yes possible.

1. Have another script that checks whether the hotkey is pressed then start the screenshot script

2. Haveing a while 1 sleep(100) wend loop and check itself for a hotkey.

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

the answer is right there... just add your script in the ***** HERE **** part

HotKeySet("{F9}", "Run_my_Program")


While 1
    Sleep(100)
WEnd
;;;;;;;;


Func Run_my_Program()
    ***** PUT YOUR SCRIPT HERE ****
EndFunc

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

Well there you go, 2 sample scripts that do exactly what you are asking.

Valuater's script has a shorter sleep function :P

Share this post


Link to post
Share on other sites

thats great.. thank you everyone for your help... having fun with this!!

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