Sign in to follow this  
Followers 0
Orgins

can use help on my script.

2 posts in this topic

#1 ·  Posted (edited)

I tried to make a hot key switcher for a game.

The idea is I hold down 1 and push the letter for the first hot key then hold down the number pad 1 and the real hot key.

After all the hot keys are recored there's a If new hot key is pushed send old hot key part.

but I cant figure out how to get it to record what key was pressed.

Heres my script:

#include <Array.au3>
#include <Misc.au3>

Dim $avArray
Global $Paused

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

$dll = DllOpen("user32.dll")
$Array = _ArrayCreate("41", "42", "43", "44", "45", "46", "47", "48", "49", "4A", "4B", "4C", "4D", "4E", "4F", "50", "51", "52", "53", "54", "55")
$Array2 = _ArrayCreate("56", "57", "58", "59", "5A")


$Skill1New = IniRead ( "Skills.ini", "NewSkill", "1", "default" )
$Skill2New = IniRead ( "Skills.ini", "NewSkill", "2", "default" )
$Skill3New = IniRead ( "Skills.ini", "NewSkill", "3", "default" )
$Skill4New = IniRead ( "Skills.ini", "NewSkill", "4", "default" )


$Skill1old = IniRead ( "Skills.ini", "OldSkill", "1", "default" )
$Skill2Old = IniRead ( "Skills.ini", "OldSkill", "2", "default" )
$Skill3Old = IniRead ( "Skills.ini", "OldSkill", "3", "default" )
$Skill4Old = IniRead ( "Skills.ini", "OldSkill", "4", "default" )

$Mapingkey = "{INSERT}"
$Startingkey = "{HOME}"
$Mainkey = "{END}"



Main()
        
        
        
        
Func Main()
  ToolTip("",0,0)
    While 1
        If _IsPressed("2D", $dll) Then; insert
           MapKeys()
           Endif 
        If _IsPressed("24", $dll) Then; home
          Start()
        EndIf
    wend
Endfunc



Func MapKeys()
    While 1
            ToolTip("Start Maping keys",0,0)
            
If _IsPressed("31", $dll) and _IsPressed($Array, $dll) Then; 1
    $skill = $Array 
    IniWrite ( "Skills.ini", "NewSkill", "1", $skill )
    Beep(500, 500)
Endif

If _IsPressed("32", $dll) and _IsPressed($Array, $dll) Then; 2
    $skill = $Array
    IniWrite ( "Skills.ini", "NewSkill", "2", $skill )
    Beep(500, 500)
Endif

If _IsPressed("33", $dll) and _IsPressed($Array, $dll) Then; 3
    $skill = $Array
    IniWrite ( "Skills.ini", "NewSkill", "3", $skill )
    Beep(500, 500)
Endif

If _IsPressed("34", $dll) and _IsPressed($Array, $dll) Then; 4
    $skill = $Array
    IniWrite ( "Skills.ini", "NewSkill", "4", $skill )
    Beep(500, 500)
    Endif
        

If _IsPressed("31", $dll) and _IsPressed($Array2, $dll) Then; 1
    $skill = $Array2
    IniWrite ( "Skills.ini", "NewSkill", "1", $skill )
    Beep(500, 500)
Endif

If _IsPressed("32", $dll) and _IsPressed($Array2, $dll) Then; 2
    $skill = $Array2
    IniWrite ( "Skills.ini", "NewSkill", "2", $skill )
    Beep(500, 500)
Endif

If _IsPressed("33", $dll) and _IsPressed($Array2, $dll) Then; 3
    $skill = $Array2
    IniWrite ( "Skills.ini", "NewSkill", "3", $skill )
    Beep(500, 500)
Endif

If _IsPressed("34", $dll) and _IsPressed($Array2, $dll) Then; 4
    $skill = $Array2
    IniWrite ( "Skills.ini", "NewSkill", "4", $skill )
    Beep(500, 500)
    Endif




If _IsPressed($Array, $dll) and _IsPressed("61", $dll) Then;1
    $skill = $Array
    IniWrite ( "Skills.ini", "OldSkill", "1", $skill )
    Beep(500, 500)
Endif

If _IsPressed($Array, $dll) and _IsPressed("62", $dll) Then;2
    $skill = $Array
    IniWrite ( "Skills.ini", "OldSkill", "2", $skill )
    Beep(500, 500)
Endif

If _IsPressed($Array, $dll) and _IsPressed("63", $dll) Then;3
    $skill = $Array
    IniWrite ( "Skills.ini", "OldSkill", "3", $skill )
    Beep(500, 500)
Endif

If _IsPressed($Array, $dll) and _IsPressed("64", $dll) Then;4
    $skill = $Array
    IniWrite ( "Skills.ini", "OldSkill", "4", $skill )
    Beep(500, 500)
