Jump to content



Photo

GuiCtrlSetData inside Loop won't refresh data


  • Please log in to reply
28 replies to this topic

#1 xanathos

xanathos

    Seeker

  • Active Members
  • 34 posts

Posted 12 May 2012 - 01:06 AM

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, 31 May 2012 - 10:04 AM.






#2 kaotkbliss

kaotkbliss

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 2,106 posts

Posted 12 May 2012 - 01:35 AM

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.
Posted Image010101000110100001101001011100110010000001101001011100110010000001101101011110010010000001110011011010010110011100100001My first project Allin1 Program launcherBill CalculatorGot <Insert problem here>?There's an AutoIt script for that!

#3 xanathos

xanathos

    Seeker

  • Active Members
  • 34 posts

Posted 12 May 2012 - 01:37 AM

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, 12 May 2012 - 07:03 AM.


#4 xanathos

xanathos

    Seeker

  • Active Members
  • 34 posts

Posted 12 May 2012 - 08:14 AM

Bump

#5 Melba23

Melba23

    Yes, me!

  • Moderators
  • 15,353 posts

Posted 12 May 2012 - 08:41 AM

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
StringSize - Automatically size controls to fit text - ExtMsgBox - A user customisable replacement for MsgBox

Toast - Small GUIs which pop out of the Systray - Marquee - Scrolling tickertape GUIs

Scrollbars - Automatically sized scrollbars with a single command - GUIFrame - Subdivide GUIs into many adjustable frames

GUIExtender - Extend and retract multiple sections within a GUI - NoFocusLines - Remove the dotted focus lines from buttons, sliders, radios and checkboxes

ChooseFileFolder - Single and multiple selections from specified path tree structure - - Notify - Small notifications on the edge of the display

RecFileListToArray - An alternative to _FileListToArray with user-defined include/exclude masks, maximum recursion level, sorting and displayed path options

GUIListViewEx - Insert, delete, move, drag and sort ListView items


#6 xanathos

xanathos

    Seeker

  • Active Members
  • 34 posts

Posted 13 May 2012 - 07:55 PM

Still looking for some help...

Edited by xanathos, 13 May 2012 - 07:55 PM.


#7 kaotkbliss

kaotkbliss

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 2,106 posts

Posted 14 May 2012 - 02:07 AM

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.
Posted Image010101000110100001101001011100110010000001101001011100110010000001101101011110010010000001110011011010010110011100100001My first project Allin1 Program launcherBill CalculatorGot <Insert problem here>?There's an AutoIt script for that!

#8 xanathos

xanathos

    Seeker

  • Active Members
  • 34 posts

Posted 15 May 2012 - 01:51 AM

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

#9 kaotkbliss

kaotkbliss

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 2,106 posts

Posted 15 May 2012 - 12:20 PM

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.
Posted Image010101000110100001101001011100110010000001101001011100110010000001101101011110010010000001110011011010010110011100100001My first project Allin1 Program launcherBill CalculatorGot <Insert problem here>?There's an AutoIt script for that!

#10 xanathos

xanathos

    Seeker

  • Active Members
  • 34 posts

Posted 15 May 2012 - 02:58 PM

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

#11 kaotkbliss

kaotkbliss

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 2,106 posts

Posted 15 May 2012 - 03:12 PM

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, 15 May 2012 - 03:27 PM.

Posted Image010101000110100001101001011100110010000001101001011100110010000001101101011110010010000001110011011010010110011100100001My first project Allin1 Program launcherBill CalculatorGot <Insert problem here>?There's an AutoIt script for that!

#12 xanathos

xanathos

    Seeker

  • Active Members
  • 34 posts

Posted 15 May 2012 - 04:46 PM

AutoIt         
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:

AutoIt         
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("<a href='http://127.0.0.1/Order.aspx?id=' class='bbc_url' title='External link' rel='nofollow external'>http://127.0.0.1/Order.aspx?id="</a> &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, 24 May 2012 - 10:07 PM.


#13 xanathos

xanathos

    Seeker

  • Active Members
  • 34 posts

Posted 16 May 2012 - 11:12 PM

Bump for more help please

#14 xanathos

xanathos

    Seeker

  • Active Members
  • 34 posts

Posted 19 May 2012 - 03:03 AM

bump

#15 xanathos

xanathos

    Seeker

  • Active Members
  • 34 posts

Posted 24 May 2012 - 10:10 PM

Would still appreciate some help please

Edited by xanathos, 24 May 2012 - 10:10 PM.


#16 xanathos

xanathos

    Seeker

  • Active Members
  • 34 posts

Posted 28 May 2012 - 05:19 PM

up

#17 xanathos

xanathos

    Seeker

  • Active Members
  • 34 posts

Posted 29 May 2012 - 11:39 PM

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

#18 BrewManNH

BrewManNH

    באָבקעס מיט קודוצ׳ה

  • MVPs
  • 6,852 posts

Posted 29 May 2012 - 11:43 PM

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

How to ask questions the smart way!

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 editorGUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.

GUIToolTip UDF Demo - Demo script to show how to use the GUIToolTip UDF to create and use customized tooltips.

Posted Image


#19 xanathos

xanathos

    Seeker

  • Active Members
  • 34 posts

Posted 29 May 2012 - 11:57 PM

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

AutoIt         
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, 30 May 2012 - 12:01 AM.


#20 BrewManNH

BrewManNH

    באָבקעס מיט קודוצ׳ה

  • MVPs
  • 6,852 posts

Posted 30 May 2012 - 12:12 AM

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?

How to ask questions the smart way!

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 editorGUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.

GUIToolTip UDF Demo - Demo script to show how to use the GUIToolTip UDF to create and use customized tooltips.

Posted Image





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users