Advertisement
AlanElston

AkaApiApplicationPromptToRangeInputBox

Jan 29th, 2018
389
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Option Explicit
  2. Rem 1 ' This I understand. it is a simple more basic version of the VBA Message Box Function                                       http://www.eileenslounge.com/viewtopic.php?f=18&t=28885#p223629
  3. ' 1a)          UnWRap it and..
  4. Private Declare Function APIssinUserDLL_MsgBox Lib "user32" Alias "MessageBoxA" (Optional ByVal HowManyFartsCanYouHandle As Long, Optional ByVal Prompt As String, Optional ByVal Title As String, Optional ByVal buttons As Long) As Long '
  5. ' 1b)        To hang in the Excel Window malking it effectively a Excel Msgbox... Normally if I did not do this  ... don't do this .. that is to say leave it at 0 , specifically no window is 0 , and it "hanging in mid air so isn't even if it is   imaginatively speaking
  6. Public Declare Function FindWndNumber Lib "user32" Alias "FindWindowA" (Optional ByVal lpClassName As String, Optional ByVal lpWindowName As String) As Long
  7. Dim HandleWndOfMyParent As Long      ' I wanted to comment  this  1b)(i) and ( 1b(ii) later )   out to leave it hanging in mid air in a virtual  inadvirtual not thereness  ... but somehow this complicated hook stuff does hang it somwhere but not in my Excel Window                                                                                                            but I don't know what my parent's fart has to do with anything
  8. ' 1d)        For some Misc experiments
  9. Private Declare Function FindWindowExtremeNutty Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
  10. Dim WndNumber As Long, hWndDskTop As Long
  11. '_-_._______________________________________________-
  12. '_-=================??? main Declarations that I don't really understand
  13. Rem 2 Position my box --- From here on I do not really have a clue
  14. ' 2(a)                                        This will tie something on the chain for when you pull it                                                                                                      https://msdn.microsoft.com/en-us/library/windows/desktop/ms644990(v=vs.85).aspx
  15. Private Declare Function SetWindowsHookExample Lib "user32" Alias "SetWindowsHookExA" (ByVal Hooktype As Long, ByVal lokprocedureAddress As Long, Optional ByVal hmod As Long, Optional ByVal dwThreadId As Long) As Long
  16. ' 2(b)                                        Wipe the chain clean
  17. Private Declare Function UnHookWindowsHookCodEx Lib "user32" Alias "UnhookWindowsHookEx" (ByVal hHook As Long) As Long
  18. ' 2(c)                                        Don't loose the Thread? - This seems to have no effect , - maybe it would if something else was going on at the time. You don't want to loose the Thread I guess
  19. Public Declare Function GetCurrentThreadId Lib "kernel32" () As Long ' Effectively long Null acttuall not ?? -
  20. ' 2(d)                                        This looks understandable almost, z(0 for top), posLeft, posTop, x pixels, y pixels,
  21. Private Declare Function SetWindowPosition Lib "user32" Alias "SetWindowPos" (ByVal hwnd As Long, ByVal zNumber As Long, ByVal CoedX As Long, ByVal CoedY As Long, ByVal xPiXel As Long, ByVal yPiYel As Long, ByVal wFlags As Long) As Long
  22. ' 2e)
  23. Private hHook As Long                         ' Handle to the Hook procedure
  24. ' 2f)
  25. Private poX As Long: Private pussY As Long    ' Positional By proXYs
  26.                            Dim GlobinalCntChopsLog As Long   ' Only used in this test code to keep track of the copies of a Function(HoldRapeAHookPro) used in a recursion process
  27. ' 2g) bits to do with 1 that i am resonably happy with
  28. Sub AkaApiApplicationPromptToRangeInputBox()  ' This one works.. but HTF
  29.        ' 1b(ii)  This section is some how over written in / by the section part or some strange Addressing of HoldRapeAHookPro
  30.         Let WndNumber = FindWndNumber(lpClassName:=vbNullString, lpWindowName:=vbNullString)
  31.          Let HandleWndOfMyParent = FindWndNumber(lpClassName:="XLMAIN", lpWindowName:=vbNullString) ' This is a case where vbNullstring is important - that signifies that I am not giving it, which i do not have to. The second option is a bit flaky and does not often work. it certainly won't work if you make it "" as that is a specific string of zero.  Null  is a special idea in computing of not set yet / not defined - that is required if I do not want to give it
  32.        ' 1d) Just some experiments, I forgot why as my brain has goine comfortably numb
  33.         Dim HeavyWindBreak As Long: Let HeavyWindBreak = HandleWndOfMyParent
  34.          Let hWndDskTop = FindWindowExtremeNutty(HandleWndOfMyParent, 0&, "XLDESK", vbNullString)
  35.                             Debug.Print "WndNumber"; WndNumber; "   HandleWndOfMyParent"; HandleWndOfMyParent; "   hWndDskTop"; hWndDskTop
  36. Rem 3                                   Mess with me hook? God knows what this all does and it seems to make no difference if the proXYs poX or pussY are before or after SetWindowsHookExample
  37.                             Debug.Print "State of Much Such"; Tab(20); "Penialtration's Number"; Tab(45); "HookCodeXcretion's"
  38.                             Debug.Print "=================="; Tab(20); "AliAs Pull of my chain"; Tab(45); "AliAs my long Hook"
  39.                             Let GlobinalCntChopsLog = 0
  40. '_-======================== Weird thing with an AddressOf ???
  41. Let poX = 10: pussY = 50 ' These can go before or after the next line, makes no diffference.. -                                                    I bet no Pro noticed that...
  42. Let hHook = SetWindowsHookExample(5, AddressOf HoldRapeAHookPro, 0, GetCurrentThreadId)     ' (5-pull before flush,  somehow arranges that the function gets called  ,
  43.                                                                                           'APIssinUserDLL_MsgBox HeavyWindBreak, "Excel MsgBox", "This is Center Position", vbOKOnly ' This breaks Wnd in Excel Window
  44. APIssinUserDLL_MsgBox 0, "Select Range", "MutsNuts AkaApi working ApplicationPromptToRangeInputBox", vbOKOnly ' Pseudo Non Modal
  45.                                                                                                          Dim Rng As Range: Set Rng = Selection
  46. ' (Optional ByVal hwnd As Long, Optional ByVal Prompt As String, Optional ByVal Title As String, Optional ByVal buttons As Long) As Long '
  47. End Sub ' AkaApiApplicationPromptToRangeInputBox
  48. '
  49. 'Going a HoldRapeAHookPro - Copy number_GlobinalCntChopsLog - a few copies of this are made and run. (Recursion)
  50. '_-=Rem 4===================??? Got me hook lochprocedue in my code ,                5 times simple run then  another + 29 new copies of it are run  = 5+30=35 times  in total                     calling it it a few times  http://www.excelfox.com/forum/showthread.php/1324-Loop-Through-Files-In-A-Folder-Using-VBA#post10421   .... wanking myself up and down a few times
  51. Private Function HoldRapeAHookPro(ByVal lMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long   '                                   ByVal CopyNumberFroNxtLvl As Long) As Long
  52.                        Let GlobinalCntChopsLog = GlobinalCntChopsLog + 1: Debug.Print " Going a HoldRapeAHookPro"; GlobinalCntChopsLog; "(1Msg"; lMsg; ", wParam"; wParam; ", lParam"; lParam; ") Function Copy Number_"; GlobinalCntChopsLog
  53.     If lMsg = 5 Then '_-.... ( Hook type: HCBT_ACTIVATE = 5 but not here?) ... this runs a further 29 copies of HoldRapeAHookPro all coming here, so 30 times in total
  54.                            Debug.Print "Expose Interface"; Tab(30); GlobinalCntChopsLog
  55.      SetWindowPosition wParam, 0, poX, pussY, 400, 150, 4 '             SWP_NOZORDER is 4 ..  but not here?? 'SWP_NOSIZE + SWP_NOZORDER ' Pull the Chainge position ...
  56.     UnHookWindowsHookCodEx hHook         ' Release the Hook 30 times this is done
  57.    Else
  58.                             Debug.Print "No InterOfCourse"; Tab(30); GlobinalCntChopsLog; Tab(50); hHook
  59.     End If ' 5 times here then '_-....
  60.                            Debug.Print "Wipe chain WRap"; Tab(30); GlobinalCntChopsLog; Tab(50); hHook
  61.  Let HoldRapeAHookPro = 0 '  Done  5+30=35 times in total  '0 (or False) makes it work, all other numbers and I get no Message box
  62.                            Let GlobinalCntChopsLog = GlobinalCntChopsLog - 1
  63. End Function ' HoldRapeAHookPro
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement