Sign in to follow this  
Followers 0

GuiCtrlSetData inside Loop won't refresh data

29 posts in this topic

Posted (edited)

Hello everyone

I'm having a little problem

Here is a part of my code:

Func MouseScan()
   Local $count = 0
   Local $expensive = Number(GUICtrlRead($CTRL_OrderSell)) < GUICtrlRead($CTRL_OrderBuy)
   Local $cheap = Number(GUICtrlRead($CTRL_OrderSell)) > GUICtrlRead($CTRL_OrderBuy)
$x = MouseGetPos(0)
$y = MouseGetPos(1)
For $count = 0 to 9 step 1
Local $Box = _MemoryRead($ADDR_MsgBoxSell, $openmem, "word")  
MouseClick("left", MouseGetPos(0), MouseGetPos(1)-35, 2)
GuiCtrlSetData($CTRL_MsgBoxSell, number($box))
If $expensive = 1 then
Send("{ESC}")
EndIf
Next
  
EndFunc

Here is what I wanna do:

1. Click on some part of the screen

2. When the msgbox pops, I want to compare 2 values from 2 inputbox ($CTRL_OrderSell and $CTRL_OrderBuy)

3. If no msgbox appears (value is stored in $CTRL_MsgBoxSell 1 if the msgbox is there / 0 if it's not), it moves to y-35

4. If $CTRL_OrderSell < $CTRL_OrderBuy it presses ESC and moves to y-35

5. If $CTRL_OrderSell > $CTRL_OrderBuy it presses ENTER and moves to y-35 (not in the code yet, since I'm having a problem from the previous step already)

6. Loop that until $count = 9 after that executes another function (another mousemove) and after the function has been executed repeat from step 1

Here is what happens:

Since it's in a loop, it won't "refresh" the values in their respective inputbox until the loop has been executed (therefore the comparison between OrderSell and OrderBuy fails)

I'm a bit lost...

Edited by xanathos

Share this post


Link to post
Share on other sites



Posted

simply re evaluate the variable at the point you need it refreshed

if you guictrlsetdata at some point, then later a new guictrlread should get your new values.

Share this post


Link to post
Share on other sites

Posted (edited)

simply re evaluate the variable at the point you need it refreshed

if you guictrlsetdata at some point, then later a new guictrlread should get your new values.

Look closely, this is what I'm already doing

MouseClick("left", MouseGetPos(0), MouseGetPos(1)-35, 2)
GuiCtrlSetData($CTRL_MsgBoxSell, number($box))
If $expensive = 1 then

$expensive already guictrlread after guictrlsetdata...

I need it refreshed like 1 second after mouseclick has been executed, so I put it inside the loop after mouseclick, but then problem is, that it doesn't get refreshed until the whole loop has ended...

Edited by xanathos

Share this post


Link to post
Share on other sites

Posted

Bump

Share this post


Link to post
Share on other sites

Posted

xanathos,

Please do not bump your posts within 24 hours. ;)

Remember this is not a 24/7 support forum - those who answer are only here because they like helping others and have some time to spare. You just have to wait until someone who knows something about your particular problem, and is willing to help, comes online. Be patient and someone will answer eventually. :)

M23

Share this post


Link to post
Share on other sites

Posted (edited)

Still looking for some help...

Edited by xanathos

Share this post


Link to post
Share on other sites

Posted

You're reading OrderBuy and OrderSell

but in the script you posted, you aren't changing their data

You change MsgBoxSell but you never read that controll in your script you posted.

Share this post


Link to post
Share on other sites

Posted

You're reading OrderBuy and OrderSell

but in the script you posted, you aren't changing their data

You change MsgBoxSell but you never read that controll in your script you posted.

