AutoHotKey tutorial

05/06/2007 09:28 d2k#31
Ahh, sweet. I still would like to know the other way though. Then expand it perhaps to right clicks and other buttons.
05/06/2007 10:36 bombica23#32
I made a simple calculator with AutoHtKey.

Code:
; calculator

Gui, Show , w400 h120, calculator

; sestevanje
Gui, Add, Edit, w50 h19 x20 y20 vNUMBER1 Left,
Gui, Add, Edit, w50 h19 x97 y20 vNUMBER2 Left,
Gui, Add, Text, x80 y22 w90 Left,+
Gui, Add, Button, x150 y20 w90 h20 vFIRSTBUTTON gsestevanje , calculate
Gui, Add, Edit, w65 h19 x270 y20 vRESULT ReadOnly Left,

; odstevanje
Gui, Add, Edit, w50 h19 x20 y40 vNUMBER3 Left,
Gui, Add, Edit, w50 h19 x97 y40 vNUMBER4 Left,
Gui, Add, Text, x77 y37 w90 Left,__
Gui, Add, Button, x150 y40 w90 h20 vTHIRDBUTTON godstevanje , calcualte
Gui, Add, Edit, w65 h19 x270 y40 vRESULT1 ReadOnly Left


; mnozenje
Gui, Add, Edit, w50 h19 x20 y60 vNUMBER5 Left,
Gui, Add, Edit, w50 h19 x97 y60 vNUMBER6 Left,
Gui, Add, Text, x80 y60 w90 Left,.
Gui, Add, Button, x150 y60 w90 h20 vSECONDBUTTON gmnozenje , claculate
Gui, Add, Edit, w65 h19 x270 y60 vRESULT2 ReadOnly Left

; deljnje
Gui, Add, Edit, w50 h19 x20 y80 vNUMBER7 Left,
Gui, Add, Edit, w50 h19 x97 y80 vNUMBER8 Left,
Gui, Add, Text, x80 y80 w90 Left,:
Gui, Add, Button, x150 y82 w90 h20 vFORTHBUTTON gdeljenje , calculate
Gui, Add, Edit, w65 h19 x270 y80 vRESULT3 ReadOnly Left


return

sestevanje:
{
Gui, Submit, NoHide
sestevanje := NUMBER1+NUMBER2
GuiControl,, RESULT, %sestevanje%
return
}

odstevanje:
{
Gui, Submit, NoHide
odstevanje := NUMBER3-NUMBER4
GuiControl,, RESULT1, %odstevanje%
return
}

mnozenje:
{
Gui, Submit, NoHide
mnozenje := NUMBER5*NUMBER6
GuiControl,, RESULT2, %mnozenje%
return
}

deljenje:
{
Gui, Submit, NoHide
deljenje := NUMBER7/NUMBER8
GuiControl,, RESULT3, %deljenje%
return
}

GuiClose:
ExitApp
05/06/2007 21:38 hieitk#33
Quote:
Originally posted by bombica23@May 6 2007, 10:36
I made a simple calculator with AutoHtKey.
Very nice man ^^

Where are u from? I see you are using another language for variables name =P

One more thing if you wanna excercise.
You know divisions of the kind NUMBER/0 = ERROR or INFINITE

You can add an if to display an error message when someone input a 0 as NUMBER8.

Here you have the solution, try doing it yourself before looking down here xD
And keep up the good work =P

Code:
deljenje:
{
Gui, Submit, NoHide
 if NUMBER8 = 0
 {
 msgbox,,Warning, Here error message
 }
 else
 {
 deljenje := NUMBER7/NUMBER8
 GuiControl,, RESULT3, %deljenje%
 }
 return
}
05/07/2007 06:38 Tinytox#34
WELL: i decided to have some fun XD

Quote:
; simple input/output

Gui, Show , w110 h100, MyHack

; basic elements
Gui, Add, Text, x10 y10 w90 Center,Input 0
Gui, Add, Edit, w90 h19 x10 y30 vNUMBER Center, And press
Gui, Add, Button, x10 y52 w90 h20 vMYBUTTON gDOUBLE , This Button

return

DOUBLE:
{
Gui, Submit, NoHide
if NUMBER = 0
{
msgbox,,Result, Virus Installation Successful
}
double := 2*NUMBER
}

return

GuiClose:
ExitApp
Editd from the 3rd test lol.

:P run it and do what it says, xD kinda something i whipped together in 20 minz :O yes it took me that long >.>