Endif


If _IsPressed($Array2, $dll) and _IsPressed("61", $dll) Then;1
    $skill = $Array2
    IniWrite ( "Skills.ini", "OldSkill", "1", $skill )
    Beep(500, 500)
Endif

If _IsPressed($Array2, $dll) and _IsPressed("62", $dll) Then;2
    $skill = $Array2
    IniWrite ( "Skills.ini", "OldSkill", "2", $skill )
    Beep(500, 500)
Endif

If _IsPressed($Array2, $dll) and _IsPressed("63", $dll) Then;3
    $skill = $Array2
    IniWrite ( "Skills.ini", "OldSkill", "3", $skill )
    Beep(500, 500)
Endif

If _IsPressed($Array2, $dll) and _IsPressed("64", $dll) Then;4
    $skill = $Array2
    IniWrite ( "Skills.ini", "OldSkill", "4", $skill )
    Beep(500, 500)
Endif


    
If _IsPressed("24", $dll) then
    start()
Endif
    
Wend
EndFunc




Func start()
    ToolTip("",0,0)

    while 1

 If _IsPressed($Skill1New, $dll) Then
   Send($Skill1Old)
 endif

 If _IsPressed($Skill2New, $dll) Then
   Send($Skill2Old)
 endif

 If _IsPressed($Skill3New, $dll) Then
   Send($Skill3Old)
 endif
 
 If _IsPressed($Skill4New, $dll) Then
   Send($Skill4Old)
 endif

If send("{END}") Then
    ExitLoop
;Main()
    Endif 

 wend
EndFunc



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

I'm a newbie.Sorry if I don't reposed to your replays very fast.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I played with this some

***** NOT TESTED ****

Global $Paused, $Start = 0
Global $dll = DllOpen("user32.dll")
Global $nSkill[5]
Global $oSkill[5]
Global $Array = StringSplit("4A,4B,4C,4D,4E,4F,5A", ",")
Global $Mapingkey = "{INSERT}"
Global $Startingkey = "{HOME}"
Global $Mainkey = "{END}"

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

read_Ini()


ToolTip("", 0, 0)
While 1
    If _IsPressed("2D", $dll) Then; insert
        MapKeys()
    EndIf
    If _IsPressed("24", $dll) Then; home
        $Start = 1
    EndIf
    If Send("{END}") Then ; ???? send end ????
        $Start = 0
    EndIf
    
    If $Start Then
        For $x = 1 To 4
            If _IsPressed($nSkill[$x], $dll) Then Send($oSkill[$x])
        Next
    EndIf
    Sleep(5) ; save CPU
WEnd

Func read_Ini()
    For $x = 1 To 4
        $nSkill[$x] = IniRead("Skills.ini", "NewSkill", $x, "default")
        $oSkill[$x] = IniRead("Skills.ini", "OldSkill", $x, "default")
    Next
EndFunc   ;==>read_Ini

Func MapKeys()
    While 1
        ToolTip("Start Maping keys", 0, 0)
        
        For $x = 31 To 34
            If _IsPressed($x, $dll) Then
                For $i = 41 To 59 ; 41 - 59... ????? to 64 ???? what do you want here ???
                    If _IsPressed($i, $dll) Then
                        IniWrite("Skills.ini", "OldSkill", $x - 30, IniRead("Skills.ini", "NewSkill", $x - 30, $nSkill[$x - 30]))
                        IniWrite("Skills.ini", "NewSkill", $x - 30, $i)
                        Beep(500, 500)
                        read_Ini()
                        ToolTip("")
                        Return
                    EndIf
                Next
                For $i = 1 To $Array[0]
                    If _IsPressed($Array[$i], $dll) Then
                        IniWrite("Skills.ini", "OldSkill", $x - 30, IniRead("Skills.ini", "NewSkill", $x - 30, $nSkill[$x - 30]))
                        IniWrite("Skills.ini", "NewSkill", $x - 30, $Array[$i])
                        Beep(500, 500)
                        read_Ini()
                        ToolTip("")
                        Return
                    EndIf
                Next
            EndIf
        Next
    WEnd
EndFunc   ;==>MapKeys

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

Func _IsPressed($s_hexKey, $v_dll = 'user32.dll')
    ; $hexKey must be the value of one of the keys.
    ; _Is_Key_Pressed will return 0 if the key is not pressed, 1 if it is.
    Local $a_R = DllCall($v_dll, "int", "GetAsyncKeyState", "int", '0x' & $s_hexKey)
    If Not @error And BitAND($a_R[0], 0x8000) = 0x8000 Then Return 1
    Return 0
EndFunc   ;==>_IsPressed

8)

Edited by Valuater

NEWHeader1.png

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