They are being set by another function which is being called in the main gui loop (I even tried to call that same function inside the loop of the MouseScan() function, but It still won't refresh

Share this post


Link to post
Share on other sites

Posted

Ok, so you want to update your ordersell and order buy right after the mouseclick but you do not set the data for those 2 controls

you will probably need to do a bit of rewriting...

put the updating of those controls into a seperate function, then call that function anywhere in the script where you need to update those controls.

Share this post


Link to post
Share on other sites

Posted

Ok, so you want to update your ordersell and order buy right after the mouseclick but you do not set the data for those 2 controls

you will probably need to do a bit of rewriting...

put the updating of those controls into a seperate function, then call that function anywhere in the script where you need to update those controls.

I did that already; with no luck...

Share this post


Link to post
Share on other sites

Posted (edited)

it would be something like:

MouseClick("left", MouseGetPos(0), MouseGetPos(1)-35, 2)
_your_set_buy_and_sell_function()
$expensive = Number(GUICtrlRead($CTRL_OrderSell)) < GUICtrlRead($CTRL_OrderBuy)
$cheap = Number(GUICtrlRead($CTRL_OrderSell)) > GUICtrlRead($CTRL_OrderBuy)
GuiCtrlSetData($CTRL_MsgBoxSell, number($box))
If $expensive = 1 then

*edit*

I noticed that in your $expensive and $cheap, you are only converting the first guictrlread to a number and not the read after the < and > signs.

Edited by kaotkbliss

Share this post


Link to post
Share on other sites

Posted (edited)

Func MouseScan()
;~ $expensive = GUICtrlRead($CTRL_OrderSell) &lt; GUICtrlRead($CTRL_OrderBuy)
;~ $cheap = GUICtrlRead($CTRL_OrderBuy) &lt; GUICtrlRead($CTRL_OrderSell)
$x = MouseGetPos(0)
$y = MouseGetPos(1)
$count = 0
For $count = 0 to 8 step 1
  $expensive = Number(GUICtrlRead($CTRL_OrderSell)) < Number(GUICtrlRead($CTRL_OrderBuy))
  $cheap = Number(GUICtrlRead($CTRL_OrderBuy)) < Number(GUICtrlRead($CTRL_OrderSell))
  MouseClick("left", MouseGetPos(0), MouseGetPos(1) - 38, 2)
  LoadPrice()
  FindValueInString()
  MemReadMsgBox()
;~ compare()
sleep(1000)
  If $expensive = 1 AND GUICtrlRead($CTRL_MsgBoxSell) = '1' then
   Sleep(2000)
   Send("{ESC}")
  EndIf
;~   If $cheap = 1 AND GUICtrlRead($CTRL_MsgBoxSell) = '1' Then
;~	sleep(500)
;~	Msgbox(0, "Han", "Cours l'acheter!")
;~	Send("{ESC}")
;~   EndIf
Next
;~	ExitLoop

EndFunc   ;==&gt;MouseScan

Here is the LoadPrice() func, that sets the input for $OrderSell:

Func LoadPrice()
$OrderID = GetOrderId()
Local $file = @ScriptDir &amp; "Orders" &amp; $OrderID &amp; ".txt"
Local $fileopen = FileOpen(@ScriptDir &amp; "Orders" &amp; $OrderID &amp; ".txt")
Local $filereadline = FileReadLine(@ScriptDir &amp; "Orders" &amp; $OrderID &amp; ".txt")
Local $line = StringSplit(FileRead(@ScriptDir &amp; "Orders" &amp; $OrderID &amp; ".txt"), @CR)
$size_bytes = FileGetSize(@ScriptDir &amp; "Orders" &amp; $OrderID &amp; ".txt")
if $OrderID = 0 Then
  $OrderID2 = $OrderID
  Return
EndIf

if $OrderID = $OrderID2 Then
  Return
EndIf
$OrderID2 = $OrderID
$webpage = InetRead("http://127.0.0.1/Order.aspx?id=" &amp; $OrderID)
;~ $webpage = 0
$webstring = BinaryToString($webpage)
if FileExists($file) Then
  $webstring = FileRead($fileopen)
  $newOrdervalue = $filereadline
Else
  $webstring = BinaryToString($webpage)
  $pos = StringInStr($webstring, "Price")
  $postocut = $pos + 28
  $trimmedleft = StringTrimLeft($webstring, $postocut)
  $pos2 = StringInStr($trimmedleft, " ")
  $newOrdervalue = StringMid($webstring, $postocut, $pos2)
Endif
$length = StringLen($newOrdervalue)
;~   $length = StringLen($newOrdervalue)


If $length &gt; 3 then
  $tausender = StringTrimRight($newOrdervalue, 3)
  $htausender = StringTrimLeft($newOrdervalue, $length - 3)
  $newOrdervalue2 = $tausender &amp; "" &amp; $htausender
  GUICtrlSetData( Int($CTRL_OrderSell), Int($newOrdervalue2))
  $oldOrdervalue2 = $newOrdervalue

Else
  Number(GUICtrlSetData($CTRL_OrderSell, $newOrdervalue))
EndIf

;~   if FileExists($file) Then
;~	  $webstring = FileRead($fileopen)
;~		$newOrdername = $filereadline
;~   Else
$pos3 = StringInStr($webstring, "Order-name")
$pos3tocut = $pos3 + 11
$trimmedleft2 = StringTrimLeft($webstring, $pos3tocut)
$pos4 = StringInStr($trimmedleft2, "")
$newOrdername = StringMid($webstring, $pos3tocut, $pos4)
GUICtrlSetData($CTRL_Nom, $newOrdername)
$oldOrdername = $newOrdername
;~   EndIf
if FileExists($file) Then
  FileClose($file)
Else
  FileWriteLine($file, $newOrdervalue)
  FileWriteLine($file, $newOrdername)
  FileClose($file)
EndIf
EndFunc   ;==&gt;loadOrderprice

Still no luck

Edited by xanathos

Share this post


Link to post
Share on other sites

Posted

Bump for more help please

Share this post


Link to post
Share on other sites

Posted

bump

Share this post


Link to post
Share on other sites

Posted (edited)

Would still appreciate some help please

Edited by xanathos

Share this post


Link to post
Share on other sites

Posted

up

Share this post


Link to post
Share on other sites

Posted

I don't know if that's because my question is too complicated but since I've seen way more complicated problems getting solved I don't think so, but I don't know why my thread is not getting any answer...I'm not asking for a complete solution but any help or hint would be appreciated

Share this post


Link to post
Share on other sites

Posted

You haven't said what you need help with, try explaining better what you're trying to do that doesn't work right.

Share this post


Link to post
Share on other sites

Posted (edited)

You haven't said what you need help with, try explaining better what you're trying to do that doesn't work right.

Func MouseScan()
;~ $expensive = GUICtrlRead($CTRL_Revente) < GUICtrlRead($CTRL_Achat)
;~ $cheap = GUICtrlRead($CTRL_Achat) < GUICtrlRead($CTRL_Revente)

	$x = MouseGetPos(0)
	$y = MouseGetPos(1)
	For $count = 1 to 9 step 1
		$expensive = Number(GUICtrlRead($CTRL_Revente)) < Number(GUICtrlRead($CTRL_Achat))
		$cheap = Number(GUICtrlRead($CTRL_Achat)) < Number(GUICtrlRead($CTRL_Revente))
		MouseClick("left", MouseGetPos(0), MouseGetPos(1) - 38, 2)
		loaditemprice()
		FindValueInString()
		MemReadMsgBox()
;~ compare()
sleep(1000)
		If $expensive = 1 AND GUICtrlRead($CTRL_MsgBoxSell) = '1' then
			Sleep(2000)
			Send("{ESC}")
		EndIf
;~		 If $cheap = 1 AND GUICtrlRead($CTRL_MsgBoxSell) = '1' Then
;~			 sleep(500)
;~			 Msgbox(0, "Han", "Cours l'acheter!")
;~			 Send("{ESC}")
;~		 EndIf
	Next
;~	ExitLoop


EndFunc   ;==>MouseScan

My script compares 2 values from 2 guicrtls; basically if my ordersell guictrl is > to orderbuy guictrl it should press ESC key and continue to next Y-18 from where it stopped, they are placed in a loop, depending on where my mouse is placed, that value changes, problem is that until the loop has not ended it will not return the correct value from where the mouse is...

Edited by xanathos

Share this post


Link to post
Share on other sites

Posted

You're only reading the location of the mouse once before it goes into the For loop, is that what you're intending?

Also, the controls you're reading from, are they in an AutoIt GUI or an external program?

Share this post


Link to post
Share on other sites

Posted

You're only reading the location of the mouse once before it goes into the For loop, is that what you're intending?

Also, the controls you're reading from, are they in an AutoIt GUI or an external program?

Yes, that is why I have put everything in the loop, I have to do the check every mouseclick for 9 times, it's more convenient with a loop

i'm reading from an external program and store them in those GUICTRL

Share this post


Link to post
Share on other sites

Posted

You're checking the same mouse click location 9 times? For what? Does it change in between those clicks?

You're going to have to post a lot more code than just this function, because I have no idea what it is you're trying to do, your explanation is really vague as to what you're trying to do. Also, you can't use GUICtrlRead on an external (non-AutoIt) program, you'd need to use something else to read from an external control.

Share this post


Link to post
Share on other sites

Posted (edited)

You're checking the same mouse click location 9 times? For what? Does it change in between those clicks?

You're going to have to post a lot more code than just this function, because I have no idea what it is you're trying to do, your explanation is really vague as to what you're trying to do. Also, you can't use GUICtrlRead on an external (non-AutoIt) program, you'd need to use something else to read from an external control.

It doesn't check the same location, it checks every 18 pixels from the current Y axis

I'm reading the memory to get those values from the external program, it returns a correct value in my autoit script, I have tried already, here is the function that reads depending on the mouse coordinates

func GetOrderId()
OpenMemory()
$StaticOffset = dec("C50494")
Global $pid = ProcessExists("iexplore.exe")
Global $CUROffset[1]
$CUROffset[0] = 0
$baseADDR = _MemoryModuleGetBaseAddress($pid, "mlang.dll")
$finalADDR = $baseADDR + $StaticOffset
$MemTest = _MEMORYREAD($finalADDR, $openmem)
Return $MemTest
EndFunc   ;==>GetOrderId

Func LoadPrice()
$OrderID = GetOrderId()
Local $file = @ScriptDir &amp; "Orders" &amp; $OrderID &amp; ".txt"
Local $fileopen = FileOpen(@ScriptDir &amp; "Orders" &amp; $OrderID &amp; ".txt")
Local $filereadline = FileReadLine(@ScriptDir &amp; "Orders" &amp; $OrderID &amp; ".txt")
Local $line = StringSplit(FileRead(@ScriptDir &amp; "Orders" &amp; $OrderID &amp; ".txt"), @CR)
$size_bytes = FileGetSize(@ScriptDir &amp; "Orders" &amp; $OrderID &amp; ".txt")
if $OrderID = 0 Then
  $OrderID2 = $OrderID
  Return
EndIf
if $OrderID = $OrderID2 Then
  Return
EndIf
$OrderID2 = $OrderID
$webpage = InetRead("http://127.0.0.1/Order.aspx?id=" &amp; $OrderID)
;~ $webpage = 0
$webstring = BinaryToString($webpage)
if FileExists($file) Then
  $webstring = FileRead($fileopen)
  $newOrdervalue = $filereadline
Else
  $webstring = BinaryToString($webpage)
  $pos = StringInStr($webstring, "Price")
  $postocut = $pos + 28
  $trimmedleft = StringTrimLeft($webstring, $postocut)
  $pos2 = StringInStr($trimmedleft, " ")
  $newOrdervalue = StringMid($webstring, $postocut, $pos2)
Endif
$length = StringLen($newOrdervalue)
;~   $length = StringLen($newOrdervalue)

If $length &gt; 3 then
  $tausender = StringTrimRight($newOrdervalue, 3)
  $htausender = StringTrimLeft($newOrdervalue, $length - 3)
  $newOrdervalue2 = $tausender &amp; "" &amp; $htausender
  GUICtrlSetData( Int($CTRL_OrderSell), Int($newOrdervalue2))
  $oldOrdervalue2 = $newOrdervalue
Else
  Number(GUICtrlSetData($CTRL_OrderSell, $newOrdervalue))
EndIf
;~   if FileExists($file) Then
;~	  $webstring = FileRead($fileopen)
;~		$newOrdername = $filereadline
;~   Else
$pos3 = StringInStr($webstring, "Order-name")
$pos3tocut = $pos3 + 11
$trimmedleft2 = StringTrimLeft($webstring, $pos3tocut)
$pos4 = StringInStr($trimmedleft2, "")
$newOrdername = StringMid($webstring, $pos3tocut, $pos4)
GUICtrlSetData($CTRL_Nom, $newOrdername)
$oldOrdername = $newOrdername
;~   EndIf
if FileExists($file) Then
  FileClose($file)
Else
  FileWriteLine($file, $newOrdervalue)
  FileWriteLine($file, $newOrdername)
  FileClose($file)
EndIf
EndFunc   ;==&gt;loadOrderprice
Edited by xanathos

Share this post


Link to post
Share on other sites

Posted

bump for help

Share this post


Link to post
Share on other sites

Posted

bump

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0




  • Recently Browsing   0 members

    No registered users viewing this page.