MaxEdman Posted July 29, 2014 Share Posted July 29, 2014 (edited) Hello, I'm using AutoIT v 3.3.10.2. Hopefully this version is late enough. I just checked for updates and saw the new 3.3.12.0. But I don't think that will solve my issue. The problem I'm having is that when I'm handling an array used in a WM_COMMAND function AutoIT just stops responding. Hopefully the code below is enough to understand the problem. Both _ArrayDisplay($arr_earlier_errands_2) and _showMyErrandsGUI($arr_earlier_errands) arrayfunctions makes AutoIT tonot respond. If I use the exact same code outside the function "_WM_COMMAND_FUNC" it will work properly. I'm using my SQL-functions all over the script without any problem. But at this point it just won't work. I'm starting to get frustrated. Anyone have a sollution? Thanks! Max Edman expandcollapse popupGUIRegisterMsg($WM_COMMAND, "_WM_COMMAND_FUNC") Global $input_mobilenumber = GUICtrlCreateInput("", 216, 139, 201, 26, BitOR($GUI_SS_DEFAULT_INPUT,$ES_NUMBER)) Func _WM_COMMAND_FUNC($hwnd_main, $imsg, $iwParam, $ilParam) Local $setHK = False Local $nNotifyCode = BitShift($iwParam, 16) Local $nID = BitAND($iwParam, 0x0000FFFF) Local $hwnd_GUICtrl = $ilParam ;~ ; Hanterar enbart de meddelanden If $nNotifyCode = $EN_CHANGE Then If $hwnd_GUICtrl = GUICtrlGetHandle($input_mobilenumber) Then Local $s_mobile_number = GUICtrlRead($input_mobilenumber) If StringRegExp($s_mobile_number, "\A(07[0-9]{8})") And StringLen($s_mobile_number) = 10 Then ;~ ; Om värdet för mobilnummer uppfyller kraven för hur ett mobilnummer ser ut så söks detta igenom i databasen. Local $obj_SQL_conn = _SQL_connect_Automate_Levstat() Local $i_number_of_records = _SQLCountRows($obj_SQL_conn, "*tableName*", "*colName", $s_mobile_number) ;~ ; Hittas inga ärenden på detta mobilnummer så returneras 1 direkt. If $i_number_of_records = 0 Then _SQLDisconnect($obj_SQL_conn) Return 1 ;~ ; Annars ställs frågan om användaren vill se dessa ärenden. ElseIf $i_number_of_records > 0 Then If MsgBox(BitOR(4, 32, 262144), "", "*SomeQuestion*") = 6 Then Local $s_SQL_query = "SELECT * FROM *tableName* WHERE " & '*colName*"=' & "'" & $s_mobile_number & "';" ConsoleWrite($s_SQL_query & @CRLF) Local $arr_earlier_errands_2 = _SQLGetArray($obj_SQL_conn, $s_SQL_query) If @error Then MsgBox(0, "", "Funktion: _SQLGetArray" & @CRLF & @error & @CRLF & @extended) _SQLDisconnect($obj_SQL_conn) _ArrayDisplay($arr_earlier_errands_2) _showMyErrandsGUI($arr_earlier_errands) Return 1 ;~ Else Return 1 EndIf ; <== If MsgBox(BitOR(4, 32, 262144), "", "*someQuestion*") = 6 Then EndIf EndIf ; <== If StringRegExp($s_mobile_number, "\A(07[0-9]{8})") Then EndIf ; <== If $hwnd_GUICtrl = GUICtrlGetHandle($input_mobilenumber) Then EndIf ; <== If $nNotifyCode = $EN_CHANGE Then EndFunc ;==>My_WM_COMMAND Edited July 29, 2014 by MaxEdman Link to comment Share on other sites More sharing options...
jchd Posted July 29, 2014 Share Posted July 29, 2014 When you are inside the function, the message pump is locked and subsequent messages are queued. You must return as quickly as possible so that normal Windows processing can continue. There is a warning in GUIRegisterMsg about this. It certainly isn't the place to connect to a remote SQL engine and query it! Also the lockup occurs when you try to affect the GUI: the message pump is waiting for your function to return (quickly) but instead you instruct it to perform actions (_ArrayDisplay, MsgBox and such) that queue in the locked message pump. You have created a deadlock condition. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
MaxEdman Posted July 29, 2014 Author Share Posted July 29, 2014 When you are inside the function, the message pump is locked and subsequent messages are queued. You must return as quickly as possible so that normal Windows processing can continue. There is a warning in GUIRegisterMsg about this. It certainly isn't the place to connect to a remote SQL engine and query it! Also the lockup occurs when you try to affect the GUI: the message pump is waiting for your function to return (quickly) but instead you instruct it to perform actions (_ArrayDisplay, MsgBox and such) that queue in the locked message pump. You have created a deadlock condition. Ok! Thanks. What is the smartest way of get the Returnmessage from this function? So that I can continue my coding when the above is correct? Link to comment Share on other sites More sharing options...
Solution j0kky Posted July 29, 2014 Solution Share Posted July 29, 2014 There is an useful tutorial about GUIRegisterMsg! Spoiler Some UDFs I created: Winsock UDF STUN UDF WinApi_GetAdaptersAddresses _WinApi_GetLogicalProcessorInformation Bitwise with 64 bit integers An useful collection of zipping file UDFs Link to comment Share on other sites More sharing options...
MaxEdman Posted July 29, 2014 Author Share Posted July 29, 2014 There is an useful tutorial about GUIRegisterMsg! Sorry, my bad! The tutorial was very helpful! Thanks! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now