Jump to content

Simple question :)


Recommended Posts

Hi, I just wrote my first script in AI (Suitable acronym? :)) and it is currently triggered by NumLock, and stopped by / key next to it. I was wondering if thre is a way to toggle it with Spacebar, or use Mousewheel up/down, or Mouse4/5 to trigger it?

Thanks in advance :)

Edited by cjetalaD
Link to comment
Share on other sites

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.2.4.9
 Author:         myName

 Script Function:
    Template AutoIt script.

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here

dim $num

$num = 10

HotKeySet("{NUMLOCK}", "Start")
Hotkeyset("{NUMPADDIV}", "Stop")
HotKeySet("{NUMPADMULT}", "Close")

#include <GUIConstants.au3>
Opt("GUIOnEventMode", 1)

$mainwindow = GUICreate("Bunnyhopper", 200, 48)
GUISetOnEvent($GUI_EVENT_CLOSE, "Close")
GUISetState(@SW_SHOW)

While 1
  Sleep(1000); Idle around
WEnd

Func Close()
  Exit
EndFunc

Func Start()
    $num = 10
    Do 
    Sleep(25)
    Send("{SPACE}")
    Until $num = 5
EndFunc

Func Stop()
    $num = 5
EndFunc

Edited by cjetalaD
Link to comment
Share on other sites

For Start() function, don't start sending {SPACE} when it's still a hotkey.

Func Start()
    $num = 10
    HotKeySet("{SPACE}")
    Do
    Sleep(25)
    Send("{SPACE}")
Until $num = 5
HotKeySet("{SPACE}", "Start")
EndFunc

EDIT: Yes, HotKeySet("{SPACE}", "Start") should be it.

Edited by poisonkiller
Link to comment
Share on other sites

Another quick one, I'm trying to get the value from the input box to be assigned to the speed varaible, saving me having to recompile, I've read the online help, still having trouble getting it to work though :)

EDIT: The code, of course:

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.2.4.9
 Author:         myName

 Script Function:
    Template AutoIt script.

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here

dim $num
dim $time

$num = 10
$time = 50

;HotKeySet("{NUMLOCK}", "Start")
HotKeySet("{SPACE}", "Start")
Hotkeyset("{NUMPADDIV}", "Stop")
HotKeySet("{NUMPADMULT}", "Stop2")
HotKeySet("{NUMPADSUB}", "Close")

#include <GUIConstants.au3>
Opt("GUIOnEventMode", 1)

$mainwindow = GUICreate("Bunnyhopper", 180, 100)
GUISetOnEvent($GUI_EVENT_CLOSE, "Close")
GUICtrlCreateLabel("SpaceBar to Enable.", 30, 10)
GUICtrlCreateLabel("* then \ to Disable.", 30, 25)
GUICtrlCreateLabel("- to Close.", 30, 40)
$input = GUICtrlCreateInput("", 30, 60)
$ok = GUICtrlCreateButton("OK", 100, 58, 60)
GUICtrlRead($input, 1)
GUICtrlSetOnEvent($ok, "Ok")
GUISetState(@SW_SHOW)

Func Ok()
$time = $input
EndFunc

While 1
  Sleep(1000) ; Idle around
WEnd

Func Close()
  Exit
EndFunc

Func Start()
    $num = 10
    HotKeySet("{SPACE}")
    Do
    Sleep($time)
    Send("{SPACE}")
Until $num = 5
EndFunc

Func Stop()
    $num = 5
    HotKeySet("{SPACE}", "Start")
EndFunc

Func Stop2()
    $num = 5
EndFunc
Edited by cjetalaD
Link to comment
Share on other sites

If this is where you set it -- You have to read the control:

Func Ok()
     $time = Number(GuiCtrlRead($input))
EndFunc

:)

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