
jfisher
Members-
Posts
16 -
Joined
-
Last visited
Everything posted by jfisher
-
The slide from side to side is MUCH better to marquee with than the other method that I have seen on here. Just set a label with flag $SS_CENTERIMAGE and loop through this slide function and its relatively smooth and fast too. Less jumpy than the other one.
-
Need a better way to exit a script
jfisher replied to matumbo's topic in AutoIt General Help and Support
Sounds like a blast to me. -
See this is what I took away when I read the help. So therefore if this is the case, then th array is started completely from a clean slate when I Global $array = whatever[] again. If that's working as expected, then I fear the problem may be somewhere else. I'm about to giveup on this thing, but really can't so here's the trouble code in full. I have included the #include file at the top of it as a region so I dont have to attach a bunch of files. This is what I know: When I call Showmenu I am consolewriting the menu's handle. The first time, the menu shows up and theres a handle set, the second and subsequent times there is no handle for the menu itself. Like I said I thought it was old array values getting in the way, but they should be cleared out when its Global'd, unless thats just wrong. Please look over it and see what you think. Thanks for the help guys. The trouble spot is highlighted in comments. Just run and right click in the edit control. ;this region is just the dll callback include file, included so I dont have to attach a file for those that don't have it. #region DLLCallBackInclude File ; Adjustable values Global Const $gi_DllCallBack_uiMsg = 0x7FFF ; WM_USER + 0x7BFF Global Const $gi_DllCallBack_MaxStubs = 64 ; Constants for $nOptions Global Const $_DllCallBack_StdCall = 0 Global Const $_DllCallBack_Cdecl = 1 Global Const $_DllCallBack_Sync = 2 Global Const $_DllCallBack_Subclass = 4 Global Const $_DllCallBack_Struct = 8 Global Const $_DllCallBack_Debug = 1024 ; Internaly used Global Const $gs_DllCallBack_typedef_CriticalSection = "PTR DebugInfo;LONG LockCount;LONG RecursionCount;PTR OwningThread;PTR LockSemaphore;DWORD SpinCount" Global $gp_DllCallBack_SendMessage = 0 Global $gh_DllCallBack_hUser32 = 0 Global $gi_DllCallBack_StubCount = 0 Global $gp_DllCallBack_EnterCriticalSection = 0 Global $gp_DllCallBack_LeaveCriticalSection = 0 Global $gp_DllCallBack_CallWindowProc = 0 Global $gh_DllCallBack_hWnd = GUICreate("au3_Callback") Global $gf_DllCallBack_fMsgRegistred = GUIRegisterMsg($gi_DllCallBack_uiMsg, "__DllCallBack_MsgHandler") Global $ga_DllCallBack_sParameters[$gi_DllCallBack_MaxStubs + 1] Global $ga_DllCallBack_nParameters[$gi_DllCallBack_MaxStubs + 1] Global $ga_DllCallBack_sFunctions[$gi_DllCallBack_MaxStubs + 1] Global $ga_DllCallBack_hGlobals[$gi_DllCallBack_MaxStubs + 1] Global $ga_DllCallBack_vCriticalSections[$gi_DllCallBack_MaxStubs + 1] Global $ga_DllCallBack_nOptions[$gi_DllCallBack_MaxStubs + 1] ;=============================================================================== ; ; Function Name: _DllCallBack ; Description: Registers a callback function and creates a stub which handles incoming calls. ; Parameter(s): $sFunction - Name of callback function ; $sParameters - DllStruct like parameter definition (only 32 and 64bit datatypes supported) ; $nOptions, Optional - Can be one or more (add them together) of the folowing constants: ; $_DllCallBack_StdCall (0) - Use 'stdcall' calling method (Default) ; $_DllCallBack_Cdecl (1) - Use 'cdecl' calling method ; $_DllCallBack_Sync (2) - Enable Critical Section (see Remarks) ; $_DllCallBack_Subclass (4) - Enable Subclassing (see Remarks) ; $_DllCallBack_Struct (8) - Pass the struct to the handler function (see Remarks) ; $_DllCallBack_Debug (1024) - Enable breakpoint (requires a JIT debugger) ; Requirement(s): ; Return Value(s): Pointer to created stub or NULL on error ; @error Value(s): 1 = Error allocating memory ; 2 = Error Loading User32.dll or Kernel32.dll ; 3 = Failed to get the address of SendMessage, EnterCriticalSection, LeaveCriticalSection or CallWindowProc ; 4 = Too many callbacks ; 5 = GUIRegisterMsg() Failed ; 6 = $sParameters Fromat wrong ; 7 = Error calling InitializeCriticalSection ; ; Author(s): Florian Fida ; Remarks: The number of coexistent callback stubs is limited to 64. ; Windows message WM_USER + 0x7BFF is used by this function. ; ; If Subclassing is enabled the callback function must not call 'CallWindowProc' itself. ; If the Function processes the message it should return NULL if not is has to return a Pointer ; to the previous 'WindowProc' Function. ; ; Critical sections allow better synchronisation, if a multithreaded library calls ; the callback function, enable this option. ; ; Passing the struct requires the callback function to accept one parameter which is the ; Struct defined in $sParameters. This allows the modification of the stack. ; ;=============================================================================== ; Func _DllCallBack($sFunction, $sParameters = "", Const $nOptions = 0) Local $pSendMessage, $hGlobal, $hUser32, $vStub, $i, $vCriticalSection, $pCallWindowProc Local $nParameters, $vParameters, $wParam = -1, $nParameters_struct = -1, $hKernel32 Local $sStub, $dwStubSize If BitAND($_DllCallBack_Debug, $nOptions) Then $sStub = "90909090CC" ; INT3 If Not $gf_DllCallBack_fMsgRegistred Then Return SetError(5, 0, 0) If $sParameters = "" Or $sParameters = Default Then $nParameters = 0 Else $vParameters = DllStructCreate($sParameters) If @error Then Return SetError(6, 0, 0) $nParameters = DllStructGetSize($vParameters) / 4 If $nParameters <> Int($nParameters) Or @error Then Return SetError(6, 0, 0) For $i = 1 To 256 DllStructGetData($vParameters, $i) If @error Then $nParameters_struct = $i - 1 ExitLoop EndIf Next If $nParameters_struct < 0 Then SetError(6, 0, 0) EndIf For $i = 0 To $gi_DllCallBack_MaxStubs If Not $ga_DllCallBack_hGlobals[$i] Then $wParam = $i ExitLoop EndIf Next If $wParam = -1 Then Return SetError(4, 0, 0) If $gh_DllCallBack_hUser32 = 0 Then $hUser32 = DllCall("kernel32.dll", "ptr", "LoadLibrary", "str", "user32.dll") If @error Then Return SetError(2, 0, 0) If $hUser32[0] = 0 Then Return SetError(2, 0, 0) $gh_DllCallBack_hUser32 = $hUser32[0] $pSendMessage = DllCall("kernel32.dll", "ptr", "GetProcAddress", "ptr", $gh_DllCallBack_hUser32, "str", "SendMessage") If @error Then Return SetError(3, 0, 0) If $pSendMessage[0] = 0 Then If @Unicode Then $pSendMessage = DllCall("kernel32.dll", "ptr", "GetProcAddress", "ptr", $gh_DllCallBack_hUser32, "str", "SendMessageW") If @error Then Return SetError(3, 0, 0) Else $pSendMessage = DllCall("kernel32.dll", "ptr", "GetProcAddress", "ptr", $gh_DllCallBack_hUser32, "str", "SendMessageA") If @error Then Return SetError(3, 0, 0) EndIf EndIf If $pSendMessage[0] = 0 Then Return SetError(3, 0, 0) $gp_DllCallBack_SendMessage = $pSendMessage[0] $pCallWindowProc = DllCall("kernel32.dll", "ptr", "GetProcAddress", "ptr", $gh_DllCallBack_hUser32, "str", "CallWindowProc") If @error Then Return SetError(3, 0, 0) If $pCallWindowProc[0] = 0 Then If @Unicode Then $pCallWindowProc = DllCall("kernel32.dll", "ptr", "GetProcAddress", "ptr", $gh_DllCallBack_hUser32, "str", "CallWindowProcW") If @error Then Return SetError(3, 0, 0) Else $pCallWindowProc = DllCall("kernel32.dll", "ptr", "GetProcAddress", "ptr", $gh_DllCallBack_hUser32, "str", "CallWindowProcA") If @error Then Return SetError(3, 0, 0) EndIf EndIf If $pCallWindowProc[0] = 0 Then Return SetError(3, 0, 0) $gp_DllCallBack_CallWindowProc = $pCallWindowProc[0] EndIf If Not BitAND($_DllCallBack_Sync, $nOptions) Then ; Critical section disabled $vCriticalSection = -1 Else ; Critical section enabled If $gp_DllCallBack_EnterCriticalSection = 0 Or $gp_DllCallBack_LeaveCriticalSection = 0 Then ; we assume kernel32.dll is allways loaded $hKernel32 = DllCall("kernel32.dll", "ptr", "GetModuleHandle", "str", "kernel32.dll") If @error Then Return SetError(2, 0, 0) If $hKernel32[0] = 0 Then Return SetError(2, 0, 0) $gp_DllCallBack_EnterCriticalSection = DllCall("kernel32.dll", "ptr", "GetProcAddress", "ptr", $hKernel32[0], "str", "EnterCriticalSection") If @error Then Return SetError(3, 0, 0) $gp_DllCallBack_EnterCriticalSection = $gp_DllCallBack_EnterCriticalSection[0] If $gp_DllCallBack_EnterCriticalSection = 0 Then Return SetError(3, 0, 0) $gp_DllCallBack_LeaveCriticalSection = DllCall("kernel32.dll", "ptr", "GetProcAddress", "ptr", $hKernel32[0], "str", "LeaveCriticalSection") If @error Then Return SetError(3, 0, 0) $gp_DllCallBack_LeaveCriticalSection = $gp_DllCallBack_LeaveCriticalSection[0] If $gp_DllCallBack_LeaveCriticalSection = 0 Then Return SetError(3, 0, 0) EndIf $vCriticalSection = DllStructCreate($gs_DllCallBack_typedef_CriticalSection) DllCall("kernel32.dll", "none", "InitializeCriticalSection", "ptr", DllStructGetPtr($vCriticalSection)) If @error Then Return SetError(7, 0, 0) EndIf If @error Then Return SetError(7, 0, 0) #cs Options: Critical section, Breakpoint, stdcall - 2 parameters $ ==> > CC INT3 ; Breakpoint (for debugging only) $+1 > 68 30859B00 PUSH 9B8530 ; Push LPCRITICAL_SECTION $+6 > B8 0510917C MOV EAX,ntdll.RtlEnterCriticalSection ; Set address for EnterCriticalSection $+B > FFD0 CALL EAX ; Call EnterCriticalSection $+D > 8D4424 04 LEA EAX,DWORD PTR SS:[ESP+4] ; Load Pointer to parameters on stack to EAX $+11 > 50 PUSH EAX ; Push lParam - Stack Pointer $+12 > 68 00000000 PUSH 0 ; Push wParam - internal reference to au3 function $+17 > 68 FF7F0000 PUSH 7FFF ; Push uiMsg - internal identifier for callback $+1C > 68 26063000 PUSH 300626 ; Push hWnd - Autoit's Callback window $+21 > B8 AEE2D177 MOV EAX,USER32.SendMessageA ; Set address for SendMessage $+26 > FFD0 CALL EAX ; Call Sendmessage $+28 > 50 PUSH EAX ; Preserve Return value of Callback Function $+29 > 68 30859B00 PUSH 9B8530 ; Push LPCRITICAL_SECTION $+2E > B8 ED10917C MOV EAX,ntdll.RtlLeaveCriticalSection ; Set address for LeaveCriticalSection $+33 > FFD0 CALL EAX ; Call LeaveCriticalSection $+35 > 58 POP EAX ; Restore Return value of Callback Function $+36 > C2 0800 RETN 8 ; Adjust stack for stdcall and return Options: Default, stdcall - 2 parameters $ ==> > 8D4424 04 LEA EAX,DWORD PTR SS:[ESP+4] ; Load Pointer to parameters on stack to EAX $+4 > 50 PUSH EAX ; Push lParam - Stack Pointer $+5 > 68 00000000 PUSH 0 ; Push wParam - internal reference to au3 function $+A > 68 FF7F0000 PUSH 7FFF ; Push uiMsg - internal identifier for callback $+F > 68 C6041700 PUSH 1704C6 ; Push hWnd - Autoit's Callback window $+14 > B8 AEE2D177 MOV EAX,USER32.SendMessageA ; Set address for SendMessage $+19 > FFD0 CALL EAX ; Call Sendmessage $+1B > C2 0800 RETN 8 ; Adjust stack for stdcall and return nOptions: Subclassing, stdcall - 4 parameters $ ==> > 8D4424 04 LEA EAX,DWORD PTR SS:[ESP+4] ; Load Pointer to parameters on stack to EAX $+4 > 50 PUSH EAX ; Push lParam - Stack Pointer $+5 > 68 00000000 PUSH 0 ; Push wParam - internal reference to au3 function $+A > 68 FF7F0000 PUSH 7FFF ; Push uiMsg - internal identifier for callback $+F > 68 34063100 PUSH 310634 ; Push hWnd - Autoit's Callback window $+14 > B8 62B7D177 MOV EAX,USER32.SendMessageW ; Set address for SendMessage $+19 > FFD0 CALL EAX ; Call Sendmessage $+1B > 83F8 00 CMP EAX,0 ; Compare EAX and NULL $+1E > 74 1C JE SHORT <$+3C> ; If equal (EAX == NULL) jump down to $+3C (return) $+20 > 8B5424 10 MOV EDX,DWORD PTR SS:[ESP+10] ; Copy lParam from stack to EDX $+24 > 52 PUSH EDX ; Push lParam $+25 > 8B5424 10 MOV EDX,DWORD PTR SS:[ESP+10] ; Copy wParam from stack to EDX $+29 > 52 PUSH EDX ; Push wParam $+2A > 8B5424 10 MOV EDX,DWORD PTR SS:[ESP+10] ; Copy uiMsg from stack to EDX $+2E > 52 PUSH EDX ; Push uiMsg $+2F > 8B5424 10 MOV EDX,DWORD PTR SS:[ESP+10] ; Copy hWnd from stack to EDX $+33 > 52 PUSH EDX ; Push hWnd - Subclassed Window $+34 > 50 PUSH EAX ; Push lpPrevWndFunc (Returned by SendMessage/Callback Func) $+35 > B8 19C0D177 MOV EAX,USER32.CallWindowProcW ; Set address for CallWindowProc $+3A > FFD0 CALL EAX ; Call CallWindowProc $+3C > C2 1000 RETN 10 ; Adjust stack and return #ce ; Note: EAX ECX EDX can be freely modified If BitAND($_DllCallBack_Sync, $nOptions) Then ; Critical section $sStub &= "68" & __DllCallBack_Endian(DllStructGetPtr($vCriticalSection)) $sStub &= "B8" & __DllCallBack_Endian($gp_DllCallBack_EnterCriticalSection) $sStub &= "FFD0" ; call EnterCriticalSection EndIf $sStub &= "8D442404" ; load stack poiner into eax $sStub &= "50" ; push eax - lparam $sStub &= "68" & __DllCallBack_Endian($wParam, "uint") $sStub &= "68" & __DllCallBack_Endian($gi_DllCallBack_uiMsg, "uint") $sStub &= "68" & __DllCallBack_Endian($gh_DllCallBack_hWnd, "hwnd") $sStub &= "B8" & __DllCallBack_Endian($gp_DllCallBack_SendMessage) $sStub &= "FFD0" ; call SendMessage If BitAND($_DllCallBack_Sync, $nOptions) Then ; Critical section $sStub &= "50" ; push eax - to preserve return value of callback function $sStub &= "68" & __DllCallBack_Endian(DllStructGetPtr($vCriticalSection)) $sStub &= "B8" & __DllCallBack_Endian($gp_DllCallBack_LeaveCriticalSection) $sStub &= "FFD0" ; call LeaveCriticalSection $sStub &= "58" ; pop eax - Retstore return value EndIf If BitAND($_DllCallBack_Subclass, $nOptions) Then ; Subclassing $sStub &= "83F800"; cmp eax,0 $sStub &= "74" & "1C"; je 0x1c - if eax == 0 jump down 0x1c opcodes (to return) $sStub &= "8B5424" & "10" & "52"; mov edx,dword ptr ss:esp+10; push edx - lparam $sStub &= "8B5424" & "10" & "52"; mov edx,dword ptr ss:esp+10; push edx - wparam $sStub &= "8B5424" & "10" & "52"; mov edx,dword ptr ss:esp+10; push edx - msg $sStub &= "8B5424" & "10" & "52"; mov edx,dword ptr ss:esp+10; push edx - hwnd $sStub &= "50"; push eax - lpPrevWndFunc $sStub &= "B8" & __DllCallBack_Endian($gp_DllCallBack_CallWindowProc) ; Set eax to CallWindowProc $sStub &= "FFD0"; call eax EndIf If BitAND($_DllCallBack_Cdecl, $nOptions) Then $sStub &= "C3" ; return near 'cdecl' Else $sStub &= "C2" & __DllCallBack_Endian($nParameters * 4, "ushort", 2) ; Return near 'stdcall' EndIf $dwStubSize = StringLen($sStub) / 2 $hGlobal = DllCall("kernel32.dll", "ptr", "GlobalAlloc", "uint", 0, "dword", $dwStubSize) If @error Then Return SetError(1, 0, 0) If $hGlobal[0] = 0 Then Return SetError(1, 0, 0) $hGlobal = $hGlobal[0] $vStub = DllStructCreate("ubyte[" & $dwStubSize & "]", $hGlobal) DllStructSetData($vStub, 1, Binary("0x" & $sStub)) $gi_DllCallBack_StubCount += 1 $ga_DllCallBack_hGlobals[$wParam] = $hGlobal $ga_DllCallBack_sFunctions[$wParam] = $sFunction $ga_DllCallBack_sParameters[$wParam] = $sParameters $ga_DllCallBack_nParameters[$wParam] = $nParameters_struct $ga_DllCallBack_vCriticalSections[$wParam] = $vCriticalSection $ga_DllCallBack_nOptions[$wParam] = $nOptions Return $hGlobal EndFunc ;==>_DllCallBack ;=============================================================================== ; ; Function Name: _DllCallBack_Free ; Description: Frees memory from global heap allocated by _DllCallBackAlloc ; Parameter(s): $hStub - Pointer to stub ; Requirement(s): ; Return Value(s): On Success: True ; On Failure: False ; @error Value(s): 1 - Error freeing memory or Invalid handle ; 2 - Error freeing User32.dll ; Author(s): Florian Fida ; ;=============================================================================== ; Func _DllCallBack_Free(ByRef $hStub) Local $aTmp, $i, $fFound = False If $hStub > 0 Then $aTmp = DllCall("kernel32.dll", "ptr", "GlobalFree", "ptr", $hStub) If @error Then Return SetError(1, 0, False) If $aTmp[0] = $hStub Then Return SetError(1, 0, False) If $aTmp[0] = 0 Then For $i = 0 To $gi_DllCallBack_MaxStubs If $ga_DllCallBack_hGlobals[$i] = $hStub Then If $ga_DllCallBack_vCriticalSections[$i] > 0 Then DllCall("kernel32.dll", "none", "DeleteCriticalSection", "ptr", DllStructGetPtr($ga_DllCallBack_vCriticalSections[$i])) $ga_DllCallBack_hGlobals[$i] = 0 $ga_DllCallBack_sParameters[$i] = 0 $ga_DllCallBack_nParameters[$i] = 0 $ga_DllCallBack_sFunctions[$i] = 0 $ga_DllCallBack_vCriticalSections[$i] = 0 $fFound = True ExitLoop EndIf Next If $fFound = False Then Return SetError(1, 0, False) $hStub = 0 $gi_DllCallBack_StubCount -= 1 If $gi_DllCallBack_StubCount < 1 Then $gi_DllCallBack_StubCount = 0 $aTmp = DllCall("kernel32.dll", "int", "FreeLibrary", "ptr", $gh_DllCallBack_hUser32) If @error Then Return SetError(2, 0, False) If $aTmp[0] = 0 Then Return SetError(2, 0, False) $gh_DllCallBack_hUser32 = 0 EndIf Return True EndIf Return False EndIf Return True EndFunc ;==>_DllCallBack_Free ; Internals Func __DllCallBack_MsgHandler($hWnd_Callback, $uiMsg, $wParam, $lParam) Local $vParameters, $i If $ga_DllCallBack_nParameters[$wParam] > 0 Then $vParameters = DllStructCreate($ga_DllCallBack_sParameters[$wParam], $lParam) If BitAND($ga_DllCallBack_nOptions[$wParam], $_DllCallBack_Struct) Then Local $aCallArgs[2] = ["CallArgArray", $vParameters] Else Local $aCallArgs[$ga_DllCallBack_nParameters[$wParam] + 1] $aCallArgs[0] = "CallArgArray" For $i = 1 To $ga_DllCallBack_nParameters[$wParam] $aCallArgs[$i] = DllStructGetData($vParameters, $i) Next EndIf Return Call($ga_DllCallBack_sFunctions[$wParam], $aCallArgs) EndIf Return Call($ga_DllCallBack_sFunctions[$wParam]) EndFunc ;==>__DllCallBack_MsgHandler Func __DllCallBack_Endian($n, $s = "ptr", $bytes = 4) ; Return $bytes bytes from $n as Little Endian Hex String, threat as $s Local $a = DllStructCreate($s), $b = DllStructCreate("ubyte[" & $bytes & "]", DllStructGetPtr($a)) DllStructSetData($a, 1, $n) Return StringTrimLeft(DllStructGetData($b, 1), 2) EndFunc ;==>__DllCallBack_Endian #endregion DLLCallBackInclude File #include <GUIConstantsEx.au3> ;#include "DllCallBack.au3" ; some windows constants Global $sIniLocation = @ScriptDir & "\jfisher.ini" ConsoleWrite($sIniLocation) Global Const $WM_RBUTTONDOWN = 0x0204 Global Const $WM_RBUTTONUP = 0x0205 Global Const $WM_RBUTTONDBLCLK = 0x0206 Global Const $WM_MOUSEMOVE = 0x0200 Global $pOriginalWindowProc, $sDbg, $hCtrl_Edit, $nMoveTimer, $fMoveSet = False ; Create a GUI with an edit box $hWnd_ui = GUICreate("Try Right-clicking in the edit box", 310, 135) $hCtrl_Edit = GUICtrlCreateEdit("", 5, 5, 300, 100) $hCtrl_Label = GUICtrlCreateLabel("", 5, 110, 300, 20) ; Register callback function $pMyWindowProc = _DllCallBack ("_MyWindowProc", "hwnd;uint;long;ptr", $_DllCallBack_Subclass) ; Retrieve a pointer to the original WindowProc and set the new one to our ; Callback function - Make sure to use a handle and not the internal id! $pOriginalWindowProc = _WinSubclass(GUICtrlGetHandle($hCtrl_Edit), $pMyWindowProc) GUISetState() While 1 If $GUI_EVENT_CLOSE = GUIGetMsg() Then _DllCallBack_Free ($pOriginalWindowProc) Exit EndIf Sleep(10) ; Gimme a break :) If $sDbg Then ConsoleWrite($sDbg) $sDbg = "" EndIf If TimerDiff($nMoveTimer) < 350 Then If Not $fMoveSet Then GUICtrlSetData($hCtrl_Label, "I saw your mouse move...") $fMoveSet = True EndIf Else If $fMoveSet Then GUICtrlSetData($hCtrl_Label, " ") $fMoveSet = False EndIf EndIf WEnd Func ShowMenu($hWnd, $nContextID) ;;;;this is there there is no handle after the first time. ;;;;this is there there is no handle after the first time. ;;;;this is there there is no handle after the first time. Global $hMenu = GUICtrlGetHandle($nContextID) ConsoleWrite(GUICtrlGetHandle($nContextID)) $arPos = MouseGetPos() Local $x = $arPos[0] Local $y = $arPos[1] DllCall("user32.dll", "int", "TrackPopupMenuEx", "hwnd", $hMenu, "int", 0, "int", $x, "int", $y, "hwnd", $hWnd, "ptr", 0) EndFunc Func _MyWindowProc($hWnd, $uiMsg, $wParam, $lParam) $sDbg &= StringFormat("hWnd: 0x%X \t uiMsg: 0x%X \t wParam: 0x%X \t lParam: 0x%X \n", $hWnd, $uiMsg, $wParam, $lParam) ; Disable the right mouse button If $uiMsg = $WM_RBUTTONDOWN Or $uiMsg = $WM_RBUTTONUP Or $uiMsg = $WM_RBUTTONDBLCLK Then $sDbg &= StringFormat("! I should pop a menu in .0001 seconds !\n") ; Set background to RED while button is down If $uiMsg = $WM_RBUTTONDOWN Or $WM_RBUTTONDBLCLK = $uiMsg Then ;;;;;;;;This is the array creation area, that I THOUGHT was trouble spot ;;;;;;;;This is the array creation area, that I THOUGHT was trouble spot ;;;;;;;;This is the array creation area, that I THOUGHT was trouble spot ;;;;;;;;This is the array creation area, that I THOUGHT was trouble spot Global $ContextMenu = GUICtrlCreateContextMenu() Global $varMenuList = IniReadSection($sIniLocation, "ValidationPositives") $varMenuLength = $varMenuList[0][0] Global $varMenuArray[$varMenuLength+1] $varMenuArray[0] = $varMenuList[0][0] For $i = 1 to ubound($varMenuList) - 1 $varMenuID = GUICtrlCreateMenuItem ($varMenuList[$i][0], $ContextMenu) $varMenuArray[$i] = $varMenuID GUICtrlSetOnEvent($varMenuID,"") Next ShowMenu($hWnd_ui, $ContextMenu) ;;;;;;;;This is the array creation area, that I THOUGHT was trouble spot ;;;;;;;;This is the array creation area, that I THOUGHT was trouble spot ;;;;;;;;This is the array creation area, that I THOUGHT was trouble spot EndIf If $uiMsg = $WM_RBUTTONUP Then GUICtrlSetBkColor($hCtrl_Edit, 0xFFFFFF) ; Returning NULL means: We Processed this message Return 0 EndIf ; i Saw your mouse move by :) If $uiMsg = $WM_MOUSEMOVE Then $nMoveTimer = TimerInit() ; Returning a Pointer to the original WindowProc means: We did not process this message. ; Do not call CallWindowProc() api yourself, the stub will do that for you! Return $pOriginalWindowProc EndFunc ;==>_MyWindowProc ;-- Wrapper for SetWindowLong API Func _WinSubclass($hWnd, $lpNewWindowProc) ;#define GWL_WNDPROC (-4) Local $aTmp = DllCall("user32.dll", "ptr", "SetWindowLong", "hwnd", $hWnd, "int", -4, "ptr", $lpNewWindowProc) If @error Then Return SetError(1, 0, 0) If $aTmp[0] = 0 Then Return SetError(1, 0, 0) Return $aTmp[0] EndFunc ;==>_WinSubclass and for the ini file, it wont let me upload so the content follows: [ValidationPositives] X properly verified=My First Message My Second Message=My Second Message My Third Message=My Third Message [ValidationNegatives1] X properly verified=My First Message My Second Message=My Second Message My Third Message=My Third Message [ValidationNegatives2] X properly verified=My First Message My Second Message=My Second Message My Third Message=My Third Message
-
even if I redim $varMenuLength as Global inside, I still get E:\AdvisorGUI\AutoIt\Include\Subclass.au3 (69) : ==> Subscript used with non-Array variable.: Global $varMenuLength = $varMenuList[0][0] Global $varMenuLength = $varMenuList^ ERROR
-
Global $ContextMenu = GUICtrlCreateContextMenu() Global $varMenuList = IniReadSection($sIniLocation, "ValidationPositives") $varMenuLength = $varMenuList[0][0] Global $varMenuArray[$varMenuLength+1] $varMenuArray[0] = $varMenuList[0][0] For $i = 1 to ubound($varMenuList) - 1 $varMenuID = GUICtrlCreateMenuItem ($varMenuList[$i][0], $ContextMenu) $varMenuArray[$i] = $varMenuID GUICtrlSetOnEvent($varMenuID,"testfunc") Next ShowMenu($hWnd_ui, $ContextMenu)oÝ÷ Øk¢^u«¢+Ø$$$$$$ÀÌØíÙÉ5¹ÕÉÉäôÅÕ½ÐìÅÕ½Ðì($$$$$$ÀÌØíÙÉ5¹Õ1¥ÍÐôÅÕ½ÐìÅսРin front of it to clear out before use again, but get: E:\AdvisorGUI\AutoIt\Include\Subclass.au3 (69) : ==> Subscript used with non-Array variable.: $varMenuLength = $varMenuList[0][0] $varMenuLength = $varMenuList^ ERROR
-
I have an array that is created dynamically with data from a text file. How can I completely wipe it clean and start with a clean slate for the next time it needs to be set? btw, I don't know the size or any information about it besides the name.
-
Callback - no external library (dll) required
jfisher replied to piccaso's topic in AutoIt Example Scripts
All of the examples are working just fine on my vista. -
I'm not quite understanding... I tried this before finding the one I am currently using and posted above. The problem was the same, that I could not attach it to a control, only the window. The part I'm not quite getting is " so there should be used Subclassing (with callback) and WM_CONTEXTMENU handled there." Not sure what WndProc is, or what you're meaning by subclassing. The SHIFT-F10 issue is not really an issue that I'm concerned about. I will take either approach as long as it works as should be expected, on right click in edit: present my menu.
-
I followed this example and it's helped dramatically. I am having a bit of a problem though. When I right click the edit control I want the menu on, sometimes it will show the windows cut, copy, paste, etc menu and sometime it will show MY menu. The other odd thing is once it DOES show my menu, it wont come back up again until I restart the program. It only shows the windows default menu. I have cut these portions out of my enormous code and not it seems that the menu won't show at all. Any ideas? #include <GUIConstants.au3> #include <A3LLibrary.au3> ;Global $sIniLocation = "M:\AdvisorConfig.ini" Global $varMenuList Global $varMenuArray $Form1_1 = GUICreate("Advisor GUI", 998, 800, 10, 9, BitOR($WS_MINIMIZEBOX, $WS_SYSMENU, $WS_CAPTION, $WS_POPUPWINDOW, $WS_GROUP, $WS_HSCROLL, $WS_VSCROLL, $WS_BORDER, $WS_CLIPSIBLINGS, $WS_OVERLAPPEDWINDOW)) GUISetOnEvent($GUI_EVENT_MOUSEMOVE, "MouseWasMoved") $InputValidationPositives = GUICtrlCreateInput("", 200, 72, 463, 21) GUISetState(@SW_SHOW) while 1 sleep(100) WEnd #region PopUp Template Menus Func MouseWasMoved() $CurInfo = GUIGetCursorInfo($Form1_1) Select Case $CurInfo[3] = 1 And $CurInfo[4] = $InputValidationPositives #cs ;I have commented out the following section to not rely on my external .ini file at the top. ;and replaced it with the code following the comments. Global $ContextMenu = GUICtrlCreateContextMenu() Global $varMenuList = IniReadSection($sIniLocation, "ValidationPositives") $varMenuLength = $varMenuList[0][0] Global $varMenuArray[$varMenuLength+1] $varMenuArray[0] = $varMenuList[0][0] For $i = 1 to ubound($varMenuList) - 1 $varMenuID = GUICtrlCreateMenuItem ($varMenuList[$i][0], $ContextMenu) $varMenuArray[$i] = $varMenuID GUICtrlSetOnEvent($varMenuID,"InsertTemplateSelection") Next ShowMenu($Form1_1, $ContextMenu) #ce Global $ContextMenu = GUICtrlCreateContextMenu() $varMenuID1 = GUICtrlCreateMenuItem ("item1", $ContextMenu) $varMenuID2 = GUICtrlCreateMenuItem ("item2", $ContextMenu) $varMenuID3 = GUICtrlCreateMenuItem ("item3", $ContextMenu) $varMenuID4 = GUICtrlCreateMenuItem ("item4", $ContextMenu) $varMenuID5 = GUICtrlCreateMenuItem ("item5", $ContextMenu) ShowMenu($Form1_1, $ContextMenu) EndSelect EndFunc Func ShowMenu($hWnd, $nContextID) Local $hMenu = GUICtrlGetHandle($nContextID) $arPos = MouseGetPos() Local $x = $arPos[0] Local $y = $arPos[1] DllCall("user32.dll", "int", "TrackPopupMenuEx", "hwnd", $hMenu, "int", 0, "int", $x, "int", $y, "hwnd", $hWnd, "ptr", 0) EndFunc Func InsertTemplateSelection() $menuitem = @GUI_CTRLID $menunum = $menuitem - $varMenuArray[1] + 1 ControlSend("Advisor GUI", "", _GuiCtrlGetFocus($Form1_1), String($varMenuList[$menunum][1])) EndFunc #endregion Popup Template Menus Func _GuiCtrlGetFocus($GuiRef) $hwnd = _API_GetFocus() Local $result = DllCall("user32.dll", "int", "GetDlgCtrlID", "hwnd", $hwnd) Return $result[0] EndFunc
-
ContextMenu Menuitems not responding to events?
jfisher replied to fiveofoh's topic in AutoIt GUI Help and Support
Yeah thats what I just found out...if you change the GUI create to: $mygui = GUICreate("My GUI Context Menu", 0, 0, $mousepos[0], $mousepos[1], $WS_POPUP) it works just perfect. Thank you for the code btw -
ContextMenu Menuitems not responding to events?
jfisher replied to fiveofoh's topic in AutoIt GUI Help and Support
This is nearly EXACTLY what I was trying to accomplish by getting menus from an INI. I had no idea how to go about it and this looks like what I need to do. Thanks, and for that reason I am working through this seeing if I can't find a way to get it working as well. -
I came across this topic via search to find out which control the text cursor was in. I don't know what the problem is in my case but I have a listview control which is ALWAYS returned as the control with focus. I tried the code above but was getting the same issue. I changed it around as follows and it works perfect. (For any looking for the same thing) _API_GetFocus() is a function included in A3Library Func _GuiCtrlGetFocus($GuiRef) $hwnd = _API_GetFocus() Local $result = DllCall("user32.dll", "int", "GetDlgCtrlID", "hwnd", $hwnd) Return $result[0] EndFunc
-
Hi all, I found in the help file that you cannot create a context menu inside a control which already has a system context menu in it. I was however wondering if anyone knows of any way that I could possibly work around this? I am in DIRE need of doing so to progress my app any further. I can even take any suggestions and run with them myself. The reason for this (if by chance anyone has an alternate solution) is that my gui has like 50 edit boxes. Each one for a different category and I need a template of premade entries that can be inserted into the context specific boxes. My thought is right click in the edit: show premade entries, click and enter it: move on to next box.... Thanks in advance.
-
ADO Usage - How to add a record
jfisher replied to jfisher's topic in AutoIt General Help and Support
Nevermind all, thanks for the help but I found the problem. It was all in my connection string: $objConnection.Open ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\AdvisorGUI\ExcelTestFile.xls;Extended Properties=""Excel 8.0;HDR=Yes;IMEX=1""") The problem was in the IMEX = 1...per connectionstrings.com if imex = 1 then it may cause problems with write access in excel! Thanks. -
ADO Usage - How to add a record
jfisher replied to jfisher's topic in AutoIt General Help and Support
I really am intent on using it. I tried the excelcom and what I have is a list of people on the left side of gui, and a bunch of fields that the data it dropped into. Using excelcom it took 8 seconds to save person 1 and load person 2. It takes a fraction of a second to read from the file with ado....if only I could get it to write to it. I have already had those defined.... I have also included the entire source if someone would like to give it a go. All you need to do is place the excel file into C:\ and plce adoconstants.au3 to include and it should run. The functions we are looking at are _SaveSingleEval() an _LoadSingleEval() which are noted below in the code. in particular savesingleeval will not save the data to excel which is the problem function. In order to get to this point you must click the button below the listbox, wait a couple seconds and click it again...afterwards, change the selected entry in the listbox and when saving correctly, the msgbox should have data other than just | pipes. heres some more code. [autoit]#include-once ;---- CursorType Values ---- $adOpenForwardOnly = 0 $adOpenKeyset = 1 $adOpenDynamic = 2 $adOpenStatic = 3 ;---- CursorOptionEnum Values ---- $adHoldRecords = 0x00000100 $adMovePrevious = 0x00000200 $adAddNew = 0x01000400 $adDelete = 0x01000800 $adUpdate = 0x01008000 $adBookmark = 0x00002000 $adApproxPosition = 0x00004000 $adUpdateBatch = 0x00010000 $adResync = 0x00020000 $adNotify = 0x00040000 ;---- LockTypeEnum Values ---- $adLockReadOnly = 1 $adLockPessimistic = 2 $adLockOptimistic = 3 $adLockBatchOptimistic = 4 ;---- ExecuteOptionEnum Values ---- $adRunAsync = 0x00000010 ;---- ObjectStateEnum Values ---- $adStateClosed = 0x00000000 $adStateOpen = 0x00000001 $adStateConnecting = 0x00000002 $adStateExecuting = 0x00000004 ;---- CursorLocationEnum Values ---- $adUseServer = 2 $adUseClient = 3 ;---- DataTypeEnum Values ---- $adEmpty = 0 $adTinyInt = 16 $adSmallInt = 2 $adInteger = 3 $adBigInt = 20 $adUnsignedTinyInt = 17 $adUnsignedSmallInt = 18 $adUnsignedInt = 19 $adUnsignedBigInt = 21 $adSingle = 4 $adDouble = 5 $adCurrency = 6 $adDecimal = 14 $adNumeric = 131 $adBoolean = 11 $adError = 10 $adUserDefined = 132 $adVariant = 12 $adIDispatch = 9 $adIUnknown = 13 $adGUID = 72 $adDate = 7 $adDBDate = 133 $adDBTime = 134 $adDBTimeStamp = 135 $adBSTR = 8 $adChar = 129 $adVarChar = 200 $adLongVarChar = 201 $adWChar = 130 $adVarWChar = 202 $adLongVarWChar = 203 $adBinary = 128 $adVarBinary = 204 $adLongVarBinary = 205 ;---- FieldAttributeEnum Values ---- $adFldMayDefer = 0x00000002 $adFldUpdatable = 0x00000004 $adFldUnknownUpdatable = 0x00000008 $adFldFixed = 0x00000010 $adFldIsNullable = 0x00000020 $adFldMayBeNull = 0x00000040 $adFldLong = 0x00000080 $adFldRowID = 0x00000100 $adFldRowVersion = 0x00000200 $adFldCacheDeferred = 0x00001000 ;---- EditModeEnum Values ---- $adEditNone = 0x0000 $adEditInProgress = 0x0001 $adEditAdd = 0x0002 $adEditDelete = 0x0004 ;---- RecordStatusEnum Values ---- $adRecOK = 0x0000000 $adRecNew = 0x0000001 $adRecModified = 0x0000002 $adRecDeleted = 0x0000004 $adRecUnmodified = 0x0000008 $adRecInvalid = 0x0000010 $adRecMultipleChanges = 0x0000040 $adRecPendingChanges = 0x0000080 $adRecCanceled = 0x0000100 $adRecCantRelease = 0x0000400 $adRecConcurrencyViolation = 0x0000800 $adRecIntegrityViolation = 0x0001000 $adRecMaxChangesExceeded = 0x0002000 $adRecObjectOpen = 0x0004000 $adRecOutOfMemory = 0x0008000 $adRecPermissionDenied = 0x0010000 $adRecSchemaViolation = 0x0020000 $adRecDBDeleted = 0x0040000 ;---- GetRowsOptionEnum Values ---- $adGetRowsRest = -1 ;---- PositionEnum Values ---- $adPosUnknown = -1 $adPosBOF = -2 $adPosEOF = -3 ;---- enum Values ---- $adBookmarkCurrent = 0 $adBookmarkFirst = 1 $adBookmarkLast = 2 ;---- MarshalOptionsEnum Values ---- $adMarshalAll = 0 $adMarshalModifiedOnly = 1 ;---- AffectEnum Values ---- $adAffectCurrent = 1 $adAffectGroup = 2 $adAffectAll = 3 ;---- FilterGroupEnum Values ---- $adFilterNone = 0 $adFilterPendingRecords = 1 $adFilterAffectedRecords = 2 $adFilterFetchedRecords = 3 $adFilterPredicate = 4 ;---- SearchDirection Values ---- $adSearchForward = 1 $adSearchBackward = -1 ;---- ConnectPromptEnum Values ---- $adPromptAlways = 1 $adPromptComplete = 2 $adPromptCompleteRequired = 3 $adPromptNever = 4 ;---- ConnectModeEnum Values ---- $adModeUnknown = 0 $adModeRead = 1 $adModeWrite = 2 $adModeReadWrite = 3 $adModeShareDenyRead = 4 $adModeShareDenyWrite = 8 $adModeShareExclusive = 0xc $adModeShareDenyNone = 0x10 ;---- IsolationLevelEnum Values ---- $adXactUnspecified = 0xffffffff $adXactChaos = 0x00000010 $adXactReadUncommitted = 0x00000100 $adXactBrowse = 0x00000100 $adXactCursorStability = 0x00001000 $adXactReadCommitted = 0x00001000 $adXactRepeatableRead = 0x00010000 $adXactSerializable = 0x00100000 $adXactIsolated = 0x00100000 ;---- XactAttributeEnum Values ---- $adXactCommitRetaining = 0x00020000 $adXactAbortRetaining = 0x00040000 ;---- PropertyAttributesEnum Values ---- $adPropNotSupported = 0x0000 $adPropRequired = 0x0001 $adPropOptional = 0x0002 $adPropRead = 0x0200 $adPropWrite = 0x0400 ;---- ErrorValueEnum Values ---- $adErrInvalidArgument = 0xbb9 $adErrNoCurrentRecord = 0xbcd $adErrIllegalOperation = 0xc93 $adErrInTransaction = 0xcae $adErrFeatureNotAvailable = 0xcb3 $adErrItemNotFound = 0xcc1 $adErrObjectInCollection = 0xd27 $adErrObjectNotSet = 0xd5c $adErrDataConversion = 0xd5d $adErrObjectClosed = 0xe78 $adErrObjectOpen = 0xe79 $adErrProviderNotFound = 0xe7a $adErrBoundToCommand = 0xe7b $adErrInvalidParamInfo = 0xe7c $adErrInvalidConnection = 0xe7d $adErrStillExecuting = 0xe7f $adErrStillConnecting = 0xe81 ;---- ParameterAttributesEnum Values ---- $adParamSigned = 0x0010 $adParamNullable = 0x0040 $adParamLong = 0x0080 ;---- ParameterDirectionEnum Values ---- $adParamUnknown = 0x0000 $adParamInput = 0x0001 $adParamOutput = 0x0002 $adParamInputOutput = 0x0003 $adParamReturnValue = 0x0004 ;---- CommandTypeEnum Values ---- $adCmdUnknown = 0x0008 $adCmdText = 0x0001 $adCmdTable = 0x0002 $adCmdStoredProc = 0x0004 ;---- SchemaEnum Values ---- $adSchemaProviderSpecific = -1 $adSchemaAsserts = 0 $adSchemaCatalogs = 1 $adSchemaCharacterSets = 2 $adSchemaCollations = 3 $adSchemaColumns = 4 $adSchemaCheckraints = 5 $adSchemaraintColumnUsage = 6 $adSchemaraintTableUsage = 7 $adSchemaKeyColumnUsage = 8 $adSchemaReferentialContraints = 9 $adSchemaTableraints = 10 $adSchemaColumnsDomainUsage = 11 $adSchemaIndexes = 12 $adSchemaColumnPrivileges = 13 $adSchemaTablePrivileges = 14 $adSchemaUsagePrivileges = 15 $adSchemaProcedures = 16 $adSchemaSchemata = 17 $adSchemaSQLLanguages = 18 $adSchemaStatistics = 19 $adSchemaTables = 20 $adSchemaTranslations = 21 $adSchemaProviderTypes = 22 $adSchemaViews = 23 $adSchemaViewColumnUsage = 24 $adSchemaViewTableUsage = 25 $adSchemaProcedureParameters = 26 $adSchemaForeignKeys = 27 $adSchemaPrimaryKeys = 28 $adSchemaProcedureColumns = 29 jfisher446AdvisorGUIAdo.zip -
I am frantically trying to add a new record to an excel database via ado with no luck whatsoever. I have tried building an sql statement INSERT INTO $table VALUES .... and using $recordset.execute($sql) with no luck, currently what I have below which I believe should be working is: $oMyError = ObjEvent("AutoIt.Error","MyErrFunc") $objConnection = ObjCreate("ADODB.Connection") $objRecordSet = ObjCreate("ADODB.Recordset") $objConnection.Open ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:\AdvisorGUI\ExcelTestFile.xls;Extended Properties=""Excel 8.0;HDR=Yes;IMEX=1""") $objRecordSet.Open ($s_Tablename, $objConnection, $adOpenStatic, $adLockOptimistic, $adCmdText) With $objRecordSet .AddNew .Fields("Agent") = "bob" .Fields("CallDate") = "3/24" .Fields("CallTime") = "6:28pm" .Update EndWith Also as a side note, I get no error when this does not go in correctly. Now this is my first time ever messing with ADO...is there any way to be notified if an entry did not go in, and why that is the case? Thanks much.