Jump to content

GuiCtrlSetData inside Loop won't refresh data


Recommended Posts

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
Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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
Link to comment
Share on other sites

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
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, edit and colour 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

 

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...