Why when I run application it just skip some ifs - autohotkey

As I said text that is bolded doesn't work, it just skip it (it worked without those ifs) could you help me? Please, I'm doing that few hours but it still doesn't work. I tried to add this if not in this loop and it worked, please give me a hand, I spent so much time
on it ;(
Gui, Add, CheckBox, x405 y317 w15 h15 vwyrzucaniediax gZapisz,
Gui, Show, h500 w800, Skrypt Na Kopanie
Return
Zapisz:
Gui, Submit , NoHide
return
F8::
WinMove, Minecraft, , , , 1280, 720
sleep 1000
Loop
{
if poziome
{
}
if pionowe
{
}
Checker()
}
Checker()
{
x := 503
y := 385
l := 0
i := 0
Send e
loop, 27{
if(i = 9){
i := 0
l++
}
Sleep 100
MouseMove, x +36*i, y + 36*l
**if wyrzucaniediax // all strong text is just skipped idk why
{
Dropdiax()
}
**
i++
}
Send e
Sleep 50
}
dropdiax(){
diaxcolor := 0x80ĄFFE
color:= getColor()
if(color == diaxcolor){
Send {LCtrl down}
Send q
Sleep 50
Send {LCtrl up}
}
}```

Your wyrzucaniediax variable (maybe you could use better variable names when asking for help?) isn't defined in that function's scope.
To tell the function you're using a variable from outside of its scope, you can use the Global keyword.
Checker()
{
global wyrzucaniediax
x := 503
y := 385
l := 0

Related

AHK PixelSearch Loop

I'm trying to get my AHK Script to Work.
Basically i want to find a row of x Pixels with the Color 0x26FDFD (BGR). But i don't know the AHK Scripting language well wnough to think about a smart, clean and easy way to program that loop, that the starting point will be modified based on the last found coordinates.
However, here's what i got so far:
SysGet, VirtualWidth, 78
SysGet, VirtualHeight, 79
;Farbe nach der gesucht wird:
ColorVar := 0x26FDFD
i:=0
while i < 10
{
PixelSearch, FoundX, FoundY, 0, 0, VirtualWidth, VirtualHeight, %ColorVar%, 3, Fast
if (ErrorLevel = 2)
{
MsgBox Could not conduct the search.
return
}
else if (ErrorLevel = 1)
{
MsgBox Color could not be found on the screen.
return
}
else
{
MouseMove, %FoundX%, %FoundY%
MsgBox Found a Pixel at %FoundX%x%FoundY%.
;return
}
i++
}
Kinda stupid and basic question, but somehow i can't figure it out.
I just needed to store the X and Y coordinates at the end of each loop, then set the new startpoint accordingly.
here's the code:
i:=0
while i < 5
{
PixelSearch, FoundX, FoundY, startX%A_Index%, startY%A_Index%, VirtualWidth, VirtualHeight, %ColorVar%, 3, Fast
Switch ErrorLevel
{
Case 1:
MsgBox Website ueberpruefen!
return
Case 2:
MsgBox Makro ueberpruefen!
return
Default:
MouseMove, %FoundX%, %FoundY%
;MsgBox Found a Pixel at %FoundX%x%FoundY%.
nextLoop := A_Index + 1
startX%nextLoop% := FoundX + 1
startY%nextLoop% := FoundY
}
i++
}
;msgbox % "found 5 matches!, first at: " startX2 "x" startY2
return

How to reset a key sequence with a specific key?

So this sequence resets itself after 1.5 sec (t:=1500) which means if i dont hit the left mouse button for 1.5 sec it always sends A. Otherwise it sends the next letter after each click.
I want to further tweak this code with another function which is to be able to reset the sequence with right mouse button too. So if i hit RButton any time it should reset to A.
Thx.
global s:=0, c:=0, t:=1500
*LButton::
Send % Seqkeys("A","B","C")
KeyWait, LButton
Send, R
return
Seqkeys(params*) {
global s, c, t
max := params.MaxIndex()
(A_TickCount-s<=t && (c+=1)<=max) ? c : c:=1
s := A_TickCount
return params[c]
}
Merely reset the current key index 'c', and the last clicked time 's':
*RButton::
c := 1
s := 0
return
I think your script would benefit with more meaningful variable names:
global lastClickedTime:=0, currentKeyIndex:=0, clickThreshold:=1500
*LButton::
Send % Seqkeys("A","B","C")
KeyWait, LButton
Send, R
return
*RButton::
currentKeyIndex := 1
clickThreshold := 0
return
Seqkeys(params*) {
global lastClickedTime, currentKeyIndex, clickThreshold
max := params.MaxIndex()
currentKeyIndex += 1
if((A_TickCount - lastClickedTime) <= clickThreshold && currentKeyIndex <= max) {
; Do nothing
} else {
currentKeyIndex := 1
}
lastClickedTime := A_TickCount
return params[currentKeyIndex]
}

Why won't my script run when attemping to make a toggle on and off key?

Im trying to make an autohotkey script that loops but only when the script is toggled on, how can i pull this off? this one just doesnt run and idk why
g::
Suspend
Pause
return
Count := 1
Loop {
if (Count = 1){
Send {s down}
Send {a down}
Send {d up}
Count := Count + 1
}else if (Count = 1000){
Send {a up}
Send {d down}
Count := Count + 1
}else if (Count = 2000){
Count := 1
}else{
Count := Count + 1
}
Sleep, 10
}
First of all, I'm not sure why you're using Suspend. Pause should be sufficient to do what you're looking for. Suspend suspends all hotkeys (except the g hotkey in this case because it's the first line in the hotkey), whereas Pause pauses the current thread. And second of all, you have your loop after the hotkey. The auto-execute section of any autohotkey script is only from the top to the first hotkey, so you need to put the loop first, then the hotkey. Here is the revised code:
Count := 1
Loop {
if (Count = 1){
Send {s down}
Send {a down}
Send {d up}
Count := Count + 1
}else if (Count = 1000){
Send {a up}
Send {d down}
Count := Count + 1
}else if (Count = 2000){
Count := 1
}else{
Count := Count + 1
}
Sleep, 10
}
g::
Pause
return

Is Autohotkey able to perform sequential pastes?

Is it possible to create a script for the multiple successive pastes?
Example: I copy ten different words with Ctrl+C (10 times) and paste into my doc pressing Ctrl+V (10 times).
Just for fun:
copiedText := []
~^C::
ClipWait, 0
copiedText.push(clipboard), clipboard := ""
return
^V::sendInput % copiedText.length() ? copiedText.remove(1) : _
something like this
loop,
{
position = 0
loop,
{
~^c::
if (a_index = 9){
position = 0
}
else
{
position := position + 1
}
ClipWait
var%position% := clipboard
return
}
::p1::
send, %var1%
return
::p2::
send, %var2%
return
::p3::
send, %var3%
return
::p4::
send, %var4%
return
::p5::
send, %var5%
return
::p6::
send, %var6%
return
::p7::
send, %var7%
return
::p8::
send, %var8%
return
::p9::
send, %var9%
return
::p10::
send, %var10%
return
}
save clipboard into var then input them where and how you like to.

CPU watch and email with AutoHotKey

I'm trying to setup an automatic email if the conditions are meet. I'm trying to watch my cpu load. if pass or drops over a number send a email.
CheckCPULoad:
CoordMode, ToolTip, Screen
SetFormat, float, 0.0
CPULoad := GetCPULoad_Short()
ToolTip, CPULoad = %CPULoad%%, 0 ,%A_ScreenHeight%
return
GetCPULoad_Short()
{
Static IdleTime, Tick
global ProcessorCount
SetBatchLines, -1
OldIdleTime = %IdleTime%
OldTick = %Tick%
VarSetCapacity( IdleTicks,8,0)
DllCall("kernel32.dll\GetSystemTimes", "uint",&IdleTicks, "uint",0, "uint",0)
IdleTime := *(&IdleTicks)
Loop 7
IdleTime += *( &IdleTicks + A_Index ) << ( 8 * A_Index )
Tick := A_TickCount
Return 100 - 0.01*(IdleTime - OldIdleTime)/(Tick - OldTick) / ProcessorCount
}
#############
#IfEqual, CPUload, 0,
#or
if (CPUload = 0)
{
IfWinNotExist Inbox - Email#Email.com - Outlook
return ; Outlook isn't open to the right section, so do nothing.
WinActivate ; Activate the window found by the above command.
Send ^n ; Create new/blank e-mail via Control+N.
WinWaitActive Untitled - Message (HTML)
Send, sentEmailto#help.com
Send {Tab 3} computer has stopped ; Set the subject line.
Send {Tab} more txt. ; etc.
return ; This line serves to finish the hotkey.
}
But I tried with a simple
if (CPULoad = 0)
msgBox testing
and it won't give me a message. why can i get a message box to show. or email to send?
This post got me curious to see if this had been done before and I instantly found a solution posted on the ahkscript forums:
Loop {
If (CPULoad() > 25) ; Assign the Number you want.
; Your EMAIL Code here! If MultiLine Use {...code...}
Sleep 250
}
CPULoad() { ; By SKAN, CD:22-Apr-2014 / MD:05-May-2014. Thanks to ejor, Codeproject: http://goo.gl/epYnkO
Static PIT, PKT, PUT ; http://ahkscript.org/boards/viewtopic.php?p=17166#p17166
IfEqual, PIT,, Return 0, DllCall( "GetSystemTimes", "Int64P",PIT, "Int64P",PKT, "Int64P",PUT )
DllCall( "GetSystemTimes", "Int64P",CIT, "Int64P",CKT, "Int64P",CUT )
, IdleTime := PIT - CIT, KernelTime := PKT - CKT, UserTime := PUT - CUT
, SystemTime := KernelTime + UserTime
Return ( ( SystemTime - IdleTime ) * 100 ) // SystemTime, PIT := CIT, PKT := CKT, PUT := CUT
}