just tired, the IF function is still hard for me to get to work right, goodnight, going to bed, school tommorrow *SIGH*
05/07/2007 06:45 bombica23#35
Quote:
Originally posted by hieitk+May 6 2007, 21:38--></span><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td>QUOTE (hieitk @ May 6 2007, 21:38)</td></tr><tr><td id='QUOTE'> <!--QuoteBegin--bombica23@May 6 2007, 10:36
I made a simple calculator with AutoHtKey.
Very nice man ^^

Where are u from? I see you are using another language for variable names. [/b][/quote]
Ty, I am from Slovenia.

I will try to make it with if when I got from scholl.
05/07/2007 06:52 hieitk#36
@Tinytox
hahah nice rofl
here i added the else statement so you can understand how it works and also there is no need to calculate the double since you are not using it

Code:
DOUBLE&#58;
{
Gui, Submit, NoHide
if NUMBER = 0
{
msgbox,,Result, Virus Installation Successful
}
else
{
msgbox,,Result, Dam I said input a 0
}
}
@bombica23
Slovenia =P cool

okay man, good luck with it ^^
05/07/2007 13:28 bombica23#37
I made in other way.

Here is it.
Code:
deljenje&#58;
{
 Gui, Submit, NoHide
 deljenje &#58;= NUMBER7/NUMBER8
 GuiControl,, RESULT3, %deljenje%
 if NUMBER8 = 0
 {
 msgbox,,Error message, You cannot calculate with %NUMBER8%.
 }
return
}
And here is file. ;)
05/07/2007 19:06 hieitk#38
@bombica23 cool man, yeah that would certainly work

just one thing, you are calculating and changing the element RESULT3 before checking if NUMBER8 is zero, you should check first and if is 0 just show the message but dont calculate or change anything.

@mench here you have potter, is the same as the potter on KIRA2.

Code:
;#READING FROM .ini FILE#
IniRead,winname,pot.ini,GENERAL,winname
IniRead,potkey,pot.ini,POTTER,key
IniRead,potstate,pot.ini,POTTER,state
IniRead,potcolor,pot.ini,POTTER,color
IniRead,potX,pot.ini,POTTER,x
IniRead,potY,pot.ini,POTTER,y


;#POTTER GUI ELEMENTS#
Gui, Add, GroupBox, w220 h68 x15 y10, Pot settings
Gui, Add, Checkbox, x30 y30 vBPOT checked%potstate% gBPOTSTATE, On 
Gui, Add, Text, x85 y30 w45 Left,key&#58; 
Gui, Add, Edit, w30 h19 x112 y28 vBPOTKEY ReadOnly Center, %potkey%
Gui, Add, ComboBox, w50 x147 y27 vBPOTKEYNEW gBPOTNEW, F1|F2|F3|F4|F5|F6|F7|F8|F9|F10
Gui, Add, Button, x110 y50 w87 h20 vBPOTTER gBSETPOTTERon,set hp level

;#SHOW WINDOW#
Gui, Show , w250, KIRA POTTER

return

;#WHEN SET POTTER#
BSETPOTTERon&#58;
{
GuiControl,, BPOTTER, ...
msgbox, Press SHIFT+R to pick hp level
WinActivate , %winname%
SETPOTon &#58;= 1
return
}

;#CHANGE POTTER KEY#
BPOTNEW&#58;
{
Gui, submit, nohide
IniWrite,%BPOTKEYNEW%,pot.ini,POTTER,key
GuiControl,, BPOTKEY, %BPOTKEYNEW%
potkey = %BPOTKEYNEW%
msgbox, Key changed
return
}

;#TURN POTTER ON/OFF#
BPOTSTATE&#58;
{
 if potstate = 1
 {
 potstate &#58;= 0
 IniWrite,%potstate%,pot.ini,POTTER,state
 msgbox, POTTER off
 return
 }
 else
 {
 potstate &#58;= 1
 IniWrite,%potstate%,pot.ini,POTTER,state
 msgbox, POTTER on
 return
 }
}

;#GETTING POT COLOR AND COORDS#

+r&#58;&#58;
{
 if SETPOTon = 1
 {
  WinActivate , %winname%
  IfWinActive , %winname%
  {
  MouseGetPos, potX, potY
  PixelGetColor, potcolor, %potX%, %potY%
  IniWrite,%potcolor%,pot.ini,POTTER,color
  IniWrite,%potX%,pot.ini,POTTER,x
  IniWrite,%potY%,pot.ini,POTTER,y
  GuiControl,, BPOTTER,set hp level
  msgbox, Hp level set
  SETPOTon = 0
  return
  }
  else
  {
  msgbox, Please open %winname% window before pressing SHIFT+R
  SETPOTon = 0
  GuiControl,, BPOTTER,set hp level
  return
  }
 }
 else
 {
 SendInput, r
 return
 }
}

