Jump to content
Sign in to follow this  
Jos07

setting hot key for script ?

Recommended Posts

Jos07

can anybody tell me,

how can i set hotkey to stop my script/exe completely from working ?

i want to stop the script/exe and its all running functions/processes/etc.

any help will be really appreciated.


Always Keep Your Sig Small... Like me :D

Share this post


Link to post
Share on other sites
goldenix

HotKeySet

in the Helpfile


My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list]

Share this post


Link to post
Share on other sites
Jos07

ya , i read that but could not understand how to stop the all programs which are running from the same program.

but all of them are running from the same script.


Always Keep Your Sig Small... Like me :D

Share this post


Link to post
Share on other sites
Muchuchu

Hotkeyset("{escape}","quit")

func quit
exit
endfunc

Not sure if that's what you are looking for or not but you didn't explain yoruself very well >>

Share this post


Link to post
Share on other sites
AlmarM

Hello,

I made this HotKeySet() Example:

#comments-start
Made by: AlmarM

Example Script for:
            HotKeySet()

Hope u enjoy ^^
#comments-end

$Site_1 = InputBox("Site 1", "Witch site you want to bind on SHIFT + 1 ?")
$Site_2 = InputBox("Site 2", "Witch site you want to bind on SHIFT + 2 ?")
$Site_3 = InputBox("Site 3", "Witch site you want to bind on SHIFT + 3 ?")
$Site_4 = InputBox("Site 4", "Witch site you want to bind on SHIFT + 4 ?")
$Site_5 = InputBox("Site 5", "Witch site you want to bind on SHIFT + 5 ?")

HotKeySet("{ESC}", "_Exit") ;If you press ESC the script will stop
HotKeySet("+{F1}", "_ShowSite") ;If you press SHIFT + F1, the script will show witch sites you have on witch keys
HotKeySet("+1", "_Site1") ;If you press SHIFT + 1, the script activates _Site1()
HotKeySet("+2", "_Site2") ;If you press SHIFT + 2, the script activates _Site2()
HotKeySet("+3", "_Site3") ;If you press SHIFT + 3, the script activates _Site3()
HotKeySet("+4", "_Site4") ;If you press SHIFT + 4, the script activates _Site4()
HotKeySet("+5", "_Site5") ;If you press SHIFT + 5, the script activates _Site5()

While 1
Sleep(100)
WEnd

Func _Exit()
Sleep(100)
Exit
EndFunc ;==> _Exit()

Func _ShowSite()
TrayTip("Sites:", "SHIFT + 1: " & $Site_1 & @CRLF & "SHIFT + 2: " & $Site_2 & @CRLF & "SHIFT + 3: " & $Site_3 & @CRLF & "SHIFT + 4: " & $Site_4 & @CRLF & "SHIFT + 5: " & $Site_5, 5)
EndFunc ;==> _ShowSite()

Func _Site1()
Run("cmd /c start " & $Site_1, "", @SW_HIDE)
EndFunc ;==> _Site1

Func _Site2()
Run("cmd /c start " & $Site_2, "", @SW_HIDE)
EndFunc ;==> _Site2

Func _Site3()
Run("cmd /c start " & $Site_3, "", @SW_HIDE)
EndFunc ;==> _Site3

Func _Site4()
Run("cmd /c start " & $Site_4, "", @SW_HIDE)
EndFunc ;==> _Site4

Func _Site5()
Run("cmd /c start " & $Site_5, "", @SW_HIDE)
EndFunc ;==> _Site5

For more information:

http://www.autoitscript.com/forum/index.php?showtopic=57070


Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

Share this post


Link to post
Share on other sites
aslani

This is what I personally use.

HotKeySet("+{ESC}", "_Terminate")   ; Shift + ESC

Func _waitRelease()
    $dll = DllOpen("user32.dll")
    While 1
        Sleep (100)
        If _IsPressed("A1", $dll) Or _IsPressed("A3", $dll) Then
            ; assume a function key is still pressed and loop again
        Else
            ExitLoop
        EndIf
    WEnd
    DllClose($dll)
EndFunc

Func _Terminate()
    _waitRelease()
    TrayTip("Status: Unloading", "Closing", 10)
    HotKeySet("+{ESC}")
    Sleep(2000)
    Exit
EndFunc

The _waitRelease() function is there just in case you pressed and hold the RSHIFT key in executing the HotKey, because the RSHIFT key has some kind of accessibility function that if you press and hold it longer than 3 seconds, it sticks.

Edited by aslani

[font="Georgia"]Chances are, I'm wrong.[/font]HotKey trouble?Stringregexp GuideAutoIT Current Version

Share this post


Link to post
Share on other sites
PsaltyDS

ya , i read that but could not understand how to stop the all programs which are running from the same program.

but all of them are running from the same script.

I occurs to me that you may mean that you want to pause all the child processes of your script also. This can be done, though it may not be safe.

Fist you would use some method to list all processes that are child processes of your script. My _ProcessListProperties() can help, and includes the PPID (Parent PID) field to compare to @AutoItPID.

Next you need a way to suspend/resume your process, which means suspend/resume the thread(s) of that process. There are ways, but not necessarily safe ways:

The risks with this approach

Not all programs are well written. Not all programs are made to be suspended, specially the multithreaded ones. Programs that implement timeouts may behave abnormally if you pause and resume them. When you pause and resume threads in an arbitrary order, like with this utility, you can create deadlocks.

So, only use this program when you know what you are doing.

The standard disclaimer

As I said before, this is not the safest tool in the world. Use it at your own risk: if you use it, you can loose data, profit, have hardware problems, cause radioactive contamination and start a world war.

Here's another one, not necesarily any safer...

Now, y'all be careful out there!

:)


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

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  

×