Sign in to follow this  
Followers 0

GuiCtrlSetData inside Loop won't refresh data

29 posts in this topic

#1 ·  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



#2 ·  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.


010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Share this post


Link to post
Share on other sites

#3 ·  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

#4 ·  Posted

Bump

Share this post


Link to post
Share on other sites

#5 ·  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


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert - Easily convert date/time formats, including the language used
ExtMsgBox ------------- A highly customisable replacement for MsgBox
GUIExtender ----------- Extend and retract multiple sections within a GUI
GUIFrame -------------- Subdivide GUIs into many adjustable frames
GUIListViewEx -------- Insert, delete, move, drag, sort and edit ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ---------------- Scrolling tickertape GUIs
NoFocusLines --------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify -------------------- Small notifications on the edge of the display
Scrollbars -------------- Automatically sized scrollbars with a single command
StringSize -------------- Automatically size controls to fit text
Toast -------------------- Small GUIs which pop out of the notification area

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Still looking for some help...

Edited by xanathos

Share this post


Link to post
Share on other sites

#7 ·  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.


010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Share this post


Link to post
Share on other sites

#8 ·  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

#9 ·  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.


010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Share this post


Link to post
Share on other sites

#10 ·  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

#11 ·  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

010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Share this post


Link to post
Share on other sites

#12 ·  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

#13 ·  Posted

Bump for more help please

Share this post


Link to post
Share on other sites

#14 ·  Posted

bump

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

Would still appreciate some help please

Edited by xanathos

Share this post


Link to post
Share on other sites

#16 ·  Posted

up

Share this post


Link to post
Share on other sites

#17 ·  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

#18 ·  Posted

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


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

#19 ·  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

#20 ·  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?


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

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