;#EXIT FUNCTION#
+ESC&#58;&#58;
{
sleep, 300
ExitApp
}

;#START FUNCTION#
HOME&#58;&#58;
{
WinActivate , %winname%
sleep, 150
run &#58;= 1
Goto, go
}

;#PAUSE FUNCTION#
END&#58;&#58;
{
run &#58;= 0
Goto, go
}

return


;#MAIN FUNCTION#
go&#58;
{ &#59;*1
  
 Loop
 {&#59;*2
 if run = 0
 {&#59;*3
 break
 }&#59;*3
 else
 {&#59;*3
  IfWinActive , %winname%
  {&#59;*4
  &#59;#POTTER#
   If potstate = 1 
   {&#59;*5
    PixelGetColor, newpotcolor, %potX%, %potY%
    if newpotcolor &#60;> %potcolor%
    {&#59;*6
    Send {%potkey%}
    }&#59;*6
   }&#59;*5
  &#59;#POTTER#
  }&#59;*4
  else if run = 1
  {&#59;*4
  msgbox, please open %winname% before pressing HOME key
  break
  }&#59;*4
 }&#59;*3
 }&#59;*2
return
}&#59;*1

return

;#CLOSE BY PRESSING &#91;X&#93;#
GuiClose&#58; 
ExitApp
you will need a file called pot.ini with this:

Code:
&#91;GENERAL&#93;
winname=&#91;Conquer2.0&#93;
&#91;POTTER&#93;
state=
color=
key=
x=
y=

And here you have attached the result: (.exe plus the .ini file)
Hope it helps
05/07/2007 19:46 bombica23#39
Quote:
Originally posted by hieitk@May 7 2007, 19:06
@bombica23 cool man, yeah that would certainly work

just one thing, you are calculating and changing the element RESULT3 before checking if NUMBER8 is zero, you should check first and if is 0 just show the message but dont calculate or change anything.
Ah I dont have time right now, maybe later. Anyone have idea what should I do for practice?
05/08/2007 01:44 Tinytox#40
Quote:
Originally posted by hieitk@May 7 2007, 06:52
@Tinytox
hahah nice rofl
here i added the else statement so you can understand how it works and also there is no need to calculate the double since you are not using it

Code:
DOUBLE&#58;
{
Gui, Submit, NoHide
if NUMBER = 0
{
msgbox,,Result, Virus Installation Successful
}
else
{
msgbox,,Result, Dam I said input a 0
}
}

okay man, good luck with it ^^
yea >.> i guess i still needa keep learning the basics!

its just, i couldnt figure out how to do it, so i decided to expirement for a LONG time with the variables untill it worked >.>!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

but at least it worked right? XD

_________________________
off topic: hieitk, i am guessing you like naruto to some extent - so watch this :O!

[Only registered and activated users can see links. Click Here To Register...]

this is fun xD

HIEITK DOSENT WANT KARMA PPLZ!!!!!
05/08/2007 02:02 hieitk#41
@Tyinitox rofl man, ur post are so weird lmao

I already saw that thing of the Uber Hax huahau so funny man lol
I have a .gif on my desk with that thing =P

one more thing, please delete that thing of give... and also stop giving me karma xD u already gave me like 5 huahsauh

ah almost forgot, imma put another lesson on how to write/read from .ini/.txt files ^^

remember, delete that >.<
05/08/2007 02:31 hieitk#42
(12)Reading and writing into a .ini file :
12.1 Introduction:
In this sample we're going to learn how to write and read from a .ini file or even a .txt file.
12.2 The .ini file:
Create a file on NOTEPAD with this:
Code:
&#91;NAMEOFSECTION&#93;
nameofkey=abc
anotherkey=123
&#91;ANOTHERSECTION&#93;
lastkey=xyz
And save it as settings.ini
This is the file we're going to use as sample

12.3 The code:
Lets open NOTEPAD and copy the next code
Quote:

;#SAMPLE READ WRITE ON INI FILE#

;#READING FROM INI FILE#
IniRead,data_one,settings.ini,NAMEOFSECTION,nameof key
IniRead,data_two,settings.ini,NAMEOFSECTION,anothe rkey
IniRead,data_three,settings.ini,ANOTHERSECTION,las tkey

