Need help: loop and compare number

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
hunter1
Posts: 4
Joined: 24 Feb 2018, 23:01

Need help: loop and compare number

24 Feb 2018, 23:36

f1::
$stop := 0
Loop, 25
{
Send k

Sleep 1500
if ($stop)
{
return
}
}

f2::
$stop := 1

sleep, 350
return
----------------------
This scrip I learn from a expert in this forum, it running on a windows app,
Now I want to add one more function for it like when it running it will be compare 2 number EX : A and B, I know A(x,y) and B (x,y), A and B on 2 cell of windows app,
It will running on loop and check A and B, if A<B , scrip will be stop until I want continue by hit F2,
Please help and advice,
Thank you too much,
User avatar
divanebaba
Posts: 805
Joined: 20 Dec 2016, 03:53
Location: Diaspora

Re: Need help: loop and compare number

28 Feb 2018, 18:03

Hi, first of all welcome to the AHK-forum.

Your issue is a bit difficult to understand, so I give you only an example for toggling your script.
Later, when you describe, from where you get the two numbers to compare, we can continue.

Your type of toggling is easy to solve with a timer.
Pressing F1 starts your script. Pressing F2 stops and continues your script.
If you want a maximal amount of sended keystrokes, you have to count inside your timed label and do some action there.
My example is only a suggestion.

Code: Select all

F1::
$stop := 1
settimer, MyTimedLabel, 1500
return

MyTimedLabel:
if ($stop)
	Send k
return

f2::
$stop := !$stop
return
Einfach nur ein toller Typ. :mrgreen:
hunter1
Posts: 4
Joined: 24 Feb 2018, 23:01

Re: Need help: loop and compare number

01 Mar 2018, 00:45

divanebaba

Let easy to know i have a ex:
We have 2 columns on excel: A and B , they have number already ; the scrip will be run in there by loop from first row to last,
every row will be check numbers in A and B cell, if a> b will be continue to next row but if a< b will be stop .
How to do a scrip can does that? any way when we know x, y of 2 number like A, B, ex : A( 123, 456), B( 678, 901), Do we have any function on auto hot key to compare them?
Thanks
User avatar
Xeo786
Posts: 759
Joined: 09 Nov 2015, 02:43
Location: Karachi, Pakistan

Re: Need help: loop and compare number

01 Mar 2018, 02:55

Select range in MS excel and it will compare the value of selection to right next column , and give answer in 3rd column to the right

Code: Select all

for cell in ComObjActive("Excel.Application").Selection 
	if (cell.value > cell.offset(0,1).value)
		cell.offset(0,2).value := "OK"
	else 
		cell.offset(0,2).value := "NOT OK"
"When there is no gravity, there is absolute vacuum and light travel with no time" -Game changer theory

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 272 guests