fataldelay Posted January 14, 2008 Share Posted January 14, 2008 while -1 $m=PixelGetColor(98, 70) ; designates the pixel cordinates (they always there) same as below $m2=PixelGetColor(49, 70) $h=PixelGetColor(105, 55) $h2=PixelGetColor(45, 55) If hex($h,6) = "3B464F" then send("{F3 up}") sleep (10) Send("{F3}") Sleep (10) Else If hex($h2,6) = "3B464F" then send("{F4 up}") sleep (10) Send("{F4 down}") Sleep (10) ElseIf hex($m,6) = "3B464F" then send("{F1 up}") sleep (10) Send("{F1 down}") Sleep (10) ElseIf hex($m2,6) = "3B464F" then send("{F2 up}") sleep (10) Send("{F2 down}") Sleep (10) Else sleep (1) EndIf EndIf EndIf EndIf WEnd again im sure that this could be written much better.. and i have searched a few scripts even went on the web to check out some tutorials... but i guess im not understanding if statements very well... heres what i am trying to accomplish h = to a pixel bar h2 = same as h pixel bar but in a different area m= different pixel bar m2= same as the other m pixel bar but another location when h pixel bar reaches a certain area F3 needs to press only once when h2 pixel bar reaches a certain area F4 needs to press only once when m pixel bar reaches a certain area F1 needs to be pressed only once When m2 pixel bar reaches a certain area F2 needs to be pressed only once the script must fire at all times and check h,h2,m,and m2 continously until i end the script i also noticed certains things cannot be posted here as i have searched and seen things on forums so i am trying to attempt this myself without bothering too many people; i am not asking anyone to write my script just help me understand if statements and else and elseif .. Thanks if anyone can help please Link to comment Share on other sites More sharing options...
martin Posted January 14, 2008 Share Posted January 14, 2008 while -1 $m=PixelGetColor(98, 70) ; designates the pixel cordinates (they always there) same as below $m2=PixelGetColor(49, 70) $h=PixelGetColor(105, 55) $h2=PixelGetColor(45, 55) If hex($h,6) = "3B464F" then send("{F3 up}") sleep (10) Send("{F3}") Sleep (10) Else If hex($h2,6) = "3B464F" then send("{F4 up}") sleep (10) Send("{F4 down}") Sleep (10) ElseIf hex($m,6) = "3B464F" then send("{F1 up}") sleep (10) Send("{F1 down}") Sleep (10) ElseIf hex($m2,6) = "3B464F" then send("{F2 up}") sleep (10) Send("{F2 down}") Sleep (10) Else sleep (1) EndIf EndIf EndIf EndIf WEnd again im sure that this could be written much better.. and i have searched a few scripts even went on the web to check out some tutorials... but i guess im not understanding if statements very well... heres what i am trying to accomplish h = to a pixel bar h2 = same as h pixel bar but in a different area m= different pixel bar m2= same as the other m pixel bar but another location when h pixel bar reaches a certain area F3 needs to press only once when h2 pixel bar reaches a certain area F4 needs to press only once when m pixel bar reaches a certain area F1 needs to be pressed only once When m2 pixel bar reaches a certain area F2 needs to be pressed only once the script must fire at all times and check h,h2,m,and m2 continously until i end the script i also noticed certains things cannot be posted here as i have searched and seen things on forums so i am trying to attempt this myself without bothering too many people; i am not asking anyone to write my script just help me understand if statements and else and elseif .. Thanks if anyone can help please Welcome to the AutoIt forums . If you've just started then you did very well; there's not much wrong with what you've done. There is only one If statement, the ElseIf's are part of the whole if construction so you only need one EndIf. It's a good idea I think to give yourself some easy way to end a script so I have added something below. I recommend that you get Scite. This has lots of useful features include a Tidy tool which is run by using Ctrl T. It will indent your code and make it neat and easy to read, and it will indicate many errors like the extra EndIfs in your example. It's also conventional to use while 1 rather than while -1. Less typing anyway, although technically it would look better if we said While True, but I don't think many people, including me, would bother. expandcollapse popupHotKeySet("{ESC}","MyExit") While 1 $m = PixelGetColor(98, 70); designates the pixel cordinates (they always there) same as below $m2 = PixelGetColor(49, 70) $h = PixelGetColor(105, 55) $h2 = PixelGetColor(45, 55) If Hex($h, 6) = "3B464F" Then Send("{F3 up}") Sleep(10) Send("{F3}") Sleep(10) ElseIf Hex($h2, 6) = "3B464F" Then Send("{F4 up}") Sleep(10) Send("{F4 down}") Sleep(10) ElseIf Hex($m, 6) = "3B464F" Then Send("{F1 up}") Sleep(10) Send("{F1 down}") Sleep(10) ElseIf Hex($m2, 6) = "3B464F" Then Send("{F2 up}") Sleep(10) Send("{F2 down}") Sleep(10) Else Sleep(1) EndIf WEnd Func MyExit() exit EndFunc Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
fataldelay Posted January 14, 2008 Author Share Posted January 14, 2008 The problem im having is that the F1, F2, F3 and F4 keys are held down too long i just want them to be hit only one time.. and thank you for the help its much appreciated Link to comment Share on other sites More sharing options...
schilbiz Posted January 14, 2008 Share Posted January 14, 2008 (edited) The problem im having is that the F1, F2, F3 and F4 keys are held down too long i just want them to be hit only one time.. and thank you for the help its much appreciated I think part of your problem is that you are tell them to go down in a elseif statement, which could result in them being down for a very long time if the color you are looking for is not found. So if all you want to happen is the key to be hit when the color is found just do: ElseIf Hex($m, 6) = "3B464F" Then Send("{F1}") Sleep(10) Don't do the Up/Down stuff because if you tell it to go Down then that color does not appear for 10 minutes it will be pushed down untill the color appears again. Edited January 14, 2008 by schilbiz 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