AustrianOak Posted October 11, 2008 Share Posted October 11, 2008 expandcollapse popup#include <GuiConstantsEx.au3> #include <GuiEdit.au3> #include <WindowsConstants.au3> #include <GUIMenu.au3> #include <WindowsConstants.au3> #include <Constants.au3> #include <EditConstants.au3> #include <WinAPI.au3> Dim $hInput_GUI[6], $Input[6], $wProcsOld[6], $InputMenu[6] Global $lastdragIP = -1 Global Enum $idOpen = 1000, $idSave, $idInfo $GUI = GUICreate("Test", 300, 300) $button5 = GUICtrlCreateButton("", 100, 200, 40, 25) GUICtrlSetState(-1, $GUI_DEFBUTTON) GUISetState() $wProcHandle = DllCallbackRegister("_WindowProc", "ptr", "hwnd;uint;wparam;lparam") While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit Case $msg = $button5 If $lastdragIP < 5 Then $lastdragIP += 1 createNextdragIP($lastdragIP) EndIf Case $msg = $GUI_EVENT_PRIMARYDOWN $aMouse_Pos = MouseGetPos() $sel = -1 For $n = 0 To $lastdragIP GUISwitch($hInput_GUI[$n]) $aCursorInfo = GUIGetCursorInfo() If Not IsArray($aCursorInfo) Then ContinueLoop If $aCursorInfo[4] = $Input[$n] Then $sel = $n ExitLoop EndIf Next If $sel = -1 Then ContinueLoop $aInputGUI_Pos = WinGetPos($hInput_GUI[$sel]) While IsArray($aCursorInfo) And $aCursorInfo[2] = 1 $aCursorInfo = GUIGetCursorInfo() $aCurrent_Mouse_Pos = MouseGetPos() WinMove($hInput_GUI[$sel], "", _ $aInputGUI_Pos[0] - $aMouse_Pos[0] + $aCurrent_Mouse_Pos[0], _ $aInputGUI_Pos[1] - $aMouse_Pos[1] + $aCurrent_Mouse_Pos[1]) WEnd EndSelect WEnd Func createNextdragIP($nw) $start = WinGetPos($GUI) $hInput_GUI[$nw] = GUICreate("", 120, 22, $start[0]+30, $start[1]+200, $WS_POPUP, $WS_EX_TOOLWINDOW) $Input[$nw] = GUICtrlCreateEdit("", 0, 0, 120, 22, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_WANTRETURN)) $hMenu = _GUICtrlMenu_CreatePopup() $InputMenu[$nw] = $hMenu _GUICtrlMenu_AddMenuItem($hMenu, "Delete", $idOpen) $wProcsOld[$nw] = _WinAPI_SetWindowLong(GUICtrlGetHandle($Input[$nw]), $GWL_WNDPROC, DllCallbackGetPtr($wProcHandle)) GUISetState() WinSetOnTop($hInput_GUI[$nw], "", 1) EndFunc;==>createNextdragIP Func _WindowProc($hWnd, $Msg, $wParam, $lParam) Local $wProcOld For $i = 0 To UBound($Input)-1 If GUICtrlGetHandle($Input[$i]) = $hWnd Then Switch $Msg Case $WM_CONTEXTMENU _GUICtrlMenu_TrackPopupMenu($InputMenu[$i], $wParam) Return 0 Case $WM_COMMAND Switch $wParam Case $idOpen GUICtrlDelete($Input[$i]) EndSwitch EndSwitch $wProcOld = $wProcsOld[$i] ExitLoop EndIf Next Local $aRet = DllCall("user32.dll", "int", "CallWindowProc", "ptr", $wProcOld, _ "hwnd", $hWnd, "uint", $Msg, "wparam", $wParam, "lparam", $lParam) Return $aRet[0] EndFunc whenever i right click and delete each edit sometimes the script crashes? should i be deleting the edits another way?? Link to comment Share on other sites More sharing options...
martin Posted October 11, 2008 Share Posted October 11, 2008 I have modified your script and I can't get an error but I don't know if I would have got an error befor! When you delete an edit you need to change the chain of functions called by WinProc which is what I have tried to do. Maybe it fixes tyor problem. expandcollapse popup#include <GuiConstantsEx.au3> #include <GuiEdit.au3> #include <WindowsConstants.au3> #include <GUIMenu.au3> #include <WindowsConstants.au3> #include <Constants.au3> #include <EditConstants.au3> #include <WinAPI.au3> Dim $hInput_GUI[6], $Input[6], $wProcsOld[6], $InputMenu[6] Global $lastdragIP = -1 Global Enum $idOpen = 1000, $idSave, $idInfo $GUI = GUICreate("Test", 300, 300) $button5 = GUICtrlCreateButton("", 100, 200, 40, 25) GUICtrlSetState(-1, $GUI_DEFBUTTON) GUISetState() $wProcHandle = DllCallbackRegister("_WindowProc", "ptr", "hwnd;uint;wparam;lparam") While 1 $Msg = GUIGetMsg() Select Case $Msg = $GUI_EVENT_CLOSE Exit Case $Msg = $button5 If $lastdragIP < 5 Then $lastdragIP += 1 createNextdragIP($lastdragIP) EndIf Case $Msg = $GUI_EVENT_PRIMARYDOWN $aMouse_Pos = MouseGetPos() $sel = -1 For $n = 0 To $lastdragIP GUISwitch($hInput_GUI[$n]) $aCursorInfo = GUIGetCursorInfo() If Not IsArray($aCursorInfo) Then ContinueLoop If $aCursorInfo[4] = $Input[$n] Then $sel = $n ExitLoop EndIf Next If $sel = -1 Then ContinueLoop $aInputGUI_Pos = WinGetPos($hInput_GUI[$sel]) While IsArray($aCursorInfo) And $aCursorInfo[2] = 1 $aCursorInfo = GUIGetCursorInfo() $aCurrent_Mouse_Pos = MouseGetPos() WinMove($hInput_GUI[$sel], "", _ $aInputGUI_Pos[0] - $aMouse_Pos[0] + $aCurrent_Mouse_Pos[0], _ $aInputGUI_Pos[1] - $aMouse_Pos[1] + $aCurrent_Mouse_Pos[1]) WEnd EndSelect WEnd Func createNextdragIP($nw) $start = WinGetPos($GUI) $hInput_GUI[$nw] = GUICreate("", 120, 22, $start[0] + 30, $start[1] + 200, $WS_POPUP, $WS_EX_TOOLWINDOW) $Input[$nw] = GUICtrlCreateEdit("", 0, 0, 120, 22, BitOR($ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_WANTRETURN)) $hMenu = _GUICtrlMenu_CreatePopup() $InputMenu[$nw] = $hMenu _GUICtrlMenu_AddMenuItem($hMenu, "Delete", $idOpen) $wProcsOld[$nw] = _WinAPI_SetWindowLong(GUICtrlGetHandle($Input[$nw]), $GWL_WNDPROC, DllCallbackGetPtr($wProcHandle)) GUISetState() WinSetOnTop($hInput_GUI[$nw], "", 1) EndFunc ;==>createNextdragIP Func _WindowProc($hWnd, $Msg, $wParam, $lParam) Local $wProcOld For $i = 0 To $lastdragIP;<----------not Ubound $Input If GUICtrlGetHandle($Input[$i]) = $hWnd Then $wProcOld = $wProcsOld[$i] Switch $Msg Case $WM_CONTEXTMENU _GUICtrlMenu_TrackPopupMenu($InputMenu[$i], $wParam) Return 0 Case $WM_COMMAND Switch $wParam Case $idOpen If $i > 0 Then $wProcsOld[$i] = $wProcsOld[$i - 1] If $i < $lastdragIP Then;we must bypass the proc which is no longer used $wProcsOld[$i + 1] = $wProcsOld[$i - 1] EndIf EndIf $wProcOld = $wProcsOld[$i] GUICtrlDelete($Input[$i]) EndSwitch EndSwitch ;$wProcOld = $wProcsOld[$i] ExitLoop EndIf Next Local $aRet = DllCall("user32.dll", "int", "CallWindowProc", "ptr", $wProcOld, _ "hwnd", $hWnd, "uint", $Msg, "wparam", $wParam, "lparam", $lParam) Return $aRet[0] EndFunc ;==>_WindowProc Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted October 11, 2008 Share Posted October 11, 2008 @martin Wouldn't it be easier to loop from the last to the first? something like (pseudocode) for $x = ubound to 0 step -1 .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
AustrianOak Posted October 12, 2008 Author Share Posted October 12, 2008 martin: on your code it crashes as well. to get the crash error im seeing make sure you have clicked the button 6 times (to open six edits) and then delete one of them. it should crash if you do this. Link to comment Share on other sites More sharing options...
martin Posted October 12, 2008 Share Posted October 12, 2008 martin:on your code it crashes as well. to get the crash error im seeing make sure you have clicked the button 6 times (to open six edits) and then delete one of them. it should crash if you do this.I tried a fgew times but I can't make it crash. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
martin Posted October 12, 2008 Share Posted October 12, 2008 @martin Wouldn't it be easier to loop from the last to the first? something like (pseudocode) for $x = ubound to 0 step -1I'm not sure. My logic was that if one edit is deleted then the winproc for that one is no longer relevant so it should not be called after the one created later, instead the one after should call the one for the winproc before if that makes sense. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
AustrianOak Posted October 12, 2008 Author Share Posted October 12, 2008 well im running beta 3.2.11.5 and my stable release is 3.2.8.1. could this be the problem? Link to comment Share on other sites More sharing options...
AustrianOak Posted October 13, 2008 Author Share Posted October 13, 2008 bump Link to comment Share on other sites More sharing options...
AustrianOak Posted October 14, 2008 Author Share Posted October 14, 2008 bump Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted October 14, 2008 Moderators Share Posted October 14, 2008 Rather than bumping the thread... update to the current release that all of us use and see if the issue still arises... I doubt anyone is going to downgrade their versions to find bugs that may be version related. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
AustrianOak Posted November 1, 2008 Author Share Posted November 1, 2008 (edited) upgraded to 3.2.13.9 and here's my updated code, its only one line different. i changed it from GUICtrlDelete to GUIDelete so it would delete the whole window instead of just the picture. the problem is when i go to create another one i get this error saying subscript used with non array variable. expandcollapse popup#include <GuiConstantsEx.au3> #include <GuiEdit.au3> #include <WindowsConstants.au3> #include <GUIMenu.au3> #include <WindowsConstants.au3> #include <Constants.au3> #include <EditConstants.au3> #include <WinAPI.au3> Dim $hInput_GUI[6], $Input[6], $wProcsOld[6], $InputMenu[6] Global $lastdragIP = -1 Global Enum $idOpen = 1000, $idSave, $idInfo $GUI = GUICreate("Test", 300, 300) $button5 = GUICtrlCreateButton("", 100, 200, 40, 25) GUICtrlSetState(-1, $GUI_DEFBUTTON) GUISetState() $wProcHandle = DllCallbackRegister("_WindowProc", "ptr", "hwnd;uint;wparam;lparam") While 1 $Msg = GUIGetMsg() Select Case $Msg = $GUI_EVENT_CLOSE Exit Case $Msg = $button5 If $lastdragIP < 5 Then $lastdragIP += 1 createNextdragIP($lastdragIP) EndIf Case $Msg = $GUI_EVENT_PRIMARYDOWN $aMouse_Pos = MouseGetPos() $sel = -1 For $n = 0 To $lastdragIP GUISwitch($hInput_GUI[$n]) $aCursorInfo = GUIGetCursorInfo() If Not IsArray($aCursorInfo) Then ContinueLoop If $aCursorInfo[4] = $Input[$n] Then $sel = $n ExitLoop EndIf Next If $sel = -1 Then ContinueLoop $aInputGUI_Pos = WinGetPos($hInput_GUI[$sel]) While IsArray($aCursorInfo) And $aCursorInfo[2] = 1 $aCursorInfo = GUIGetCursorInfo() $aCurrent_Mouse_Pos = MouseGetPos() WinMove($hInput_GUI[$sel], "", _ $aInputGUI_Pos[0] - $aMouse_Pos[0] + $aCurrent_Mouse_Pos[0], _ $aInputGUI_Pos[1] - $aMouse_Pos[1] + $aCurrent_Mouse_Pos[1]) WEnd EndSelect WEnd Func createNextdragIP($nw) $start = WinGetPos($GUI) $hInput_GUI[$nw] = GUICreate("", 120, 22, $start[0] + 30, $start[1] + 200, $WS_POPUP, $WS_EX_TOOLWINDOW) $Input[$nw] = GUICtrlCreateEdit("", 0, 0, 120, 22, BitOR($ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_WANTRETURN)) $hMenu = _GUICtrlMenu_CreatePopup() $InputMenu[$nw] = $hMenu _GUICtrlMenu_AddMenuItem($hMenu, "Delete", $idOpen) $wProcsOld[$nw] = _WinAPI_SetWindowLong(GUICtrlGetHandle($Input[$nw]), $GWL_WNDPROC, DllCallbackGetPtr($wProcHandle)) GUISetState() WinSetOnTop($hInput_GUI[$nw], "", 1) EndFunc ;==>createNextdragIP Func _WindowProc($hWnd, $Msg, $wParam, $lParam) Local $wProcOld For $i = 0 To $lastdragIP;<----------not Ubound $Input If GUICtrlGetHandle($Input[$i]) = $hWnd Then $wProcOld = $wProcsOld[$i] Switch $Msg Case $WM_CONTEXTMENU _GUICtrlMenu_TrackPopupMenu($InputMenu[$i], $wParam) Return 0 Case $WM_COMMAND Switch $wParam Case $idOpen If $i > 0 Then $wProcsOld[$i] = $wProcsOld[$i - 1] If $i < $lastdragIP Then;we must bypass the proc which is no longer used $wProcsOld[$i + 1] = $wProcsOld[$i - 1] EndIf EndIf $wProcOld = $wProcsOld[$i] GUIDelete($hInput_GUI[$i]) EndSwitch EndSwitch ;$wProcOld = $wProcsOld[$i] ExitLoop EndIf Next Local $aRet = DllCall("user32.dll", "int", "CallWindowProc", "ptr", $wProcOld, _ "hwnd", $hWnd, "uint", $Msg, "wparam", $wParam, "lparam", $lParam) Return $aRet[0] EndFunc ;==>_WindowProc Edited November 1, 2008 by AustrianOak Link to comment Share on other sites More sharing options...
oMBRa Posted November 1, 2008 Share Posted November 1, 2008 (edited) 1) I get no error but If I create a edit, I delete it, then, if I re-create a new edit I cant delete it... 2) I want to know how u use WindowProc Edited November 1, 2008 by oMBra Link to comment Share on other sites More sharing options...
AustrianOak Posted November 1, 2008 Author Share Posted November 1, 2008 what version u got Link to comment Share on other sites More sharing options...
oMBRa Posted November 1, 2008 Share Posted November 1, 2008 3.2.12.1 and Beta Link to comment Share on other sites More sharing options...
AustrianOak Posted November 1, 2008 Author Share Posted November 1, 2008 what version beta?? Link to comment Share on other sites More sharing options...
oMBRa Posted November 1, 2008 Share Posted November 1, 2008 3.2.13.9 Link to comment Share on other sites More sharing options...
AustrianOak Posted November 16, 2008 Author Share Posted November 16, 2008 expandcollapse popup#include <GuiConstantsEx.au3> #include <GuiEdit.au3> #include <WindowsConstants.au3> #include <GUIMenu.au3> #include <WindowsConstants.au3> #include <Constants.au3> #include <EditConstants.au3> #include <WinAPI.au3> Dim $hInput_GUI[6], $Input[6], $wProcsOld[6], $InputMenu[6] Global $lastdragIP = -1 Global Enum $idOpen = 1000, $idSave, $idInfo $GUI = GUICreate("Test", 300, 300) $button5 = GUICtrlCreateButton("", 100, 200, 40, 25) GUICtrlSetState(-1, $GUI_DEFBUTTON) GUISetState() $wProcHandle = DllCallbackRegister("_WindowProc", "ptr", "hwnd;uint;wparam;lparam") While 1 $Msg = GUIGetMsg() Select Case $Msg = $GUI_EVENT_CLOSE Exit Case $Msg = $button5 If $lastdragIP < 5 Then $lastdragIP += 1 createNextdragIP($lastdragIP) EndIf Case $Msg = $GUI_EVENT_PRIMARYDOWN $aMouse_Pos = MouseGetPos() $sel = -1 For $n = 0 To $lastdragIP GUISwitch($hInput_GUI[$n]) $aCursorInfo = GUIGetCursorInfo() If Not IsArray($aCursorInfo) Then ContinueLoop If $aCursorInfo[4] = $Input[$n] Then $sel = $n ExitLoop EndIf Next If $sel = -1 Then ContinueLoop $aInputGUI_Pos = WinGetPos($hInput_GUI[$sel]) While IsArray($aCursorInfo) And $aCursorInfo[2] = 1 $aCursorInfo = GUIGetCursorInfo() $aCurrent_Mouse_Pos = MouseGetPos() WinMove($hInput_GUI[$sel], "", _ $aInputGUI_Pos[0] - $aMouse_Pos[0] + $aCurrent_Mouse_Pos[0], _ $aInputGUI_Pos[1] - $aMouse_Pos[1] + $aCurrent_Mouse_Pos[1]) WEnd EndSelect WEnd Func createNextdragIP($nw) $start = WinGetPos($GUI) $hInput_GUI[$nw] = GUICreate("", 120, 22, $start[0] + 30, $start[1] + 200, $WS_POPUP, $WS_EX_TOOLWINDOW) $Input[$nw] = GUICtrlCreateEdit("", 0, 0, 120, 22, BitOR($ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_WANTRETURN)) $hMenu = _GUICtrlMenu_CreatePopup() $InputMenu[$nw] = $hMenu _GUICtrlMenu_AddMenuItem($hMenu, "Delete", $idOpen) $wProcsOld[$nw] = _WinAPI_SetWindowLong(GUICtrlGetHandle($Input[$nw]), $GWL_WNDPROC, DllCallbackGetPtr($wProcHandle)) GUISetState() WinSetOnTop($hInput_GUI[$nw], "", 1) EndFunc ;==>createNextdragIP Func _WindowProc($hWnd, $Msg, $wParam, $lParam) Local $wProcOld For $i = 0 To $lastdragIP;<----------not Ubound $Input If GUICtrlGetHandle($Input[$i]) = $hWnd Then $wProcOld = $wProcsOld[$i] Switch $Msg Case $WM_CONTEXTMENU _GUICtrlMenu_TrackPopupMenu($InputMenu[$i], $wParam) Return 0 Case $WM_COMMAND Switch $wParam Case $idOpen If $i > 0 Then $wProcsOld[$i] = $wProcsOld[$i - 1] If $i < $lastdragIP Then;we must bypass the proc which is no longer used $wProcsOld[$i + 1] = $wProcsOld[$i - 1] EndIf EndIf $wProcOld = $wProcsOld[$i] GUIDelete($hInput_GUI[$i]) EndSwitch EndSwitch ExitLoop EndIf Next Local $aRet = DllCall("user32.dll", "int", "CallWindowProc", "ptr", $wProcOld, _ "hwnd", $hWnd, "uint", $Msg, "wparam", $wParam, "lparam", $lParam) Return $aRet[0] EndFunc ;==>_WindowProc The problem is somewhere in the deletion part of the code in the WindowProc(). It crashes for me after I delete an edit or a few. It's totally random sometimes. Link to comment Share on other sites More sharing options...
AustrianOak Posted November 24, 2008 Author Share Posted November 24, 2008 bump Link to comment Share on other sites More sharing options...
AustrianOak Posted November 26, 2008 Author Share Posted November 26, 2008 bump Link to comment Share on other sites More sharing options...
BrettF Posted November 26, 2008 Share Posted November 26, 2008 When you say crash is this hard crash or does it crash with an error? Are you using the full version of SciTE? If not please install it and run the script, showing and then paste the output pane. Cheers, Brett Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! 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