Jump to content
Sign in to follow this  
LordBoling

Script not working (Problems solved! Thanks.)

Recommended Posts

LordBoling

Hello everyone! Hope you are having great days.

I unfortunately am in need of assistance.

I am in the process of creating a program that will allow me to search 2 systems that my company uses that store customer info.

At this time if a customer places an order it could be in our online only system, our in-store system, or both at the same time. So instead of searching one manually, then the other, I decided to code a script that would look in both at the same time until it find the order. It has a few issues though.

Issue #1 (Solved, Thank you BrewManNH!): I have two GUIs that I created, but apparently created wrong as the first one never closes until the script ends completely or if they press the red X, but is supposed to close when the user presses okay, but not end the script. This GUI is called in my code by a function called RefGui().

Issue #2 (Solved): This same GUI is supposed to return a reference id entered by the user in an input field and what type of reference number it is by selecting a radio button. However, when used like it was intended it only returns the data from the input field. If nothing is put in the input field then it will return both the data in the input field and which radio selection is made.

I have other issues but will probably deal with them once I have those figured out. If someone could take a look at my code and give me some ideas I would appreciate it.

#include "CSV.au3"
#include "Array.au3"
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <StaticConstants.au3>
#include <ButtonConstants.au3>
Opt("WinWaitDelay",100)
Opt("WinDetectHiddenText",1)
Opt("MouseCoordMode",0)
Opt("SendCapslockMode",1)

$objErr = ObjEvent("AutoIt.Error","MyErrFunc")


;Open Connection to OsCommerce database
$oConn = ObjCreate("ADODB.Connection")
$oConn.Open(;Connection string to my first database)

;Open Connection to Mas90 database
$conn = ObjCreate("ADODB.Connection")
$DSN = ;Connection string for my second database
$conn.Open($DSN)

;Define var for reference type as global w/ initial value/Moved per BrewManNH's suggestion
Global $refType="Internet"
;Loop until user closes first GUI w/ close button
While 1
;~ ;Define var for reference type as global w/ initial value
;~ Global $refType="Internet"
;Ask for order number or invoice number: (This opens first gui)
$refNum=RefGui()
;Start text var to display message.
$OrderMsg=$refNum & @CRLF & $refType
;If user selected internet search OsCommerce. Otherwise this won't be necessarily.
If $refType="Internet" Then
;Query status and comments
$rs = $oConn.Execute("SELECT orders.orders_status,orders_status_history.comments FROM orders,orders_status_history WHERE orders.orders_id='"& $refNum &"' AND orders_status_history.orders_status_id=orders.orders_status AND orders_status_history.orders_id=orders.orders_id")
;Make sure a result was returned then get results
If IsObj($rs) And $rs.EOF=False Then
  $osStatus = $rs.GetRows()

  $rs = $oConn.Execute("SELECT orders_status_name FROM orders_status WHERE orders_status_id ='"& $osStatus[UBound($osStatus)-1][0] &"'")
  $temp=$rs.GetRows()
  $osStatus[UBound($osStatus)-1][0]=$temp[0][0]

  $OrderMsg+="OsCommerce:" & @CRLF
  $OrderMsg+=@TAB & "Status:" & $osStatus[UBound($osStatus)-1][0] & @CRLF
  $OrderMsg+=@TAB & "Comments:" & $osStatus[UBound($osStatus)-1][1] & @CRLF

Else
  $osStatus = 0
EndIf
EndIf
;If internet or sales were chosen then check if it has been put in Mas90 yet.
If $refType="Internet" Or $refType="Sales" Then
$rs = $conn.Execute("SELECT OrderType FROM SO_SalesOrderHeader WHERE (SalesOrderNo='"& $refNum &"')")
If IsObj($rs) And $rs.EOF=False Then
  $SOStatus = $rs.GetRows()

  $OrderMsg+="Sales Order:" & @CRLF
  $OrderMsg+=@TAB & "Status:" & $SOStatus[0][0] & @CRLF

  $rs = $conn.Execute("SELECT ItemCode,ItemCodeDesc,QuantityOrdered,QuantityBackordered FROM SO_SalesOrderDetail WHERE (SalesOrderNo='"& $refNum &"' AND ItemType='1')")
  If IsObj($rs) And $rs.EOF=False Then
   $SOItems = $rs.GetRows()
  
   $OrderMsg+=@TAB & "Items:" & @CRLF
  
   $i=0
   While $i<UBound($SOItems)-1
    $OrderMsg+=@TAB & @TAB & "(" & $SOItems[$i][0] & ") " & $SOItems[$i][1] & @CRLF
  
    $rs = $conn.Execute("SELECT TotalQuantityOnHand FROM CI_Item WHERE (ItemCode='"& $SOItems[$i][0] &"')")
    If IsObj($rs) And $rs.EOF=False Then
     $item = $rs.GetRows()
    
     $OrderMsg+=@TAB & @TAB & "Ordered/Available: " & $SOItems[$i][2] & "/" & $item[0][0] & @TAB & "Backordered: " & $SOItems[$i][3] & @CRLF
    EndIf
    $i+=1
   WEnd

  Else
   $SOItems = 0
  EndIf
Else
  $SOStatus = 0
EndIf

$rs = $conn.Execute("SELECT InvoiceNo, SalesOrderNo FROM SO_InvoiceHeader WHERE (SalesOrderNo='"& $refNum &"')")
If IsObj($rs) And $rs.EOF=False Then
  $InvStatus = $rs.GetRows()

  $rs = $conn.Execute("SELECT InvoiceNo,ItemCode,ItemCodeDesc,QuantityOrdered,QuantityBackordered FROM SO_InvoiceDetail WHERE (InvoiceNo='"& $InvStatus[0][0] &"' AND ItemType=1)")
  If IsObj($rs) And $rs.EOF=False Then
   $InvItems = $rs.GetRows()
  Else
   $InvItems = 0
  EndIf
Else
  $InvStatus = 0
EndIf

$rs = $conn.Execute("SELECT InvoiceNo, SalesOrderNo FROM AR_InvoiceHistoryHeader WHERE (SalesOrderNo='"& $refNum &"')")
If IsObj($rs) And $rs.EOF=False Then
  $InvHst = $rs.GetRows()
  $rs = $conn.Execute("SELECT InvoiceNo,ItemCode,ItemCodeDesc,QuantityOrdered,QuantityBackordered FROM AR_InvoiceHistoryDetail WHERE (InvoiceNo='"& $InvHst[0][0] &"' AND ItemType=1)")
  If IsObj($rs) And $rs.EOF=False Then
   $InvItems = $rs.GetRows()
  Else
   $InvItems = 0
  EndIf
Else
  $InvHst = 0
EndIf

ElseIf $refType="Invoice" Then
$rs = $conn.Execute("SELECT InvoiceNo, SalesOrderNo FROM AR_InvoiceHistoryHeader WHERE (InvoiceNo='"& $refNum &"')")
If IsObj($rs) And $rs.EOF=False Then
  $InvHst = $rs.GetRows()
  $rs = $conn.Execute("SELECT InvoiceNo,ItemCode,ItemCodeDesc,QuantityOrdered,QuantityBackordered FROM AR_InvoiceHistoryDetail WHERE (InvoiceNo='"& $refNum &"' AND ItemType=1)")
  If IsObj($rs) And $rs.EOF=False Then
   $InvItems = $rs.GetRows()
  Else
   $InvItems = 0
  EndIf
Else
  $InvHst = 0
EndIf
EndIf
Gui($OrderMsg)

WEnd

;This is the second GUI that displays the results
Func Gui($txt)
    Local $myedit, $msg
    $hGUI=GUICreate("Details:", 500, 300, Default, Default,$WS_OVERLAPPEDWINDOW) ; will create a dialog box that when displayed is centered
$GUISize=WinGetClientSize($hGUI)
$myedit = GUICtrlCreateEdit($txt,-1, -1, $GUISize[0], $GUISize[1],$ES_READONLY)
GUICtrlSetResizing ( $myedit, $GUI_DOCKBORDERS )
    GUISetState()
DllCall("user32.dll","int","HideCaret","int",0)

Send("{END}")
    ; Run the GUI until the dialog is closed
    While 1
        $msg = GUIGetMsg()
        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd
    GUIDelete($hGUI)
EndFunc

