UnknownWarrior Posted January 24, 2009 Share Posted January 24, 2009 Maybe I just never caught this part of learning AutoIt, but when I say have Func ads() $i = 1 bsd() EndFunc Func bsd() If $i = 1 Then ;-- endIf EndFunc It don't work for me. I'm trying to create something that knows when the pot key has been pressed 3 times, once it has, then it goes to a different Func.... heres my script, do you guys see anything wrong? :S expandcollapse popupOpt("GUIOnEventMode", 1) Opt("MouseCoordMode", 0) Opt("PixelCoordMode", 0) #include <GUIConstants.au3> HotKeySet("{ESC}", "Terminate") HotKeySet("^p", "_ToggleRun") HotKeySet("^o", "stop") Global $Running = 0, $MPos, $PixelColor, $i = 1 While 1 If $Running Then Pot() Box() EndIf WEnd Func Box() If $i = 4 Then Send("{F3}") $i = 1 EndIf EndFunc Func Pot() If $PixelColor <> PixelGetColor($MPos[0], $MPos[1]) Then Send("{F2}") Sleep(1000) $i = $i + 1 EndIf EndFunc Func _ToggleRun() $Running = NOT $Running If $Running Then $MPos = MouseGetPos() $PixelColor = PixelGetColor($MPos[0], $MPos[1]) EndIf EndFunc Func stop() $Running = NOT $Running MsgBox(0, "", "Press Ctrl+p AGAIN to record your new pixel spot!") EndFunc Func Terminate() Exit EndFunc P.S. this code: If $PixelColor <> PixelGetColor($MPos[0], $MPos[1]) Then Just means if the spot recorded color changes, Then: blah blah... Link to comment Share on other sites More sharing options...
Andreik Posted January 24, 2009 Share Posted January 24, 2009 Set $i as global variable. When the words fail... music speaks. Link to comment Share on other sites More sharing options...
UnknownWarrior Posted January 24, 2009 Author Share Posted January 24, 2009 (edited) Set $i as global variable. It is at the top... $i = 1... And from what I think, that means the variable can be changed throughout the script... So $i = 1 would turn into $i = 2, etc etc, until it reaches $i = 4 and then Box() would activate... But it's not -.- Ps/Edit - In this line: If $PixelColor <> PixelGetColor($MPos[0], $MPos[1]) Then I used to use just If $PixelColor <> $PixelColor Then But that didn't work, until my friend told me to switch the 2nd PixelColor with what PixelColor actually is... What I don't get, why doesn't $PixelColor <> $PixelColor work the same as $PixelColor <> PixelGetColor($MPos[0], $MPos[1])... Because in here: Func _ToggleRun() $Running = NOT $Running If $Running Then $MPos = MouseGetPos() $PixelColor = PixelGetColor($MPos[0], $MPos[1]) EndIf EndFunc PixelColor IS PixelGetColor($MPos[0], $MPos[1])... So what is the difference between using PixelGetColor($MPos[0], $MPos[1]) and just PixelColor... And why don't PixelColor <> PixelColor work? >< Edited January 24, 2009 by UnknownWarrior Link to comment Share on other sites More sharing options...
Authenticity Posted January 24, 2009 Share Posted January 24, 2009 Opt('MustDeclareVars', 1) Dim $i = 0 _First() MsgBox(0x40, 'Title', '$i = ' & $i) Func _First() $i += 1 _Third() EndFunc Func _Second() $i *= 2 EndFunc Func _Third() $i += 5 _Second() EndFunc MsgBox indeed confirm the result was calculated properly and the result is 12 as you can see so it's probably your HotKey UDF get called more than once even if you press CTRL+p once, also I believe that ^p and ^P are different. Try to use #AutoIt3Wrapper_Run_Debug_Mode=Y and ConsoleWrite with your format to see what is going on. Link to comment Share on other sites More sharing options...
UnknownWarrior Posted January 24, 2009 Author Share Posted January 24, 2009 Opt('MustDeclareVars', 1) Dim $i = 0 _First() MsgBox(0x40, 'Title', '$i = ' & $i) Func _First() $i += 1 _Third() EndFunc Func _Second() $i *= 2 EndFunc Func _Third() $i += 5 _Second() EndFunc MsgBox indeed confirm the result was calculated properly and the result is 12 as you can see so it's probably your HotKey UDF get called more than once even if you press CTRL+p once, also I believe that ^p and ^P are different. Try to use #AutoIt3Wrapper_Run_Debug_Mode=Y and ConsoleWrite with your format to see what is going on. So exactly, why is it not working in MY script... Any idea? :S Link to comment Share on other sites More sharing options...
Authenticity Posted January 24, 2009 Share Posted January 24, 2009 rofl I'm not blind, I can't understand what reason it might be. If it was my script I'd try to use ConsoleWrite to inform me about the progress and maybe delete it all and start function by function because it has to be something. Link to comment Share on other sites More sharing options...
Suirad Posted January 25, 2009 Share Posted January 25, 2009 Func ads() $i = 1 bsd($i) EndFunc Func bsd($i) If $i = 1 Then MsgBox(0,"","works") endIf EndFunc cheers Link to comment Share on other sites More sharing options...
CodyBarrett Posted January 25, 2009 Share Posted January 25, 2009 Yeah You COULD use $i as a parameter, But COULD you use it as Global Const $i im pretty sure you CAN [size="1"][font="Tahoma"][COMPLETED]-----[FAILED]-----[ONGOING]VolumeControl|Binary Converter|CPU Usage| Mouse Wrap |WinHide|Word Scrammbler|LOCKER|SCREEN FREEZE|Decisions Decisions|Version UDF|Recast Desktop Mask|TCP Multiclient EXAMPLE|BTCP|LANCR|UDP serverless|AIOCR|OECR|Recast Messenger|AU3C|Tik-Tak-Toe|Snakes & Ladders|BattleShips|TRON|SNAKE_____________________[u]I love the Helpfile it is my best friend.[/u][/font][/size] Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now