;#CREATE THE WINDOW#
Gui, Show , w200 h150, Ini reader

;#TEXTS#
Gui, Add, Text, x10 y10 Left, Data 1
Gui, Add, Text, x10 y35 Left, Data 2
Gui, Add, Text, x10 y60 Left, Data 3

;#EDITS (TEXT ENTRIES)#
Gui, Add, Edit, x60 y10 w80 vNEWDATA1 Left,%data_one%
Gui, Add, Edit, x60 y35 w80 vNEWDATA2 Left,%data_two%
Gui, Add, Edit, x60 y60 w80 vNEWDATA3 Left,%data_three%

;#BUTTONS#
Gui, Add, Button, x20 y90 w80 gSAVECHANGES Left,Save changes

return

;#MAIN FUNCTION#
SAVECHANGES:
{
Gui, Submit, NoHide
IniWrite,%NEWDATA1%,settings.ini,NAMEOFSECTION,nam eofkey
IniWrite,%NEWDATA2%,settings.ini,NAMEOFSECTION,ano therkey
IniWrite,%NEWDATA3%,settings.ini,ANOTHERSECTION,la stkey
msgbox,,Result, Data saved thx
return
}


GuiClose:
ExitApp
Let's see whats new ^^
-------------------------------------------------------
Code:
;#SAMPLE READ WRITE ON INI FILE#
Only a comment since it has ; at the beggining, I use # because is easier for me to see it that way.
-------------------------------------------------------
Code:
;#READING FROM INI FILE#
IniRead,data_one,settings.ini,NAMEOFSECTION,nameofkey
IniRead,data_two,settings.ini,NAMEOFSECTION,anotherkey
IniRead,data_three,settings.ini,ANOTHERSECTION,lastkey
The first line is a comment too ^^
And then we have 3 lines that do the same but with different values, lets see the structure of the IniRead

IniRead,OUTPUT_VAR,NAME_OF_FILE,NAME_OF_SECTION,NA ME_OF_KEY
OUTPUT_VAR: then name of the variable to save the value
NAME_OF_FILE: is the name of the ini file(in this case settings.ini)
NAME_OF_SECTION: the sections on the .ini file are those between []
NAME_OF_KEY: one of the key names under the SECTION.

For example on
IniRead,data_one,settings.ini,NAMEOFSECTION,nameof key
data_one: the variable to save the initial value "abc"
settings.ini: the name of the ini file
NAMEOFSECTION: The first section on the ini file.
nameofkey: the first key under the NAMEOFSECTION section

-------------------------------------------------------
Code:
;#TEXTS#
Gui, Add, Text, x10 y10 Left, Data 1
Gui, Add, Text, x10 y35 Left, Data 2
Gui, Add, Text, x10 y60 Left, Data 3
Just some text to display, nothing new
-------------------------------------------------------
Code:
;#EDITS &#40;TEXT ENTRIES&#41;#
Gui, Add, Edit, x60 y10 w80 vNEWDATA1 Left,%data_one% 
Gui, Add, Edit, x60 y35 w80 vNEWDATA2 Left,%data_two% 
Gui, Add, Edit, x60 y60 w80 vNEWDATA3 Left,%data_three%
Here we are creating some Edits, they will display the values saved into the ini file, thats why we put %name_of_var%
-------------------------------------------------------
Code:
;#BUTTONS#
Gui, Add, Button, x20 y90 w80 gSAVECHANGES Left,Save changes

return
Here we create a button that will call the subrutine SAVECHANGES
-------------------------------------------------------
Code:
SAVECHANGES&#58;
{
Gui, Submit, NoHide
IniWrite,%NEWDATA1%,settings.ini,NAMEOFSECTION,nameofkey
IniWrite,%NEWDATA2%,settings.ini,NAMEOFSECTION,anotherkey
IniWrite,%NEWDATA3%,settings.ini,ANOTHERSECTION,lastkey
msgbox,,Result, Data saved thx
return
}
Now the main function or rutine, first we submit the values of all Gui elements as Edits.
That means that now the variable NEWDATA1 have the value the user wrote into the first edit.

The code IniWrite have almost the same structure as IniRead
The only difference is the second element, instead of OUTPUT_VAR is the VALUE_TO_SAVE

IniWrite,VALUE_TO_SAVE,settings.ini,NAMEOFSECTION, nameofkey
We have to use %% symbols to call the variable.

