Register for your free account! | Forgot your password?

Go Back   elitepvpers > MMORPGs > Conquer Online 2
You last visited: Today at 07:08

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



GUI Button function w/ autoit

Discussion on GUI Button function w/ autoit within the Conquer Online 2 forum part of the MMORPGs category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Dec 2005
Posts: 48
Received Thanks: 34
GUI Button function w/ autoit

kk im a newbie at makin bots but heres the code i have now...
okay im a TOTAL newb at making stuff with autoit, so far i can only make simple things with clicking and what not...but i ran into a problem today. my bot creates a gui that instructs you on how to use the bot, what i need help with is how to create a hotkey that "Starts" the bot(the opposite of the exiting hotkey)
HotKeySet("^!x", "QuitProg")
Func QuitProg()
Exit
EndFunc
thats the exit hotkey that i got, but i was wondering if its possible to reverse it, and have a 2nd code like dat but it starts instead of exits....ty
joshsta911 is offline  
Old 01/01/2009, 06:53   #2
 
elite*gold: 0
Join Date: Feb 2008
Posts: 1,590
Received Thanks: 154
From what I know of Win32, you have to handle the WM_COMMAND message for the button.(Windows will throw the message when the button is pushed) You'll have to assign the buttons ID and etc, and when you handle the WM_COMMAND message, check if it's the ID of the button and then execute your next code.

Don't ask how to do it in AutoIt though...


Edit:: Woah, you totally changed the first post....
I dunno anything about AutoIt so I guess ask swords or Hiyoal..
tao4229 is offline  
Old 01/01/2009, 08:29   #3
 
elite*gold: 0
Join Date: Dec 2005
Posts: 48
Received Thanks: 34
rofl thanks for trying to help but you Totally lost me, it seems like it should be simple as hell becuase its just simply like this:
Person clicks the button then it should endswitch/closewindow and then move onto the next line..wich is the bot
joshsta911 is offline  
Old 01/01/2009, 11:33   #4
 
Hiyoal's Avatar
 
elite*gold: 20
Join Date: Mar 2007
Posts: 2,444
Received Thanks: 1,066
Ok. So are you using another hotkey for this?! Or are you using the same hotkey?

Hiyoal
Hiyoal is offline  
Old 01/02/2009, 03:01   #5
 
elite*gold: 0
Join Date: Dec 2005
Posts: 48
Received Thanks: 34
no, ctrl+alt+x = exit script
and, ctrl+alt+z = start

i was thinking..is there a way that when you start the script from clicking it, it automatically pauses the script untill a hotkey is executed such as my "start"(ctr+alt+z)??
joshsta911 is offline  
Old 01/02/2009, 03:12   #6
 
Hiyoal's Avatar
 
elite*gold: 20
Join Date: Mar 2007
Posts: 2,444
Received Thanks: 1,066
Until the GUI Pops up?!
Lets have a look at your script.

Hiyoal
Hiyoal is offline  
Old 01/02/2009, 03:23   #7
 
elite*gold: 0
Join Date: Dec 2005
Posts: 48
Received Thanks: 34
okay well since your here now and your wonderfull help i hope you wouldnt mind awnser another question at the same time :P
but heres my script

This script is to where a msg pops up with instructions, you minimize it and then press the hotkey CTRL+ALT+Z,(Idont have that part in yet becuase i dont know how to make it)
PHP Code:
HotKeySet("^!x""QuitProg")
Func QuitProg()
    Exit
EndFunc
#include <GUIConstants.au3>

#Region ### START Koda GUI section ### Form=
$ToxicFogLvler GUICreate("ToxicFogLvler"415170, -1, -1)
GUISetBkColor(0xC0C0C0)
$Label1 GUICtrlCreateLabel("This bot was created to level your ninja's Toxic Fog skill"0033320)
GUICtrlSetFont(-1104000"MS Sans Serif")
$Label2 GUICtrlCreateLabel("Created By Joshsta"2406414324)
GUICtrlSetFont(-1124008"MS Sans Serif")
$Label3 GUICtrlCreateLabel("To exit this bot simply hit CTRL+ALT+X"01627020)
GUICtrlSetFont(-1108000"MS Sans Serif")
$Label4 GUICtrlCreateLabel("Instructions:"0487320)
GUICtrlSetFont(-1104000"MS Sans Serif")
$Label5 GUICtrlCreateLabel("Sit = F3"0644017)
$Label6 GUICtrlCreateLabel("Have your toxic fog SKILL selected"08017117)
$Label7 GUICtrlCreateLabel("To start bot hit CTRL+ALT+Z"03216917)
GUICtrlSetFont(-188000"MS Sans Serif")
$Label8 GUICtrlCreateLabel("Make sure to minimize this window before starting!"2412834720)
GUICtrlSetFont(-1108004"MS Sans Serif")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg 
GUIGetMsg()
    Switch 
$nMsg
        
Case $GUI_EVENT_CLOSE
            
Exit

        Case 
$ToxicFogLvler
    
EndSwitch
WEnd 
and heres a simple question i have, its the same script just instead its worked with a button instead of a hotkey to start it..
PHP Code:
HotKeySet("^!x""QuitProg")
Func QuitProg()
    Exit
EndFunc
#include <GUIConstants.au3>

#Region ### START Koda GUI section ### Form=c:\users\josh\desktop\botmakingshit\toxicfogbotcreatedbyjoshsta.kxf
$ToxicFogBot GUICreate("ToxicFogBot"349151, -1, -1)
GUISetBkColor(0xC8C8C8)
$Button1 GUICtrlCreateButton("Start"1204810557)
$Label1 GUICtrlCreateLabel("Created By Joshsta"21912812120)
GUICtrlSetFont(-1104000"MS Sans Serif")
$Label2 GUICtrlCreateLabel("The bot will start when you click Start.."0018617)
$Label3 GUICtrlCreateLabel("To exit the bot simply hit CTRT+ALT+X"01618817)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg 
GUIGetMsg()
    Switch 
$nMsg
        
Case $GUI_EVENT_CLOSE
            
Exit

        Case 
$Button1
    
EndSwitch
WEnd

While 1
MouseClick
("left" 57838821)
Sleep(1200)
MouseClick("right" 63545711)
Sleep(1200)
MouseClick("left" 69738721)
Send("{F3}")
Sleep(6000)
WEnd 
the problem with this bot is that when i click the button nothing happends, the "Window(gui)" that pops up dosnt go away when i click on $Button1 AkA Start...i dont know how to make it move onto the next part of the script thnx 4 ure help
joshsta911 is offline  
Old 01/02/2009, 03:51   #8
 
Hiyoal's Avatar
 
elite*gold: 20
Join Date: Mar 2007
Posts: 2,444
Received Thanks: 1,066
Lol, Ok. Ill start off with the basics
Start off with #Include <> at the START OF YOUR SCRIPT!!!

A HotKeySet() Function does not need to be declared with a function underneath.

You can set however many hotkeys at the start of your script.

Quote:
Originally Posted by Hiyoal
#include <GUIConstants.au3>
HotKeySet("^!x", "QuitProg")
HotKeySet("^!z","StartProg")

#Region ### START Koda GUI section ### Form=
$ToxicFogLvler = GUICreate("ToxicFogLvler", 415, 170, -1, -1)
GUISetBkColor(0xC0C0C0)
$Label1 = GUICtrlCreateLabel("This bot was created to level your ninja's Toxic Fog skill", 0, 0, 333, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Label2 = GUICtrlCreateLabel("Created By Joshsta", 240, 64, 143, 24)
GUICtrlSetFont(-1, 12, 400, 8, "MS Sans Serif")
$Label3 = GUICtrlCreateLabel("To exit this bot simply hit CTRL+ALT+X", 0, 16, 270, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$Label4 = GUICtrlCreateLabel("Instructions:", 0, 48, 73, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Label5 = GUICtrlCreateLabel("Sit = F3", 0, 64, 40, 17)
$Label6 = GUICtrlCreateLabel("Have your toxic fog SKILL selected", 0, 80, 171, 17)
$Label7 = GUICtrlCreateLabel("To start bot hit CTRL+ALT+Z", 0, 32, 169, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$Label8 = GUICtrlCreateLabel("Make sure to minimize this window before starting!", 24, 128, 347, 20)
GUICtrlSetFont(-1, 10, 800, 4, "MS Sans Serif")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd

Func QuitProg()
Exit
EndFunc

Func StartProg()
;Put Your Function Here
EndFunc
Now, for the GUI.

You cannot have 2 While loops happening at once. The first one from top to bottom of the script will run first, so your:

Quote:
While 1
MouseClick()
jadslkfja;f
Wend
That will never happen unless the first WHile loop is exitted using Exitloop.


You dont have anything which the button does.

Switch looks at the variable $nMsg and checks to see if it changes.
If $button1 is clicked, $nMsg=$button1 sooo

Switch will move down to:
Case $button1

If their is one.

So, if you want those button clicks, you should do this.
Quote:
Originally Posted by Hiyoal
#include <GUIConstants.au3>
HotKeySet("^!x", "QuitProg")
HotKeySet("^!z","StartProg")

Global $checker=0 ;<--- DECLARE THIS!!

#Region ### START Koda GUI section ### Form=c:\users\josh\desktop\botmakingshit\toxicfogb otcreatedbyjoshsta.kxf
$ToxicFogBot = GUICreate("ToxicFogBot", 349, 151, -1, -1)
GUISetBkColor(0xC8C8C8)
$Button1 = GUICtrlCreateButton("Start", 120, 48, 105, 57)
$Label1 = GUICtrlCreateLabel("Created By Joshsta", 219, 128, 121, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Label2 = GUICtrlCreateLabel("The bot will start when you click Start..", 0, 0, 186, 17)
$Label3 = GUICtrlCreateLabel("To exit the bot simply hit CTRT+ALT+X", 0, 16, 188, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
I have also declared the variable $checker=0 GLOBALLY so that it can be used throughout the whole script.

Then you should write the While function so the script stays alive:

Quote:
Originally Posted by Hiyoal
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit

Case $Button1
EndSwitch
WEnd
Next we add the function for clicking the button and we make our own Function which loops clicking.

Quote:
Originally Posted by Hiyoal
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit

Case $Button1
if $checker=0 then
$checker=1
elseif $checker=1 then
$checker=0
endif
EndSwitch

If $checker=1 Then
StartProg()
EndIf

WEnd

Func StartProg()
MouseClick("left" , 578, 388, 2, 1)
Sleep(1200)
MouseClick("right" , 635, 457, 1, 1)
Sleep(1200)
MouseClick("left" , 697, 387, 2, 1)
Send("{F3}")
Sleep(6000)
EndFunc
When the button is clicked, $checker is set to "1" and then the function "StartFunc" is called because in the:
While 1

Wend

loop, it checks to see if $checker=1 and will keep on running until the button on the GUI is pressed again.
Because, when $x=1 when button1 is pressed, it checks to see what $checker is and if it is 0 then it starts the bot, otherwise it see's whether $checker=1 and if it is then it makes it ="0" and will skip the:

If $checker=1 Then
StartProg()
EndIf

because $checker=0

Hope thats some insight.

Hiyoal
Hiyoal is offline  
Thanks
1 User
Old 01/02/2009, 04:20   #9
 
elite*gold: 0
Join Date: Dec 2005
Posts: 48
Received Thanks: 34
oh snap, im not gonna lie i dont understand half of that. but from what i do understand, i understand what you did with the ctrl+alt+z, i also found out another way for this to work..
PHP Code:
Case $Button1
    GUISetState
(@SW_HIDE)
EndSwitch
WEnd 
so basically once they click start it just hides the gui and stops the switch, and they go on to pressing ctrl+alt+z to start the bot...! right? lol
joshsta911 is offline  
Old 01/02/2009, 04:23   #10
 
elite*gold: 0
Join Date: Dec 2005
Posts: 48
Received Thanks: 34
Btw is there a way that i can loop this function, after you click ctrl+alt+z
sorry if i wasted your time, id rather do it this way becuase i actually understand it sort of lol :x

PHP Code:
Func StartProg()
MouseClick("left" 57838821)
Sleep(1200)
MouseClick("right" 63545711)
Sleep(1200)
MouseClick("left" 69738721)
Send("{F3}")
Sleep(6000)
EndFunc 
joshsta911 is offline  
Old 01/02/2009, 04:24   #11
 
Hiyoal's Avatar
 
elite*gold: 20
Join Date: Mar 2007
Posts: 2,444
Received Thanks: 1,066
Or, you can start the bot from clicking aswell.

PHP Code:
Case $button1
GUISetState
(@SW_HIDE)
StartProg()
EndSwitch
Wend 
Hiyoal

<edit>

Yes you can:

Declare Global $checker=0 at the start of your script

PHP Code:
Func StartProg()
if 
$checker=1 then
$checker
=0
elseif $checker=0 Then
$checker
=1
endIf
While 
$checker=1
MouseClick
("left" 57838821)
Sleep(1200)
MouseClick("right" 63545711)
Sleep(1200)
MouseClick("left" 69738721)
Send("{F3}")
Sleep(6000)
Wend
EndFunc 
This checks and see's whether $checker=1 or 0. If it equals to 0 then it makes $checker=1 and the while loop starts because $checker=1. When the hotkey is pressed again $checker=1 so it makes $checker=0 and the while stops, because While only runs when $checker=1.

Hiyoal
Hiyoal is offline  
Thanks
1 User
Old 01/02/2009, 04:46   #12
 
elite*gold: 0
Join Date: Dec 2005
Posts: 48
Received Thanks: 34
oky fixed my hotkey situation Thanks alot Hiyoal, i spent a long time on this last nightl; just trying to get the gui function to work, it now works exacally how i want it, when i repost it ill make sure to give you credit
joshsta911 is offline  
Old 01/02/2009, 05:55   #13
 
Hiyoal's Avatar
 
elite*gold: 20
Join Date: Mar 2007
Posts: 2,444
Received Thanks: 1,066
Np, glad 2 help. Hope i taught u something aswell

Hiyoal
Hiyoal is offline  
Reply


Similar Threads Similar Threads
autoit function alle x minuten ausführen
05/02/2010 - AutoIt - 6 Replies
Hallo, ist es möchlich eine funktion alle x minuten auszuführen und gleichzeitig das programm weiter laufen zu lassen also sowas in der art blabla() ;funktion soll alle 2 sekunden ausgeführt werden blub() ; funktion soll alle 4 sekunden ausgeführt werden MfG Lukas
guild function button
10/23/2009 - Dekaron - 3 Replies
im still crashing when i mouse over he function button in my guild, our yall still having the same problem? because i have uber amount of AP im wanting to donate. And if ur having same problem, know when the will get around to fixing it?
Need help to add 2 Function in bot build on Autoit
09/13/2009 - AutoIt - 6 Replies
Hey All, How are you..?! Hope be good I wanna help to add 2 Function in bot build on Autoit The bot which i need to add on it at attachment This bot maked Bywildspirit n this topic of bot here So i ask if any one can help me to add function that stop this Bot after 3h ..? (i mean like Timer)(It's like Howl interval in this bot) Coz i hate to take spwen to myself only By using Auto Howl Although my bag Full. -Press ctrl+a (always) coz auto grab is very slow.. PLz Bro if Any one...
AutoIt Button
04/17/2008 - General Coding - 1 Replies
Hi, ich habe mir mal nen pickup bot erstellt mit nem button der funct aber ich möchte noch ein button hinzufügen für AutoSend und Fish Bot Und so habe ich mein erster Butto erstellt aber ich gebe genau das gleiche ein aber es kommt kein 2 button warumP? Und ich möchte halt noch nen buton erstellen das der pick up ausgeht wie geht das?? ------------------------------------------------ #include <GUIConstants.au3> GUICreate("AmelieMaus Hack")
Autoit function
03/17/2008 - Silkroad Online - 0 Replies
I'm just looking to write a quick autoit script so I can auto-ress if I need to delvl someone. It's my first time using autoit ^^ I found the Sleep (#) code to wait, but what is the code to select a skill? I also would like to know how I can make the program loop until I press a button to end it. I've looked around and used the search button, but I don't see any codes posted here, only the programs. Thx for anyone who can help me :D



All times are GMT +2. The time now is 07:08.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.