
LordBoling
Active Members-
Posts
20 -
Joined
-
Last visited
Profile Information
-
Location
Arizona
LordBoling's Achievements
-
LordBoling reacted to a post in a topic: Solved! StringRegExpReplace Left 0 Padding: Solved!
-
Kidney: Sorry if I was not clear. My last example, 6000002, is an example of a number that did not work with my code. jdelaney: Thank you! Your solution works perfectly. I was just too focused on RegExReplace and didn't think about using the standard RegEx to return an array. kylomas: Thank you as well. I am not sure what Non-SRE stands for, but your solution works great when I need to check numbers from the website. corgano: Well, I guess I should have tried that. It was the first thing that I considered, but I thought (0*) is a greedy match and that it would stop the next group from selecting a 0. Instead of assuming I should have checked. That is the simplest solution to my problem I believe. I appreciate everyone getting back to me so quickly.
- 8 replies
-
- padding
- stringregexpreplace
-
(and 2 more)
Tagged with:
-
(HELP IM NEW) error parsing function call
LordBoling replied to NizonRox's topic in AutoIt General Help and Support
NizonRox, If you are trying to compare text with your IF functions, then the text needs to be within quotes: MouseClick ( "LEFT", 984, 206, 1, 1) Sleep(500) Local $shiny = WinGetText("[CLASS:Chrome]", "Shiny") Local $dark = WinGetText("[CLASS:Chrome]", "Dark") Local $mystic = WinGetText("[CLASS:Chrome]", "Mystic") Local $ancient = WinGetText("[CLASS:Chrome]", "Ancient") if $shiny > "Shiny" Then Exit 0 EndIf if $dark > "Dark" Then Exit 0 EndIf If $mystic > "Mystic" Then Exit 0 EndIf If $ancient > "Ancient" Then Exit 0 EndIf That will get rid of the error, though since I don't know what you are trying to do with it, I don't know if it will function as you want it to. -
Is it possible to left pad a matched group? Here is my situation. I am working on a program to integrate inventory from my companies warehouse with our website. Our part numbers in our Warehouse inventory look like this: 1501895, 1000973, 5000165, 6000002, etc. On our website, these same numbers would look like this: 15-1895, 1-973,5-165, 6-02 My program monitors our warehouse inventory database for changes, and when a change is made it needs to find the matching item on our website. This is the code that I originally used: StringRegExpReplace($new_items[$i][0],"([1-9]{1,2})(0*)(\d{1,4})","$1-$3") However I noticed this does not work for numbers that match my last example. The last matched group needs to be zero padded if the number is less than 10. Does anyone have an idea of where to start for this? Is there a better way than how I have started?
- 8 replies
-
- padding
- stringregexpreplace
-
(and 2 more)
Tagged with:
-
Okay, so I did some checking on this and unfortunately there is no solution. My server does not allow for the connection timeout to be adjusted within the connection parameters. I will have to either open and close the connection for every query or adjust my actual server settings. Just thought I would post this in case anyone else has this issue.
-
Hi Everyone. So I am making a program that pulls orders down from my website and then enters them into an in house inventory management system. Unfortunately after making the first few queries the database connection seems to disconnect and I get this error: [MySQL][ODBC 5.1 Driver][mysqld-5.1.70-cll]MySQL server has gone away err.windescription is: Unspecified error err.number is: 80020009 This is the code that I use to connect to the database: Global $OSC = ObjCreate("ADODB.Connection") $OSC.ConnectionString="Provider=MSDASQL;Driver={MySQL ODBC 5.1 Driver};Server=OurServer;Database=DB;Uid=User;Pwd=ThePassword;" $OSC.Open() I also tried this to see if it would work: Global $OSC = ObjCreate("ADODB.Connection") $OSC.ConnectionTimeout=100000 $OSC.CommandTimeout=100000 $OSC.ConnectionString="Provider=MSDASQL;Driver={MySQL ODBC 5.1 Driver};Server=OurServer;Database=db;Uid=User;Pwd=ThePassword;wait_timeout=100000" $OSC.Open() I run my queries like this: $rs = $OSC.Execute("SELECT some, columns FROM some,tables WHERE some.customers_id = tables.customers_id AND orders_id="&$OscNum) If IsObj($rs) And $rs.EOF=False Then ;There is an order so get the details from last query Global $order_info = $rs.GetRows() EndIf To try to fix the issue I also tried running them by calling this in place of the first line in the above example: Func mysqlQuery(ByRef $DB,$query) If Not $DB.State() Then $DB.Open() $result=$DB.Execute($query) Return $result EndFunc I then process the information gained by this query and display it in a GUI for the user to verify. The user will accept the information and the automation begins. There are then a few more queries that run, however depending on the time it took to verify the information one of them always fails. If the user decides to walk away while the GUI is waiting then accepts it when they return the very next query fails. If they accept it immediately the last query usually fails. All the fixes above seem to produce the exact same results. I also tried opening and closing the database connection around every query which got rid of the error: $OSC.Open() $rs = $OSC.Execute("SELECT some, columns FROM some,tables WHERE some.customers_id = tables.customers_id AND orders_id="&$OscNum) If IsObj($rs) And $rs.EOF=False Then ;There is an order so get the details from last query Global $order_info = $rs.GetRows() $OSC.Close() EndIf However it appeared to take about five seconds to open and close the database for each query, which made the program significantly longer. I would employ that if needed but was hoping there was a better solution. Does anyone have any suggestions? Thank you. PS: I am not sure if ADODB is COM related or not. I thought it was but if this is not the right section and can be better answered in another section of the forum, please let me know. Thanks.
-
[SOLVED] Two of my buttons mysteriously don't work.
LordBoling replied to pugh's topic in AutoIt GUI Help and Support
Regarding your bonus question, you might look into WinList. It should be listed in order of top-most first. Check out this post by ProgAndy, it might be helpful in this area: Also, looking through your code I saw you did this a couple time: If FileExists($filename) Then Sleep(500) Else MsgBox(4096,"", $filename & " does not exist. Creating now...") DirCreate("C:mjrtHlprOEMgraph") EndIf I may be wrong or missing something but wouldn't this work more efficiently: If Not FileExists($filename) Then MsgBox(4096,"", $filename & " does not exist. Creating now...") DirCreate($filename) EndIf Hope this helps. -
Script not working (Problems solved! Thanks.)
LordBoling replied to LordBoling's topic in AutoIt GUI Help and Support
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. -
Script not working (Problems solved! Thanks.)
LordBoling replied to LordBoling's topic in AutoIt GUI Help and Support
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. -
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
-
Changing decrypt php to autoit
LordBoling replied to LordBoling's topic in AutoIt General Help and Support
I could do that or just pull the card number from the invoice. I am hoping to avoid that though. I wish I understood encryptions better. Though I have been coding for 6 years now I have never worked with encryptions before. -
Changing decrypt php to autoit
LordBoling replied to LordBoling's topic in AutoIt General Help and Support
Thanks JohnOne. I had thought so as well, which should mean that the proper way to decrypt this using autoit is the following: $CC = _Crypt_DecryptData($CC,$KEY,$CALG_AES_256) With the credit card number being $CC, the preset key as $KEY and as this is a 256bit Rijndael $CALG_AES_256 should be the correct hash id. However using this I get an error of 2, failed to decrypt. Am I doing something wrong? -
Changing decrypt php to autoit
LordBoling replied to LordBoling's topic in AutoIt General Help and Support
No ideas? -
Hey guys. I am stuck again. I have a website that takes orders and, of course, encrypts the card numbers. I have been trying to rewrite the PHP decryption to work in Autoit, but I have been having difficulties. Here is my PHP Function: function cc_decrypt($string,$key) { $key = md5($key); //to improve variance /* Open module, and create IV */ $td = mcrypt_module_open(MCRYPT_RIJNDAEL_256, '','cfb', ''); $key = substr($key, 0, mcrypt_enc_get_key_size($td)); $iv_size = mcrypt_enc_get_iv_size($td); $iv = substr($string,0,$iv_size); $string = substr($string,$iv_size); /* Initialize encryption handle */ if (mcrypt_generic_init($td, $key, $iv) != -1) { /* Encrypt data */ $c_t = mdecrypt_generic($td, $string); mcrypt_generic_deinit($td); mcrypt_module_close($td); return $c_t; } else { trigger_error("cc_decrypt(C): Unable to decrypt input", E_USER_NOTICE); } } I looked at Crypt but I could not find that it would work with a Rijndael encryption. I also need to be able to determine the IV. Does anyone have any ideas for me? Thanks.
-
Thank you. Looks to be exactly what I am looking for. Now off to research how to use it. Thanks again. Your suggestions for others have been very useful in my coding projects. I appreciate your helpfulness.
-
I have a GUI with a ListView populated by an array. I need the Gui to update with more controls when the user clicks on an item in the list. However I have no clue how to know when the user clicks on an item. If anyone has any suggestions I would appreciate it. Thanks. Here is the Gui if you need it. $Test = GUICreate("Test", 413, 298, 524, 167) $ListView1 = GUICtrlCreateListView("Qty|Description|Part Number|Total", 0, 0, 266, 129) _GUICtrlListView_SetExtendedListViewStyle($ListView1, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_TRACKSELECT)) _GUICtrlListView_AddArray($ListView1,$oProd) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd