Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Help with my script


  • Please log in to reply
10 replies to this topic
pjvillarante
  • Members
  • 15 posts
  • Last active: Dec 04 2015 04:43 AM
  • Joined: 20 Sep 2015

Ok, so im noob with scripting. Back then, this simple script (1) of mine works in my game while this kind of scripts (2) work

Now, what i wanted to do was to revise script (1) so that it will work

It works this way, when I press F1, it will press F1 then Enter then F2 then Mouseclick then repeat. I want it that when i press F1 it will be a continuous loop and when i press F1 again, it will stop. Help me please?

 

(1)

~F1::
loop, %count% {
send, {F1}
sleep, 500
send, {Enter}
sleep, 1200
send, {F2}
sleep, 150
MouseClick, Left
sleep, 50
}
Return
 

 

(2)

$F1::
SetKeyDelay,-1 ;
Loop
{
   BlockInput, MouseMoveOff
    if not GetKeyState("F1", "P")
     SendPlay {F1}{LButton}
   BlockInput, off
   SendEvent {Click}
}
 
 


Shadowpheonix
  • Members
  • 268 posts
  • Last active:
  • Joined: 10 Feb 2014

This thread will tell you how to do what you want.



pjvillarante
  • Members
  • 15 posts
  • Last active: Dec 04 2015 04:43 AM
  • Joined: 20 Sep 2015

list={F1},{enter},{F2},{click}
stringsplit, list, list,`,
Counter = 0

$F8::
Counter := (Counter=list0) ? (1) : (Counter+1)
send % list%counter%
return

 

what's wrong with this help me please



pjvillarante
  • Members
  • 15 posts
  • Last active: Dec 04 2015 04:43 AM
  • Joined: 20 Sep 2015

help



Exaskryz
  • Members
  • 3249 posts
  • Last active: Nov 20 2015 05:30 AM
  • Joined: 23 Aug 2012

I tested the script by changing the "send" into "tooltip". It should be working just fine. Why do you think it's wrong? What is happening vs what you expect?

 

Edit: OK, going back to the original post, you still want it to automatically work. Correct me if that's wrong. (Your $F8 script you shared works just one at a time with each press of F8.)

 

I'd use SetTimer in this to make it automatically send every half second. F8 can turn it on or off. You can change that to F1 if you wish.

list={F1},{enter},{F2},{click}
stringsplit, list, list,`,
Counter = 0

$F8::SetTimer, myTimer, % (toggle:=!toggle)?"500":"Off"
 
myTimer:
Counter := (Counter=list0) ? (1) : (Counter+1)
send % list%counter%
return

Problem with this simple approach is there's no variation in the time. I would consider this as a way to still use the timer but change up the timing.

list={F1},{enter},{F2},{click}
stringsplit, list, list,`,
mist=-500,-1200,-150,-50
stringsplit, mist, mist,`,
Counter = 0

$F8::SetTimer, myTimer, % (toggle:=!toggle)?"-500":"Off"
 
myTimer:
Counter := (Counter=list0) ? (1) : (Counter+1)
send %  list%counter%
SetTimer, myTimer, % mist%counter%
return

Edited due to lack of parentheses in the toggling. Thanks Xtra for the correction. I tested being able to turn it on, then off, but never on again ^_^'


Edited by Exaskryz, 29 October 2015 - 08:39 PM.


Xtra
  • Members
  • 954 posts
  • Last active: Jul 23 2016 09:04 PM
  • Joined: 29 Sep 2013

Using:

$F8::SetTimer, myTimer, % toggle:=!toggle?"500":"Off"

Will only turn the timer on once then it will allways be set to off.

 

It should be set like this:

$F8::SetTimer, myTimer, % (toggle:=!toggle)?"500":"Off"

Here is my take on this using an array for the keys and sleeps.

list:=[["{F1}",500],["{enter}",1200],["{F2}",150],["{click}",50]] , Cnt:=0


$F1::SetTimer, myTimer, % (toggle:=!toggle)?-1:"Off",(Cnt:=0)


myTimer:
    Send % list[(Cnt=list.MaxIndex())?Cnt:=1:++Cnt,1]
    Sleep list[Cnt,2]
    SetTimer, myTimer, % toggle?-1:"Off"
return

OP in the future there is no need to PM people for help you will get help if you are patient.

 

Arrays
SetTimer

ternary operator (?)

 



pjvillarante
  • Members
  • 15 posts
  • Last active: Dec 04 2015 04:43 AM
  • Joined: 20 Sep 2015

thank you both of you

it's because Shadowphoenix is always replying to see this thread (link) which i found some hard to understand

thank you again :)



pjvillarante
  • Members
  • 15 posts
  • Last active: Dec 04 2015 04:43 AM
  • Joined: 20 Sep 2015

for somewhat reason, this is not working in the game i am playing. it doesn't send any keys even if i change the timer :(



Exaskryz
  • Members
  • 3249 posts
  • Last active: Nov 20 2015 05:30 AM
  • Joined: 23 Aug 2012

Have you been able to make any AHK scripts work in your game? Some games don't respond too well.

 

Check out this thread for troubleshooting tips: http://www.autohotke...mes-the-basics/



pjvillarante
  • Members
  • 15 posts
  • Last active: Dec 04 2015 04:43 AM
  • Joined: 20 Sep 2015

yes as i've said this script worked :(

 

$F1::
SetKeyDelay,-1 ;
Loop
{
   BlockInput, MouseMoveOff
    if not GetKeyState("F1", "P")
     SendPlay {F1}{LButton}
   BlockInput, off
   SendEvent {Click}
}
 
can you just help me with this below
what i wanted was to send WheelUp WheelDown at the same time at speed as fast as possible
how can i speed this up? 
 
#MaxThreadsPerHotkey 2
SetKeyDelay, -1
 
 
$F8::
if (toggle:=!toggle)
While toggle
{
Sendinput, {WheelUp}
Sendinput, {WheelDown}
 
}
Return


Xtra
  • Members
  • 954 posts
  • Last active: Jul 23 2016 09:04 PM
  • Joined: 29 Sep 2013

Try the scripts we posted adding this to the top of them:

SetKeyDelay,-1,20
SetKeyDelay
  PressDuration

Certain games and other specialized applications may require a delay inside each keystroke; that is, after the press of the key but before its release.

 

 

 

 

I think your game problems with the scripts we posted is you have no press duration which is default -1 for the sendmode you are using.