Jump to content

Question


Recommended Posts

Func Pramh()
    _Sendkeys($hWnd, "d5")
MouseClick("left")
sleep(800)
EndFunc

I need to make a loop. So when hot key "INSERT" is pressed, it will just loop the func, until "INSERT" Is pressed again. Is there a way to go about doing this?

[font="Verdana"]Valik:Get it straight - I'm not here to say please, I'm here to help - if my help's not appreciated then lotsa luck, gentlemen.[/font]

Link to comment
Share on other sites

  • Moderators

Func Pramh()
    _Sendkeys($hWnd, "d5")
MouseClick("left")
sleep(800)
EndFunc

I need to make a loop. So when hot key "INSERT" is pressed, it will just loop the func, until "INSERT" Is pressed again. Is there a way to go about doing this?

Global Variable

Hotkeyset

While / WEnd or Do / Until Loop

Take a look at the HotKeySet() example for TogglePause() in the help file ... that's your answer.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Global $Paused
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{END}", "Pramh")
HotKeySet("{INSERT}", "DSG")

;Run("C:\Program Files\KRU\Dark Ages\windower.exe")

$hWnd = WinGetHandle("Darkages");Name of the programs' title
                
WinSetTitle($hWnd, "", "Arena")



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

;;;;;;;;

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

Func Pramh()
    _Sendkeys($hWnd, "d5")
MouseClick("left")
sleep(800)
EndFunc

Still having a problem. When I hit the hotkey, it will do the funcation. I need it to do the funcation untill I hit the hotkey again, how would I go about doing that?

[font="Verdana"]Valik:Get it straight - I'm not here to say please, I'm here to help - if my help's not appreciated then lotsa luck, gentlemen.[/font]

Link to comment
Share on other sites

Global $Paused = 1
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{END}", "Pramh")
HotKeySet("{INSERT}", "DSG")

;Run("C:\Program Files\KRU\Dark Ages\windower.exe")

$hWnd = WinGetHandle("Darkages");Name of the programs' title

WinSetTitle($hWnd, "", "Arena")



;;;; Body of program would go here;;;;
While 1
    Sleep(100)
    If $Paused Then ToolTip('Macroing is "Paused"', 0, 0)
WEnd

;;;;;;;;

Func TogglePause()
    $Paused = Not $Paused
    If Not $Paused Then ToolTip("")
EndFunc  ;==>TogglePause

Func Pramh()
    _Sendkeys ($hWnd, "d5")
    MouseClick("left")
    Sleep(800)
EndFunc  ;==>Pramh

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

Global $Paused = 1
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{END}", "Pramh")
HotKeySet("{INSERT}", "DSG")

;Run("C:\Program Files\KRU\Dark Ages\windower.exe")

$hWnd = WinGetHandle("Darkages");Name of the programs' title

WinSetTitle($hWnd, "", "Arena")



;;;; Body of program would go here;;;;
While 1
    Sleep(100)
    If $Paused Then 
        ToolTip('Macroing is "Paused"', 0, 0)
    Else
        Pramh()
    EndIf
WEnd

;;;;;;;;

Func TogglePause()
    $Paused = Not $Paused
    If Not $Paused Then ToolTip("")
EndFunc ;==>TogglePause

Func Pramh()
    _Sendkeys ($hWnd, "d5")
    MouseClick("left")
    Sleep(800)
EndFunc ;==>Pramh

8)

NEWHeader1.png

Link to comment
Share on other sites

That works thanks. One thing though I wanted to have two funcations in the script. With just a pause I can't select which One I want to use. Due to it's pausing the the whole script. Thats why I need to use the hot keys to run the funcation, then have it just loop until I hit the hotkey again.

Global $Paused
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{END}", "Pramh")
HotKeySet("{INSERT}", "DSG")

;Run("C:\Program Files\KRU\Dark Ages\windower.exe")

$hWnd = WinGetHandle("Darkages");Name of the programs' title
                
WinSetTitle($hWnd, "", "Arena")



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

;;;;;;;;

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

Func Pramh()
    _Sendkeys($hWnd, "d5")
MouseClick("left")
sleep(800)
EndFunc


Func DSG()
    _Sendkeys($hWnd, "d4")
MouseClick("left")
sleep(800)
EndFunc

Func OnAutoItExit ( )
WinSetTitle($hWnd, "", "Darkages - Windowed by Eru")
EndFunc
Edited by Sardith

[font="Verdana"]Valik:Get it straight - I'm not here to say please, I'm here to help - if my help's not appreciated then lotsa luck, gentlemen.[/font]

Link to comment
Share on other sites

Couldn't I do something like..

If _IsPressed(0x01) Then

_Aim()

EndIf
    
    Sleep(10)
WEnd

Func _IsPressed($hexKey)
    Local $ret = DllCall("user32", "int", "GetAsyncKeyState", "int", $hexKey)
    If Not @error And BitAND($ret[0], 0x8000) = 0x8000 Then
        Return True
    Else
        Return False
    EndIf
EndFunc

[font="Verdana"]Valik:Get it straight - I'm not here to say please, I'm here to help - if my help's not appreciated then lotsa luck, gentlemen.[/font]

Link to comment
Share on other sites

  • Moderators

Try replacing TogglePauses information with your functions information. I didn't mean for you to use TogglePause, I wanted you to see the functionality and incorporate it into your own function :think: .

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Oh, I feel silly thanks. Give me a example with one on my funcations? Im not sure how to redo it...

Edit: Im really confused now.

Edited by Sardith

[font="Verdana"]Valik:Get it straight - I'm not here to say please, I'm here to help - if my help's not appreciated then lotsa luck, gentlemen.[/font]

Link to comment
Share on other sites

  • Moderators

Oh, I feel silly thanks. Give me a example with one on my funcations? Im not sure how to redo it...

You're kidding right?

Look at the TogglePause Function, then run the script, hit pause and then hit pause again, and see what is going on. Then look at your function, what is yours missing that TogglePause isn't, then fix yours.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

At this point im not kidding. Im completely missing it.

[font="Verdana"]Valik:Get it straight - I'm not here to say please, I'm here to help - if my help's not appreciated then lotsa luck, gentlemen.[/font]

Link to comment
Share on other sites

maybe

Global $Paused = 0, $Paused2 = 0
HotKeySet("{END}", "Pramh")
HotKeySet("{INSERT}", "DSG")

;Run("C:\Program Files\KRU\Dark Ages\windower.exe")

$hWnd = WinGetHandle("Darkages");Name of the programs' title

WinSetTitle($hWnd, "", "Arena")

;;;; Body of program would go here;;;;
While 1
    If $Paused = 1 Then
        _Sendkeys ($hWnd, "d5")
        MouseClick("left")
        Sleep(800)
    EndIf
    
    If $Paused2 = 1 Then
        _Sendkeys ($hWnd, "d4")
        MouseClick("left")
        Sleep(800)
    EndIf
    
    Sleep(1)
WEnd

;;;;;;;;

Func Pramh()
    If $Paused = 0 Then
        $Paused = 1
    Else
        $Paused = 0
    EndIf
EndFunc  ;==>Pramh

Func DSG()
    If $Paused2 = 0 Then
        $Paused2 = 1
    Else
        $Paused2 = 0
    EndIf
    
EndFunc  ;==>DSG

Func OnAutoItExit()
    WinSetTitle($hWnd, "", "Darkages - Windowed by Eru")
EndFunc  ;==>OnAutoItExit

8)

NEWHeader1.png

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