;This is the first GUI. It asks for the information required to look up the order
Func RefGui()
$RefGui = GUICreate("Reference#", 261, 156, -1, -1)
GUISetFont(10, 400, 0, "Verdana")
GUICtrlCreateLabel("Enter Reference:", 15, 12, 116, 20)
$RefNum = GUICtrlCreateInput("REFERENCE #", 136, 8, 110, 24, BitOR($GUI_SS_DEFAULT_INPUT,$ES_UPPERCASE))
$OK = GUICtrlCreateButton("OK", 176, 120, 75, 25, BitOR($BS_DEFPUSHBUTTON,$BS_NOTIFY))
GUICtrlCreateGroup("Select Ref Type:", 16, 40, 145, 105, BitOR($GUI_SS_DEFAULT_GROUP,$WS_CLIPSIBLINGS))
$Internet = GUICtrlCreateRadio("Internet Order", 24, 64, 113, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
$Sales = GUICtrlCreateRadio("Sales Order", 24, 88, 113, 17)
$Invoice = GUICtrlCreateRadio("Invoice", 24, 112, 113, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
While 1
  $nMsg = GUIGetMsg()
  If $nMsg = $GUI_EVENT_CLOSE Then Exit

  If $nMsg = $OK Then
   ExitLoop
  EndIf
WEnd
If GUICtrlRead($Internet) = 1 Then
  $refType="Internet"
ElseIf GUICtrlRead($Sales) = 1 Then
  $refType="Sales"
ElseIf GUICtrlRead($Invoice) = 1 Then
  $refType="Invoice"
EndIf

$temp=GUICtrlRead($RefNum)
GUIDelete($RefGui)
Return $temp
EndFunc

Func MyErrFunc()
$hexnum=hex($objErr.number,8)
Msgbox(0,"","We intercepted a COM Error!!"    & @CRLF               & @CRLF & _
             "err.description is: " & $objErr.description   & @CRLF & _
             "err.windescription is: " & $objErr.windescription & @CRLF & _
             "err.lastdllerror is: "   & $objErr.lastdllerror   & @CRLF & _
             "err.scriptline is: "   & $objErr.scriptline   & @CRLF & _
             "err.number is: "     & $hexnum               & @CRLF & _
             "err.source is: "     & $objErr.source     & @CRLF & _
             "err.helpfile is: "       & $objErr.helpfile     & @CRLF & _
             "err.helpcontext is: " & $objErr.helpcontext _
            )
exit
EndFunc

Here is just the code for the first GUI so you don't have to look through all that:

Func RefGui()
$RefGui = GUICreate("Reference#", 261, 156, -1, -1)
GUISetFont(10, 400, 0, "Verdana")
GUICtrlCreateLabel("Enter Reference:", 15, 12, 116, 20)
$RefNum = GUICtrlCreateInput("REFERENCE #", 136, 8, 110, 24, BitOR($GUI_SS_DEFAULT_INPUT,$ES_UPPERCASE))
$OK = GUICtrlCreateButton("OK", 176, 120, 75, 25, BitOR($BS_DEFPUSHBUTTON,$BS_NOTIFY))
GUICtrlCreateGroup("Select Ref Type:", 16, 40, 145, 105, BitOR($GUI_SS_DEFAULT_GROUP,$WS_CLIPSIBLINGS))
$Internet = GUICtrlCreateRadio("Internet Order", 24, 64, 113, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
$Sales = GUICtrlCreateRadio("Sales Order", 24, 88, 113, 17)
$Invoice = GUICtrlCreateRadio("Invoice", 24, 112, 113, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
While 1
  $nMsg = GUIGetMsg()
  If $nMsg = $GUI_EVENT_CLOSE Then Exit

  If $nMsg = $OK Then
   ExitLoop
  EndIf
WEnd
If GUICtrlRead($Internet) = 1 Then
  $refType="Internet"
ElseIf GUICtrlRead($Sales) = 1 Then
  $refType="Sales"
ElseIf GUICtrlRead($Invoice) = 1 Then
  $refType="Invoice"
EndIf

$temp=GUICtrlRead($RefNum)
GUIDelete($RefGui)
Return $temp
EndFunc
Edited by LordBoling

Share this post


Link to post
Share on other sites
BrewManNH

First, your GUIDelete is after the Return statement so it's never going to get acted on, you'll need to move it to before the Return statement. BUT, and this is extremely important, first read the contents of the $refnum input box and assign it to a variable, and then use the variable in the Return statement. If you don't do this, there's no control to read from anymore, so the contents will be lost when you delete the GUI.

Second, you should probably move the declaration of the variables outside of the While loop, it can slow the script down, just move the Global $reftype line to before the While 1 line.


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
LordBoling

BrewManNH, Awesome!! Thank you, that solved the first issue perfectly, the RefGui now closes like it is supposed to. I knew I had to check the value before deleting the GUI but had forgotten that the Return keyword exits the function.

Unfortunately I still have the second issue. I predefined $refType as "Internet", but after RefGui() is called, it becomes blank. Anyone got any ideas on what is causing this? I did move the initial declaration outside of the loop as BrewManNH suggested but that did not affect what it is set to after the gui is called.

Updated code can be seen in the first post.

Share this post


Link to post
Share on other sites
Zedna

If you need to reeturn more values from functions use ByRef parameters like this (tested,working):

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <StaticConstants.au3>
#include <ButtonConstants.au3>

Global $RefNum, $RefType

RefGui($RefNum, $RefType)
MsgBox (0, 'RefGui result', $RefNum & ' - ' & $RefType)

Func RefGui(ByRef $num, ByRef $type)
    $RefGui = GUICreate("Reference#", 261, 156, -1, -1)
    GUISetFont(10, 400, 0, "Verdana")
    GUICtrlCreateLabel("Enter Reference:", 15, 12, 116, 20)
    $RefNum_id = GUICtrlCreateInput("REFERENCE #", 136, 8, 110, 24, BitOR($GUI_SS_DEFAULT_INPUT,$ES_UPPERCASE))
    $OK = GUICtrlCreateButton("OK", 176, 120, 75, 25, BitOR($BS_DEFPUSHBUTTON,$BS_NOTIFY))
    GUICtrlCreateGroup("Select Ref Type:", 16, 40, 145, 105, BitOR($GUI_SS_DEFAULT_GROUP,$WS_CLIPSIBLINGS))
    $Internet = GUICtrlCreateRadio("Internet Order", 24, 64, 113, 17)
    GUICtrlSetState(-1, $GUI_CHECKED)
    $Sales = GUICtrlCreateRadio("Sales Order", 24, 88, 113, 17)
    $Invoice = GUICtrlCreateRadio("Invoice", 24, 112, 113, 17)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    GUISetState(@SW_SHOW)
    While 1
      $nMsg = GUIGetMsg()
      If $nMsg = $GUI_EVENT_CLOSE Then Exit

      If $nMsg = $OK Then
       ExitLoop
      EndIf
    WEnd

    If GUICtrlRead($Internet) = 1 Then
      $Type="Internet"
    ElseIf GUICtrlRead($Sales) = 1 Then
      $Type="Sales"
    ElseIf GUICtrlRead($Invoice) = 1 Then
      $Type="Invoice"
    EndIf

    $num=GUICtrlRead($RefNum_id)
    GUIDelete($RefGui)
EndFunc

Also check if you don't have the same variable names more than once (local x global)

I see $RefNum is such case

Share this post


Link to post
Share on other sites
Zedna

Also it's better (more safe) to use

If IsChecked($Internet) Then
      $Type="Internet"
    ElseIf IsChecked($Sales) Then
      $Type="Sales"
    ElseIf IsChecked($Invoice) Then
      $Type="Invoice"
    EndIf

Func IsChecked($control)
    Return BitAnd(GUICtrlRead($control),$GUI_CHECKED) = $GUI_CHECKED
EndFunc
Edited by Zedna

Share this post


Link to post
Share on other sites
BrewManNH

What makes you think that $reftype is getting blanked after the function returns? I tested parts of your script and it worked for me, but I can't test all of it because the script won't run as written.


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
LordBoling

Sorry guys. My bad. It was not returning blank. I was appending it to other variables using += instead of &=. This caused some issues of course. Once I fixed that everything seems to be working great.

Thank you for all the help guys.

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  

  • Similar Content

    • Blois
      By Blois
      Hi Guis,
       
      I need to create keyboard shortcut to navigate the tabs and activate them, but I could not use the code below:
      #include <TabConstants.au3> #include <WindowsConstants.au3> #include <GuiTab.au3> #include <GUIConstantsEx.au3> HotKeySet("^{TAB}", "_TabRight") HotKeySet("^+{TAB}", "_TabLeft") $gui = GUICreate("test",450, 300) $Tab1 = GUICtrlCreateTab(20, 24, 425, 201) $TabSheet1 = GUICtrlCreateTabItem("Tabsheet 1") $lbContagemGrupos2 = GUICtrlCreateLabel("aaaa", 50, 50) GUICtrlSetColor(-1, 0x0000FF) GUICtrlCreateTabItem("") $TabSheet2 = GUICtrlCreateTabItem(" ") $TabSheet3 = GUICtrlCreateTabItem(" ") GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd Func _TabRight() $CurPos = _GUICtrlTab_GetCurSel($Tab1) _GUICtrlTab_SetCurSel($Tab1, $CurPos + 1) $tab = "$TabSheet" & $CurPos GUICtrlSetState($TabSheet1 + $CurPos, $GUI_SHOW) Return EndFunc Func _TabLeft() $CurPos = _GUICtrlTab_GetCurSel($Tab1) _GUICtrlTab_SetCurSel($Tab1, $CurPos - 1) $tab = "$TabSheet" & $CurPos GUICtrlSetState($TabSheet1 + $CurPos, $GUI_SHOW) Return EndFunc Exit  
      can you help me?
    • Pricehacker
      By Pricehacker
      Hello again!
      I have tried searching for quite some time now but couldn´t find a single working way to change the class of your GUI that doesn´t include changing it manually after its compilation.
      First or "AutoIt v3 GUI" is a pretty boring name tbh and i would like to spice it up a bit, also, and more importantly, I would like to identify my windows by something other than its title as it will change depending on some factors and im using two different programs independently as multi threading isn't supported.
      Any help is appreciated! Thank you!
    • xtcislove
      By xtcislove
      Hello, 
      i have a Problem with  _WinAPI_SetLayeredWindowAttributes, everything is working as excepted if u are on Windows 7.

      But if u are on Windows 10 the transparent background of a control is not clickable anymore. 

      Could someone help?

      Please see example below, put cmd.jpg into the same folder as Example.au3

      Please see trigger.jpg to see which sections are not clickable in Windows 10 (the red dots, the green dots are clickable) on Windows 7 the red ones and green ones are clickable.
       
      The same problem occurs if i use 
       
       
      Example.au3


    • WilliamasKumeliukas
      By WilliamasKumeliukas
      Hello everyones reading this post,
      I'm struggling at resizing properly my radio buttons to fit long text inside without affecting others radio buttons and also adjust position of them relative to the string.
      I tried with _StringSize UDF but I guess im too tired to figure out how to use it correctly..
      I also tried: _Control_SetWidth2Text I found on this forum, it work aslong im not maximizing GUI (radio text is gone when I maximize and maximize is a must)
       
      here is the code example, I hope someone can figure out (sorry if guictrlsetpos is not included in the example, I know thats probably the way to go but I wanted to make sure there is nothing better before use it)
      Thank you
       
      Br,
      ~WilliamasKumeliukas
       
      #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <Array.au3> #include <StringConstants.au3> #include <FileConstants.au3> #include <WindowsConstants.au3> #include <File.au3> #include <EditConstants.au3> #include <GUIListBox.au3> #include <ButtonConstants.au3> #include <ProgressConstants.au3> #include <ColorConstants.au3> #include <AutoitConstants.au3> #include <Misc.au3> #include <WinAPIReg.au3> #include <WinAPI.au3> #Region Opt's Opt("GUIResizeMode", 802) #EndRegion Opt's Global $q = "INTRO LINE" & @CRLF & @CRLF & "description of everything until user press start." Global $file = @TempDir & "\test.p" destroy() Global $msg, $score = 0, $rate, $com, $total = 0, $cfile, $cq, $i = 0, $time = 0, $min = 0, $sec = 0, $hour = 0, $qf, $ii = 0 Main() Func Main() Global $iGUIInitSize = 550 #Region GUI Opt("GUICloseOnEsc", 1) Global $gui = GUICreate("example", 1124, 550,-1 ,-1, BitOR($WS_MAXIMIZEBOX , $WS_MINIMIZEBOX)) Global $gui_size = WinGetClientSize($gui) Global $iFontSize = Int(2 * (.25 + (8 * $gui_size[0] / $iGUIInitSize))) / 2 Global $options = GUICtrlCreateMenu("&Options") Global $guide = GUICtrlCreateMenuItem("Guide", $options) Global $restart = GUICtrlCreateMenuItem("Restart", $options) Global $about = GUICtrlCreateMenuItem("About", $options) Global $exit = GUICtrlCreateMenuItem("Exit", $options) Global $extra = GUICtrlCreateMenu("Extras") Global $creator = GUICtrlCreateMenu("CQB", $extra ) Global $new = GUICtrlCreateMenuItem("custom QP", $creator) Global $load = GUICtrlCreateMenuItem("CQ", $creator ) Global $timer = GUICtrlCreateLabel("", 752, 472, 294, 30, $WS_BORDER) GUICtrlSetResizing(-1, BitOR($GUI_DOCKHCENTER, $GUI_DOCKVCENTER) ) GUICtrlSetFont(-1, $iFontSize) GUICtrlSetState($timer, $GUI_HIDE) Global $info = GUICtrlCreateLabel( $q, 200, 20, 700, 200, $SS_CENTER ) GUICtrlSetResizing(-1, BitOR($GUI_DOCKHCENTER, $GUI_DOCKVCENTER) ) $fi = GUICtrlSetFont($info, $iFontSize) Global $a = GUICtrlCreateRadio("A)", 100, 210, $WS_EX_CLIENTEDGE) $fa = GUICtrlSetFont($a, 15) GUICtrlSetResizing(-1, BitOR($GUI_DOCKHCENTER, $GUI_DOCKVCENTER) ) GUICtrlSetState($a, 16) Global $b = GUICtrlCreateRadio("B)", 100, 310 , $WS_EX_CLIENTEDGE) $fb = GUICtrlSetFont($b, 15) GUICtrlSetResizing(-1, BitOR($GUI_DOCKHCENTER, $GUI_DOCKVCENTER) ) GUICtrlSetState($b, 16) Global $c = GUICtrlCreateRadio("C)", 750, 210 , $WS_EX_CLIENTEDGE) $fc = GUICtrlSetFont($c, 15) GUICtrlSetResizing(-1, BitOR($GUI_DOCKHCENTER, $GUI_DOCKVCENTER) ) GUICtrlSetState($c, 16) Global $d = GUICtrlCreateRadio( "D) ", 750, 310, $WS_EX_CLIENTEDGE) $fd = GUICtrlSetFont($d, 15) GUICtrlSetResizing (-1, BitOR($GUI_DOCKHCENTER, $GUI_DOCKVCENTER) ) GUICtrlSetState($d, 16) Global $sign = GUICtrlCreateLabel( $file, 420, 480, -1, -1, BitOR ( $SS_CENTER, $WS_BORDER ) ) GUICtrlSetResizing ( -1, BitOR ( $GUI_DOCKHCENTER, $GUI_DOCKVCENTER ) ) GUICtrlSetFont($sign, 12) Global $yb = GUICtrlCreateRadio("True", 200, 420, 200, 50, $BS_PUSHLIKE) GUICtrlSetResizing(-1, BitOR($GUI_DOCKHCENTER, $GUI_DOCKVCENTER,$GUI_DOCKSIZE)) GUICtrlSetFont($yb, 15) GUICtrlSetState($yb, 32) Global $nb = GUICtrlCreateRadio("False", 700, 420, 200, 50, $BS_PUSHLIKE) GUICtrlSetResizing(-1, BitOR($GUI_DOCKHCENTER, $GUI_DOCKVCENTER, $GUI_DOCKSIZE)) GUICtrlSetFont($nb, 15) GUICtrlSetState($nb, 32) Global $start = GUICtrlCreateButton("Start", 20, 20, 100, 50, $SS_CENTER, $WS_EX_CLIENTEDGE) GUICtrlSetResizing(-1, BitOR($GUI_DOCKHCENTER, $GUI_DOCKVCENTER)) GUICtrlSetFont($start, 12) Global $valid = GUICtrlCreateButton("Confirm", 20, 20, 100, 50, $SS_CENTER, $WS_EX_CLIENTEDGE) GUICtrlSetResizing(-1, BitOR($GUI_DOCKHCENTER, $GUI_DOCKVCENTER)) GUICtrlSetFont($valid, 12) GUICtrlSetState($valid, 32) GUISetState(@SW_SHOW) #EndRegion GUI While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Switch MsgBox(4096 + 4, "Warning", "Are you sure to exit?") Case 6 AdlibUnRegister("timer") If Not $qf = "" Then FileClose($file) EndIf Exit Case 7 ContinueLoop EndSwitch Case $start ;AdlibRegister("timer") ;Global $qf = StringSplit(StringStripWS(FileRead($file), 6), @CRLF, 0) ;qloop($file) GUICtrlSetData($a, "A) This long string is an example as string that I want to fit in 4 radio buttons because sometimes it can be that long.") GUICtrlSetData($b, "B) This long string is an example as string that I want to fit in 4 radio buttons because sometimes it can be that long.") GUICtrlSetData($c, "C) This long string is an example as string that I want to fit in 4 radio buttons because sometimes it can be that long.") GUICtrlSetData($d, "D) This long string is an example as string that I want to fit in 4 radio buttons because sometimes it can be that long.") Case $restart MsgBox(4096, "Warning", 'Normally, your suposed to start something before restarting it.') ContinueLoop Case $new ;GUISetState(@SW_HIDE, $gui) ;_CustomNew() ContinueLoop Case $load ;_CustomLoad() Case $about ;_About() EndSwitch WEnd EndFunc ;Main() Func timer() If $time = 0 Then Global $time = TimerInit() Global $diff = TimerDiff($time) Global $sec = Int(Mod($diff / 1000, 60)) Global $min = Int(Mod($diff / 60000, 60)) Global $hour = Int($diff / 3600000) If $sec < 10 Then $sec = "0" & $sec If $min < 10 Then $min = "0" & $min If $hour < 10 Then $hour = "0" & $hour GUICtrlSetData($timer, "Temps: " & $hour & ":" & $min & ":" & $sec) EndFunc ;==>timer Func destroy() If FileExists($file) Then FileDelete($file) EndIf DirCreate(@TempDir & "\About") FileInstall("C:\test.txt", $file) EndFunc ;==>destroy  
    • xtcislove
      By xtcislove
      Hello,

      im searching like 6 hours and i didnt found the right solution.

      Im trying to build a treeview from a directory and its subfolders etc.

      This function give me right treeview, but i cant color each item seperated.

       
      #include <GuiTreeView.au3> $hGui = GUICreate("Demo1", 600, 400) $hTreeView = _GUICtrlTreeView_Create($hGui, 10, 10, 580, 380) GUISetState() _GUICtrlTreeView_BeginUpdate($hTreeView) ListFiles_ToTreeView(@ScriptDir, 0) _GUICtrlTreeView_EndUpdate($hTreeView) Do Until GUIGetMsg() = -3 Func ListFiles_ToTreeView($sSourceFolder, $hItem) Local $sFile ; Force a trailing \ If StringRight($sSourceFolder, 1) <> "\" Then $sSourceFolder &= "\" ; Start the search Local $hSearch = FileFindFirstFile($sSourceFolder & "*.*") ; If no files found then return If $hSearch = -1 Then Return ; This is where we break the recursive loop <<<<<<<<<<<<<<<<<<<<<<<<<< ; Now run through the contents of the folder While 1 ; Get next match $sFile = FileFindNextFile($hSearch) ; If no more files then close search handle and return If @error Then ExitLoop ; This is where we break the recursive loop <<<<<<<<<<<<<<<<<<<<<<<<<< ; Check if a folder If @extended Then ; If so then call the function recursively ListFiles_ToTreeView($sSourceFolder & $sFile, _GUICtrlTreeView_AddChild($hTreeView, $hItem, $sFile)) Else ; If a file than write path and name _GUICtrlTreeView_AddChild($hTreeView, $hItem, $sFile) EndIf WEnd ; Close search handle FileClose($hSearch) EndFunc ;==>ListFiles_ToTreeView
      So i am searching for the exact same function just with
      GUICtrlCreateTreeViewItem
      instead of 
      _GUICtrlTreeView_AddChild
       
      Ps: i have a folder structure where i like to color each item green if a file only exist once and red if it exist more than once.

      Could someone help?
       
      Solution:

       
       
×