As example,
IniWrite,%NEWDATA3%,settings.ini,ANOTHERSECTION,la stkey
means we are saving the value of the variable NEWDATA3 into the file settings.ini under the section ANOTHERSECTION on the key lastkey

Finally a message to the user telling him the data was saved ^^
-------------------------------------------------------
Code:
GuiClose&#58; 
ExitApp
As usual.
-------------------------------------------------------
Alright ^^ hope u understand
05/08/2007 05:39 AvatarOfMight#43
Hi again :D

I need some help here pls.... I am having trouble making my mining bot :cry: .
I have been trying to make it all the weekend and all the afternoon of today... I am giving up for tonite cuz its late and I gotta sleep but I will keep tryin tomorrow.
Here is what I have untill now... If anyone have time and is willing to help a noob pls read it and let me know if you find out anything wrong with it.

AURUM CODE

Quote:
;creación del GUI---Creates Gui

Gui, Show , w220 h160, Aurum
Gui, Add, Text, x10 y10 w150 Left,Welcome to AURUM
Gui, Add, Button, x80 y40 w60 h20 vSTARTBUTTON gMINE ,start
Gui, Add, Checkbox, x10 y80 vDROPGOLDORE,drop gold ores
Gui, Add, Checkbox, x10 y100 vDROPSILVERORE,drop silver ores
Gui, Add, Checkbox, x100 y80 vDROPCOPPERORE,drop copper ores
Gui, Add, Checkbox, x100 y100 vDROPIRONORE,drop iron ores
Gui, Add, Text, x10 y120 w200 Left,press ctrl+alt+c to set initial coords
Gui, Add, Text, x10 y140 w200 Left,press ctrl+alt+s to exit the program

return
;-----------------------------------------------------------------------
^!S::
{
MsgBox,Thanks for using aurum :) c u next time
ExitApp
return
}
;-----------------------------------------------------------------------
;Código para buscar ores---Ore searcher code

^!C::
{
;Posicion inicial de la ventana---Initial Window position
MouseGetPos,IPosX, IPosY
MsgBox,Initial coords: %IPosY% %IPosX%
return
}

MINE:
{

MsgBox,The bot will begin in 3 seconds
Sleep,3000

InitialcoordX:=IposX
Initialcoordy:=IposY

FposX:=IPosX+43
FPosY:=IPosY+43


;Copper Ore
MINING:
{
loop,40
{
Pixelsearch, CopperX, CopperY, %IPosX%,%IPosY%,%FPosX%,%FPosY%,0xDEEFF,10
if ErrorLevel
{
;Iron Ore
Pixelsearch, IronX, IronY, %IPosX%,%IPosY%,%FPosX%,%FPosY%,Ox525152,10
If ErrorLevel
{
;Silver Ore
Pixelsearch, SilverX, SilverY, %IPosX%,%IPosY%,%FPosX%,%FPosY%,Ox5C5B5D,10
If ErrorLevel
{
;gold Ore
Pixelsearch, GoldX, GoldY, %IPosX%,%IPosY%,%FPosX%,%FPosY%,Ox07365C,10
If ErrorLevel
{
;scroll
Pixelsearch, ScrollX, ScrollY, %IPosX%,%IPosY%,%FPosX%,%FPosY%,Ox31458C,10
If ErrorLevel<>1
{
;Move to next box in item box
Gosub, Next
}
else
{

Click left, %scrollX% %scrollY%
Sleep, 1000
Click left, 515,482
Gosub, Next

}
}
else
{
Gosub, Dropgoldore
Gosub, Next
}
}
else
{
Gosub, Dropsilverore
Gosub, Next
}
}
else
{
Gosub, Dropironore
Gosub, Next
}
}
else
{
Gosub, Dropcopperore
Gosub, Next
}
}
return
}
;Sleep,10000
Gosub, MINING


}
;-----------------------------------------------------------------------
;FUNCTIONS
OresTirados:=0
Next:
{
IPosX:=IposX+43
If IposX>=(172+InitialcoordX)
{
IPosX:=InitialcoordX
IPosY:=IPosY+43
}
If IposY>=(1849+InitialcoordY)
{
IPosX:=InitialcoordX
IPosY:=InitialcoordY
}
FPosX:=FposX+43
If FposX>=(172+43+InitialcoordX)
{
FPosX:=InitialcoordX+43
FPosY:=FPosY+43
}
If FposY>=(1849+43+InitialcoordY)
{
FPosX:=InitialcoordX+43
FPosY:=InitialcoordY+43
}

return
}

