testmeout Posted November 20, 2005 Share Posted November 20, 2005 I am trying to create a counter based on if certain control id buttons are pressed in a window. From searching it doesn't look like its possible. Here is my current code but it doesn't provide any results. #include <GUIConstants.au3> #include <Misc.au3> Opt("GUICoordMode", 1) Opt("WinTitleMatchMode", 1) WinActivate("Program Name") WinWaitActive("Program Name") While 1 If ControlGetFocus("112") AND _IsPressed(01) Then $currentvalue = IniRead ("counter.ini", "counter", "currentcount", "0" ) + 1 Iniwrite ( "counter.ini", "counter", "currentcount", $currentvalue ) EndIf If ControlGetFocus("210") AND _IsPressed(01) Then $currentvalue = IniRead ("counter.ini", "counter", "currentcount", "0" ) + 1 Iniwrite ( "counter.ini", "counter", "currentcount", $currentvalue ) EndIf If ControlGetFocus("211") AND _IsPressed(01) Then $currentvalue = IniRead ("counter.ini", "counter", "currentcount", "0" ) + 1 Iniwrite ( "counter.ini", "counter", "currentcount", $currentvalue ) EndIf WEnd Does anyone know if this is even possible or is there a workaround, or is my code just disfunctional? Thanks Link to comment Share on other sites More sharing options...
DoctorX Posted November 20, 2005 Share Posted November 20, 2005 (edited) You might not be using ControlGetFocus in the correct manner. ControlGetFocus is expecting ("Window Title", "Window Text") as its parameters. You seem to be inputting the ControlID, which is what ControlGetFocus will return. Try something like this:$curbut = ControlGetFocus ("Program Name") If $curbut = 112 AND _IsPressed (01) Then ; Add your .ini increment EndIf Edit: There may be a syntax problem with the _IsPressed function too. What you're trying to do is possible, but you should read up in the help file for the proper uses of these functions. Edited November 20, 2005 by DoctorX -DRX Link to comment Share on other sites More sharing options...
testmeout Posted November 20, 2005 Author Share Posted November 20, 2005 Thanks DocterX for replying. Although after testing still nothing outputed to my .ini file. Is ControlGetFocus the right command even if there is no keyboard focus in the window? Is there a way to focus on what button the mouse is hovering over or clicked? Thanks Link to comment Share on other sites More sharing options...
DoctorX Posted November 20, 2005 Share Posted November 20, 2005 AFAIK keyboard focus and mouse focus are one in the same. You might have missed my edit about the _IsPressed function. There is probably a cleaner way to do what you are trying to do, but the way you have it should work if all of the parameters are corrected. -DRX Link to comment Share on other sites More sharing options...
DoctorX Posted November 20, 2005 Share Posted November 20, 2005 Whoops, just checked the help file myself, you seem to be using the _IsPressed function correctly. I wonder if GUIControlRead might work in this situation? -DRX Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted November 20, 2005 Moderators Share Posted November 20, 2005 Did you try using the direct path to the ini? Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
testmeout Posted November 20, 2005 Author Share Posted November 20, 2005 Still Nothing. Has anyone actually done something like this, and got it working? Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted November 20, 2005 Moderators Share Posted November 20, 2005 HMMMM!! I tried it many different ways testmeout... It seems that _IsPressed isn't working for me at all. I don't know if this is a bug, but I tried it both in the stable release just using the function itself, and in the Beta .86 release. Maybe you should post it in the bug reports, and have one of the Devs look at it. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Valuater Posted November 20, 2005 Share Posted November 20, 2005 maybe this #include <GUIConstants.au3> #include <Misc.au3> Opt("GUICoordMode", 1) Opt("WinTitleMatchMode", 1) WinActivate("Program Name") WinWaitActive("Program Name") While 1 If _IsPressed(01) Then If WinActive("?Name?") Or WinActive("?Name?") Or WinActive("?Name?") Then $currentvalue = IniRead ("counter.ini", "counter", "currentcount", "0" ) + 1 Iniwrite ( "counter.ini", "counter", "currentcount", $currentvalue ) EndIf EndIf WEnd 8) Link to comment Share on other sites More sharing options...
Valuater Posted November 20, 2005 Share Posted November 20, 2005 (edited) sorry its 3 am #include <GUIConstants.au3> #include <Misc.au3> Opt("GUICoordMode", 1) Opt("WinTitleMatchMode", 1) WinActivate("Program Name") WinWaitActive("Program Name") While 1 If _IsPressed(01) Then ;MsgBox(0,"test", " cool"); for testing If ControlGetFocus("210") >= "" Or ControlGetFocus("112") >= "" Or ControlGetFocus("211") >= "" Then $currentvalue = IniRead ("counter.ini", "counter", "currentcount", "0" ) + 1 Iniwrite ( "counter.ini", "counter", "currentcount", $currentvalue ) EndIf EndIf WEnd 8) EDIT replaced 0 with "" EDIT 2 removed extra Endif... Dah Edited November 20, 2005 by Valuater Link to comment Share on other sites More sharing options...
testmeout Posted November 20, 2005 Author Share Posted November 20, 2005 Yea! It actually writes to the ini, but it writes if I click anywhere not just those three buttons, and it is not incrimenting in 1's it is some weird increment. Any ideas? Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted November 20, 2005 Moderators Share Posted November 20, 2005 I'll attest that it worked also... What buttons are your talking. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
testmeout Posted November 20, 2005 Author Share Posted November 20, 2005 I would be talking about 210, 112, and 211 which come to find out are the control ids for the buttons which is not what ControlGetFocus returnsI realized that ControlGetFocus("Program Name") will return the ClassNameNN.210 is the Control ID for ImageButton3112 is the Control ID for ImageButton2211 is the Control ID for ImageButton6Although its writing data, which is good it is still not doing it based on clicks to those three buttonsAny ideas?By the way Ron if you get a chance will you look at my reply for my previous posthttp://www.autoitscript.com/forum/index.php?showtopic=18186 Link to comment Share on other sites More sharing options...
Valuater Posted November 20, 2005 Share Posted November 20, 2005 (edited) I would be talking about 210, 112, and 211 which come to find out are the control ids for the buttons which is not what ControlGetFocus returnsI realized that ControlGetFocus("Program Name") will return the ClassNameNN.210 is the Control ID for ImageButton3112 is the Control ID for ImageButton2211 is the Control ID for ImageButton6Although its writing data, which is good it is still not doing it based on clicks to those three buttonsAny ideas?By the way Ron if you get a chance will you look at my reply for my previous posthttp://www.autoitscript.com/forum/index.php?showtopic=18186Actually... I hate guessingwhat programis it the internetwhy dont you show your scriptDah8) Edited November 20, 2005 by Valuater Link to comment Share on other sites More sharing options...
testmeout Posted November 20, 2005 Author Share Posted November 20, 2005 Sorry just didn't think it was important. I am trying to make a counter for my amount wagered at a online casino Here is the code I have been messing with, it currently does not write to .ini #include <GUIConstants.au3> #include <Misc.au3> Opt("GUICoordMode", 1) Opt("WinTitleMatchMode", 1) WinActivate("Casino") WinWaitActive("Casino") While 1 If _IsPressed(01) Then ;MsgBox(0,"test", " cool"); for testing If ControlGetFocus("Casino") >= "ImageButton2" Or ControlGetFocus("Casino") >= "ImageButton3" Or ControlGetFocus("Casino") >= "ImageButton6" Then $currentvalue = IniRead ("counter.ini", "counter", "currentcount", "0" ) + 1 Iniwrite ( "counter.ini", "counter", "currentcount", $currentvalue ) EndIf EndIf WEnd Hope this helps Link to comment Share on other sites More sharing options...
Valuater Posted November 20, 2005 Share Posted November 20, 2005 if you are using Internet Explorer..I strongly urge you to learn about IE.au3this was developed by Dale Hohmhttp://www.autoitscript.com/forum/index.ph...ernet+Explorer#there all kinds of ways of controlling IEi used it myselfit reads the pages, finds words, pictures etc,,,etcgood luck8) Link to comment Share on other sites More sharing options...
testmeout Posted November 20, 2005 Author Share Posted November 20, 2005 Thanks for the info, but this is a client based software, it is not run through internet explorer, or foxfire Link to comment Share on other sites More sharing options...
Valuater Posted November 20, 2005 Share Posted November 20, 2005 (edited) i thought it was online ok... there is more than one way to skin a cat... right 8) Edited November 20, 2005 by Valuater Link to comment Share on other sites More sharing options...
Valuater Posted November 20, 2005 Share Posted November 20, 2005 ok this will do the trick.. all you need to do is put in the mouse area that covers the button(s) example top left right bottom where $pos[0] > - 1 And $pos[0] < 12 is left and right of the button and $pos[1] > - 1 And $pos[1] < 12 is top and bottom of the button #include <GUIConstants.au3> #include <Misc.au3> Dim $post = 0 Opt("GUICoordMode", 1) Opt("WinTitleMatchMode", 1) WinActivate("Casino") WinWaitActive("Casino") While 1 If _IsPressed(01) Then ;MsgBox(0,"test", " cool"); for testing $pos = MouseGetPos() ; position of 1 button If $pos[0] > - 1 And $pos[0] < 12 And $pos[1] > - 1 And $pos[1] < 12 Then $post = 1 ; position of 2 button If $pos[0] > - 1 And $pos[0] < 12 And $pos[1] > - 1 And $pos[1] < 12 Then $post = 1 ; position of 3 button If $pos[0] > - 1 And $pos[0] < 12 And $pos[1] > - 1 And $pos[1] < 12 Then $post = 1 If $post = 1 Then $currentvalue = IniRead ("counter.ini", "counter", "currentcount", "0" ) + 1 Iniwrite ( "counter.ini", "counter", "currentcount", $currentvalue ) $post = 0 EndIf EndIf WEnd 8) Link to comment Share on other sites More sharing options...
Valuater Posted November 20, 2005 Share Posted November 20, 2005 (edited) even better if you use the mouse coodinates Opt("MouseCoordMode", 2) ;1=absolute, 0=relative, 2=client EDIT... need to put a sleep in the While Loop...like Sleep(20) 8) Edited November 20, 2005 by Valuater 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