Jump to content

Recommended Posts

I've been trying to add a hotkey to a script but I only started out earlier today and I am already struggling with the basics (not a big surprise for starting new) anyway I was hoping someone could give me an example on how to make a simple On/Off Hotkey

#include <Misc.au3>

Global $Paused

HotKeySet("{PAUSE}", "TogglePause")

HotKeySet("{ESC}", "Terminate")

HotKeySet("+!d", "ShowMessage") ;Shift-Alt-d

$dll = DllOpen("user32.dll")

Dim $coord[3]

Func TogglePause()

$Paused = Not $Paused

While $Paused

Sleep(100)

ToolTip('Script is "Paused"', 0, 0)

WEnd

ToolTip("")

EndFunc ;==>TogglePause

While 1

If _IsPressed("1[", $dll) Then ExitLoop

For $i = 0 To 1024 Step 1

$coord = PixelSearch( 0, 0, $i, 768, 0xFF0000, 10 )

If Not @error Then

MouseMove($coord[0],$coord[1])

EndIf

If _IsPressed("1[", $dll) Then ExitLoop

Next

WEnd

Link to comment
Share on other sites

hello "Tuurngait"

try using this code :

HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{ESC}", "Terminate")
HotKeySet("+!d", "ShowMessage") ;Shift-Alt-d

Global $Paused
Dim $coord[3]
While 1
For $i = 0 To 1024 Step 1
$coord = PixelSearch( 0, 0, $i, 768, 0xFF0000, 10 )
If Not @error Then
MouseMove($coord[0],$coord[1])
EndIf
Next

WEnd

Func TogglePause()
$Paused = Not $Paused
While $Paused
Sleep(100)
ToolTip('Script is "Paused"', 0, 0)
WEnd
ToolTip("")
EndFunc ;==>TogglePause

func Terminate ()
msgbox(0,"Hotkey problem", "script Terminate")
exit
EndFunc

func ShowMessage()
msgbox(0,"Hotkey problem","my program message")
EndFunc

enjoy !!

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

×
×
  • Create New...