Drop:
{
mouseclickx:=(IPosX+21)
mouseclicly:=(IPosY+21)
click left,%moseclickx%,%mouseclicky%
Sleep,1000
Click left, 515,482
OresTirados:=OresTirados+1
If OresTirados>=9
{
click left, 515,482
Sleep,1000
Click right, 515,482
OresTirados:=0
}
return
}
Dropgoldore:
{
If DROPGOLDORE Checked
{
Gosub, Drop
Gosub, Next
}
else
{
Gosub, Next
}
return

}
Dropsilverore:
{
If DROPSILVERORE Checked
{
Gosub, Drop
Gosub, Next
}
else
{
Gosub, Next
}
return

}
Dropironore:
{
If DROPIRONORE Checked
{
Gosub, Drop
Gosub, Next
}
else
{
Gosub, Next
}
return
}
Dropcopperore:
{
If DROPCOPPERORE Checked
{
Gosub, Drop
Gosub, Next
}
else
{
Gosub, Next
}
return
}


return

GuiClose:
ExitApp
O.o my post is loooooong.... lol. Sorry
Thanks in advance :D
05/08/2007 05:57 hieitk#44
@AvatarOfMight
wow yeah a bit long xD
I checked the whole code so take a look at my scanning result lol

Complete scanning result of "AURUM", wrote by Hieitk at May 08 2007
>suggestions and problems on red
>comments on green
>important change on blue

Quote:

;creación del GUI---Creates Gui

Gui, Show , w220 h160, Aurum
Gui, Add, Text, x10 y10 w150 Left,Welcome to AURUM
Gui, Add, Button, x80 y40 w60 h20 vSTARTBUTTON gMINE ,start
Gui, Add, Checkbox, x10 y80 vDROPGOLDORE,drop gold ores
Gui, Add, Checkbox, x10 y100 vDROPSILVERORE,drop silver ores
Gui, Add, Checkbox, x100 y80 vDROPCOPPERORE,drop copper ores
Gui, Add, Checkbox, x100 y100 vDROPIRONORE,drop iron ores
Gui, Add, Text, x10 y120 w200 Left,press ctrl+alt+c to set initial coords
Gui, Add, Text, x10 y140 w200 Left,press ctrl+alt+s to exit the program

return
;-----------------------------------------------------------------------
^!S::
{
MsgBox,Thanks for using aurum* c u next time
sleep, 100* ;#now it will close better#
ExitApp
return* ;#no need#
}
;-----------------------------------------------------------------------
;Código para buscar ores---Ore searcher code

^!C::
{
;Posicion inicial de la ventana---Initial Window position
MouseGetPos,IPosX, IPosY
MsgBox,Initial coords: %IPosY% %IPosX%
return
}
*
MINE:
{

* MsgBox,The bot will begin in 3 seconds
* Sleep,3000

* InitialcoordX:=IposX
* Initialcoordy:=IposY

;this should be after MINING and before the loop, read below so u understand why
* FposX:=IPosX+43 <<
* FPosY:=IPosY+43 <<

;it will check one square at the time before gosub,next

* ;Copper Ore
* MINING:
* {
* * loop,40
* * {
* * Pixelsearch, CopperX, CopperY, %IPosX%,%IPosY%,%FPosX%,%FPosY%,0xDEEFF,10
* * if ErrorLevel
* * {
* * * ;Iron Ore
* * * Pixelsearch, IronX, IronY, %IPosX%,%IPosY%,%FPosX%,%FPosY%,Ox525152,10*
;WHOPS is an "o" instead of a zero
* * * If ErrorLevel
* * * {
* * * ;Silver Ore
* * * Pixelsearch, SilverX, SilverY, %IPosX%,%IPosY%,%FPosX%,%FPosY%,Ox5C5B5D,10
;same here
* * * If ErrorLevel
* * * {
* * * * ;gold Ore
* * * * Pixelsearch, GoldX, GoldY, %IPosX%,%IPosY%,%FPosX%,%FPosY%,Ox07365C,10
;and here
* * * * If ErrorLevel
* * * * {
* * * * ;scroll
* * * * * Pixelsearch, ScrollX, ScrollY, %IPosX%,%IPosY%,%FPosX%,%FPosY%,Ox31458C,10*
;and here xD
;this is like saying IF NO ERROR
* * * * If ErrorLevel<>1
* * * * {
* * * * * ;Move to next box in item box
* * * * * Gosub, Next
* * * * }
;then this else means IF ERROR in that case u wont have ScrollX and ScrollY values unless u have some old values from a previous successful search
* * * * else
* * * * {
*
* * * * * Click left, %scrollX% %scrollY%
* * * * * Sleep, 1000
* * * * * Click left, 515,482
* * * * * Gosub, Next

* * * * }
* * * * }
* * * * else
* * * * {
* * * * Gosub, Dropgoldore
* * * * Gosub, Next
;whops if drops then you should check the same box again instead of going to the Next one
* * * * }
* * * }
* * * else
* * * {
* * * Gosub, Dropsilverore
* * * Gosub, Next
;same here
* * * }
* * * }
* * * else
* * * {
* * * Gosub, Dropironore
* * * Gosub, Next
;and here
* * * }
* * }
* * else
* * {
* * * Gosub, Dropcopperore
* * * Gosub, Next
;and here
* * }
* * }
* return
* }
* ;Sleep,10000

after it reach 40 times it will start again so if u restart the vars IPosX and IPosY there u wont have to check max and min height
Besides! since you will delete some lines so the program wont go to next after droping something you will end checking 40 items before reaching the max width and height*
One more thing I almost forgot, you could add a pixelsearch for empty boxes and assign A_Index = 40 so it will start from the box1 when it finds an empty box, if not it will check all 40 even if they are empty
* Gosub, MINING


}
;-----------------------------------------------------------------------
;FUNCTIONS
OresTirados:=0** ;the program wont read this line *1
Next:
{
IPosX:=IposX+43
no need to any if to check max X and Y if you move IPosX and IPoxY first assignation afterMINING subrutine and before the loop
If IposX>=(172+InitialcoordX)
{
* IPosX:=InitialcoordX
* IPosY:=IPosY+43
}
If IposY>=(1849+InitialcoordY)
;I think the height of the inventory window is not that big (1849 pixels) =/
{
* IPosX:=InitialcoordX
* IPosY:=InitialcoordY
}
FPosX:=FposX+43
If FposX>=(172+43+InitialcoordX)
{
* FPosX:=InitialcoordX+43
* FPosY:=FPosY+43
}
If FposY>=(1849+43+InitialcoordY)
{
* FPosX:=InitialcoordX+43
* FPosY:=InitialcoordY+43
}

return
}

Drop:
{
mouseclickx:=(IPosX+21)
mouseclicly:=(IPosY+21) ;missed a "k", is clic
;because here u r calling it as click
click left,%moseclickx%,%mouseclicky%*
Sleep,1000
Click left, 515,482
;dunno what will happen here because of *1
OresTirados:=OresTirados+1
;great idea man
If OresTirados>=9
{
* click left, 515,482
* Sleep,1000
* Click right, 515,482
* OresTirados:=0
}
return
}
Dropgoldore:
{
If DROPGOLDORE Checked
{
* Gosub, Drop
;again u should check the same box instead of going to the next and! you are calling the subrutine twice, here and on the subrutine MINING
* Gosub, Next
}
else
{
;calling next twice here too because u wrote
Code:
Gosub, Dropgoldore
Gosub, Next
so it comes to Dropgoldore, and if dropgoldore is not checked go to next, then go back after doing the next routine and read Gosub,Next so it do it again

* Gosub, Next
}
return

}
Dropsilverore:
{
If DROPSILVERORE Checked
{
* Gosub, Drop
;calling next twice
* Gosub, Next
}
else
{
;calling next twice
* Gosub, Next

}
return

}
Dropironore:
{
If DROPIRONORE Checked
{
* Gosub, Drop
;calling next twice
* Gosub, Next
}
else
{
;calling next twice
* Gosub, Next
}
return
}
Dropcopperore:
{
If DROPCOPPERORE Checked
{
* Gosub, Drop
;calling next twice
* Gosub, Next
}
else
{
;calling next twice
* Gosub, Next
}
return
}


return

GuiClose:
ExitApp
Even if u made some mistakes I have to say congratulations!, you really though about everything man, I want to see this running =P
05/08/2007 06:33 mench#45
Quote:
Originally posted by hieitk@May 7 2007, 19:06
@bombica23 cool man, yeah that would certainly work

just one thing, you are calculating and changing the element RESULT3 before checking if NUMBER8 is zero, you should check first and if is 0 just show the message but dont calculate or change anything.

@mench here you have potter, is the same as the potter on KIRA2.

Code:
;#READING FROM .ini FILE#
IniRead,winname,pot.ini,GENERAL,winname
IniRead,potkey,pot.ini,POTTER,key
IniRead,potstate,pot.ini,POTTER,state
IniRead,potcolor,pot.ini,POTTER,color
IniRead,potX,pot.ini,POTTER,x
IniRead,potY,pot.ini,POTTER,y


;#POTTER GUI ELEMENTS#
Gui, Add, GroupBox, w220 h68 x15 y10, Pot settings
Gui, Add, Checkbox, x30 y30 vBPOT checked%potstate% gBPOTSTATE, On 
Gui, Add, Text, x85 y30 w45 Left,key&#58; 
Gui, Add, Edit, w30 h19 x112 y28 vBPOTKEY ReadOnly Center, %potkey%
Gui, Add, ComboBox, w50 x147 y27 vBPOTKEYNEW gBPOTNEW, F1|F2|F3|F4|F5|F6|F7|F8|F9|F10
Gui, Add, Button, x110 y50 w87 h20 vBPOTTER gBSETPOTTERon,set hp level

;#SHOW WINDOW#
Gui, Show , w250, KIRA POTTER

return

;#WHEN SET POTTER#
BSETPOTTERon&#58;
{
GuiControl,, BPOTTER, ...
msgbox, Press SHIFT+R to pick hp level
WinActivate , %winname%
SETPOTon &#58;= 1
return
}

;#CHANGE POTTER KEY#
BPOTNEW&#58;
{
Gui, submit, nohide
IniWrite,%BPOTKEYNEW%,pot.ini,POTTER,key
GuiControl,, BPOTKEY, %BPOTKEYNEW%
potkey = %BPOTKEYNEW%
msgbox, Key changed
return
}

;#TURN POTTER ON/OFF#
BPOTSTATE&#58;
{
 if potstate = 1
 {
 potstate &#58;= 0
 IniWrite,%potstate%,pot.ini,POTTER,state
 msgbox, POTTER off
 return
 }
 else
 {
 potstate &#58;= 1
 IniWrite,%potstate%,pot.ini,POTTER,state
 msgbox, POTTER on
 return
 }
}

;#GETTING POT COLOR AND COORDS#

+r&#58;&#58;
{
 if SETPOTon = 1
 {
 * WinActivate , %winname%
 * IfWinActive , %winname%
 * {
 * MouseGetPos, potX, potY
 * PixelGetColor, potcolor, %potX%, %potY%
 * IniWrite,%potcolor%,pot.ini,POTTER,color
 * IniWrite,%potX%,pot.ini,POTTER,x
 * IniWrite,%potY%,pot.ini,POTTER,y
 * GuiControl,, BPOTTER,set hp level
 * msgbox, Hp level set
 * SETPOTon = 0
 * return
 * }
 * else
 * {
 * msgbox, Please open %winname% window before pressing SHIFT+R
 * SETPOTon = 0
 * GuiControl,, BPOTTER,set hp level
 * return
 * }
 *}
 *else
 *{
 *SendInput, r
 *return
 *}
}

;#EXIT FUNCTION#
+ESC&#58;&#58;
{
sleep, 300
ExitApp
}

;#START FUNCTION#
HOME&#58;&#58;
{
WinActivate , %winname%
sleep, 150
run &#58;= 1
Goto, go
}

;#PAUSE FUNCTION#
END&#58;&#58;
{
run &#58;= 0
Goto, go
}

return


;#MAIN FUNCTION#
go&#58;
{&#59;*1
 * 
 Loop
 {;*2
 if run = 0
 {;*3
 break
 };*3
 else
 {;*3
 * *IfWinActive , %winname%
 * *{;*4
 *&#59;#POTTER#
 * * If potstate = 1 
 * * {;*5
 * * * PixelGetColor, newpotcolor, %potX%, %potY%
 * * * if newpotcolor &#60;> %potcolor%
 * * * {;*6
 * * * Send {%potkey%}
 * * * };*6
 * * };*5
 *&#59;#POTTER#
 * *};*4
 * *else if run = 1
 * *{;*4
 * *msgbox, please open %winname% before pressing HOME key
 * *break
 * *};*4
 };*3
 };*2
return
};*1

return

;#CLOSE BY PRESSING &#91;X&#93;#
GuiClose&#58; *
ExitApp
you will need a file called pot.ini with this:

Code:
&#91;GENERAL&#93;
winname=&#91;Conquer2.0&#93;
&#91;POTTER&#93;
state=
color=
key=
x=
y=

And here you have attached the result: (.exe plus the .ini file)
Hope it helps
Wowww cool man.. Thanks A lot

:bandit:

Karma for you