Leaderboard
Popular Content
Showing content with the highest reputation on 02/21/2025 in all areas
-
MessageBox higher than Desktop
Musashi and one other reacted to pixelsearch for a topic
Hi everybody This script displays a big MessageBox having a height higher than @DesktopHeight While the MessageBox is displayed, you can "navigate" inside it like this : * Mouse Left-click drag : to move the window up and down (displaying a new panel of lines) * Mouse Right-click : to display the window at its initial position * Up key * Down key * PageUp Key (Fn + up key on some laptops) * PageDown Key (Fn + down key on some laptops) * Home Key (Fn + left key on some laptops) * End Key (Fn + right key on some laptops) The 6 keyboard keys allow to navigate inside the window. Click on a button (placed at top of the window) to make your choice. All this could have been scripted more easily using a GUI, an Edit control containing the text to display, plus the buttons to choose from, but I just wanted to try it using a native MessageBox #include <APISysConstants.au3> ; $GCL_HCURSOR #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <Misc.au3> #include <MsgBoxConstants.au3> #include <StaticConstants.au3> #include <WinAPIRes.au3> ; _WinAPI_LoadCursor() #include <WinAPISysWin.au3> ; _WinAPI_SetClassLongEx() #include <WindowsConstants.au3> Opt("MustDeclareVars", 1) ;0=no, 1=require pre-declaration Global $g_hGUI, $g_hDLL = DllOpen("user32.dll") Global $g_aCaption, $g_sTitle Example() ;=========================================== Func Example() $g_hGUI = GUICreate("Big MsgBox example", 400, 200) GUICtrlCreateLabel("Number of lines in MsgBox (2 - 1588)", 10, 20, 180, 20, $SS_SUNKEN) Local $idNbLines = GUICtrlCreateInput("200", 200, 20, 35, 20, BitOR($GUI_SS_DEFAULT_INPUT, $ES_NUMBER)), $iNbLines GUICtrlSetLimit($idNbLines, 4) Local $idMsgBox = GUICtrlCreateButton("Big MsgBox", 10, 60, 100, 25, $BS_DEFPUSHBUTTON) Local $idExit = GUICtrlCreateButton("Exit", 10, 110, 100, 25) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $idExit ExitLoop Case $idMsgBox Local $iRet = Prepare_MsgBox(GUICtrlRead($idNbLines)) If $iRet Then MsgBox($MB_TOPMOST, "Big MsgBox return value", $iRet, 0, $g_hGUI) GUICtrlSetState($idNbLines, $GUI_FOCUS) EndSwitch WEnd DllClose($g_hDLL) EndFunc ;==>Example ;=========================================== Func Prepare_MsgBox(Const $iNbLines) If $iNbLines < 2 Or $iNbLines > 1588 Then MsgBox($MB_TOPMOST, "Error", "Enter a number of lines between 2 and 1588", 0, $g_hGUI) Return ; 0 EndIf Local $sTxt = "Line 1 : first line" & @crlf For $i = 2 To $iNbLines - 1 $sTxt &= "Line " & $i & @crlf Next $sTxt &= "Line " & $iNbLines & " : last line" Dim $g_aCaption[3] = ["Cancel", "Try Again", "Continue"] $g_sTitle = "MsgBox with 3 buttons" Local $iChoice = _MsgBox(BitOr($MB_CANCELTRYCONTINUE, $MB_TOPMOST), $g_sTitle, $sTxt, 0, $g_hGUI) ;~ Dim $g_aCaption[2] = ["Yes", "No"] ;~ $g_sTitle = "MsgBox with 2 buttons" ;~ Local $iChoice = _MsgBox(BitOr($MB_YESNO, $MB_TOPMOST), $g_sTitle, $sTxt, 0, $g_hGUI) ;~ Dim $g_aCaption[1] = ["OK"] ;~ $g_sTitle = "MsgBox with 1 button" ;~ Local $iChoice = _MsgBox(BitOr($MB_OK, $MB_TOPMOST), $g_sTitle, $sTxt, 0, $g_hGUI) Return $iChoice EndFunc ;==>Prepare_MsgBox ;=========================================== Func _MsgBox($iFlag, $g_sTitle, $sText, $iTimeOut = 0, $hWnd = 0) GUIRegisterMsg($WM_HELP , "WM_HELP") Local $hTimerProc = DllCallbackRegister('_MsgBoxTimerProc', 'none', 'hwnd;uint;uint_ptr;dword') Local $iTimerID = _WinAPI_SetTimer(0, 0, 10, DllCallbackGetPtr($hTimerProc)) Local $iChoice = MsgBox($iFlag, $g_sTitle, $sText, $iTimeOut, $hWnd) _WinAPI_KillTimer(0, $iTimerID) DllCallbackFree($hTimerProc) GUIRegisterMsg($WM_HELP, "") Return $iChoice EndFunc ;==>_MsgBox ;=========================================== Func _MsgBoxTimerProc($hWnd, $iMsg, $iTimerID, $iTime) If WinExists($g_sTitle) Then _WinAPI_KillTimer(0, $iTimerID) Local $hMsgBox = WinGetHandle($g_sTitle) Local $aPosMsgBox = WinGetPos($hMsgBox) Local $bTooHigh = ($aPosMsgBox[3] > @DesktopHeight + 15) ? True : False If $bTooHigh Then Local $aPosButton, $aPosStatic = ControlGetPos($hMsgBox, "", "Static1") ; the text area For $i = 0 To Ubound($g_aCaption) - 1 ControlSetText($hMsgBox, "", "Button" & ($i + 1), $g_aCaption[$i]) $aPosButton = ControlGetPos($hMsgBox, "", "Button" & ($i + 1)) WinMove(ControlGetHandle($hMsgBox, "", "Button" & ($i + 1)), "", $aPosButton[0], $aPosStatic[1]) Next WinMove(ControlGetHandle($hMsgBox, "", "Static1"), "", $aPosStatic[0], $aPosStatic[1] + $aPosButton[3] + 10) _WinAPI_RedrawWindow($hMsgBox) ; +++ Send("{F1}") ; => Func WM_HELP Else For $i = 0 To Ubound($g_aCaption) - 1 ControlSetText($hMsgBox, "", "Button" & ($i + 1), $g_aCaption[$i]) Next EndIf EndIf EndFunc ;==>_MsgBoxTimerProc ;============================================== Func WM_HELP($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam, $lParam If WinExists($g_sTitle) Then ; MessageBox window always exists at this stage Local $hMsgBox = WinGetHandle($g_sTitle) Local $aPosMsgBox = WinGetPos($hMsgBox), $aPosMsgBox_Init = $aPosMsgBox Local $aWinPos, $aMPos, $aMPosOld Local $hCursor = _WinAPI_LoadCursor(0, $OCR_SIZEALL) ; $OCR_SIZENS ok too Local $iPrev = _WinAPI_SetClassLongEx($hMsgBox, $GCL_HCURSOR, $hCursor) ; see "147c.au3" HotKeySet("{SPACE}", "_Space") While 1 If WinActive($hMsgBox) Then Select Case _IsPressed("01", $g_hDLL) ; "01" = Left mouse button $aMPosOld = MouseGetPos() While _IsPressed("01", $g_hDLL) $aMPos = MouseGetPos() If $aMPos[1] <> $aMPosOld[1] Then $aWinpos = WinGetPos($hMsgBox) If ($aMPos[0] - 1 > $aWinpos[0]) And ($aMPos[0] + 1 < $aWinpos[0] + $aWinpos[2]) Then WinMove($hMsgBox, "", Default, $aWinpos[1] + ($aMPos[1] - $aMPosOld[1])) $aMPosOld = $aMPos EndIf EndIf Sleep(10) Wend Case _IsPressed("02", $g_hDLL) ; Right mouse button WinMove($hMsgBox, "", $aPosMsgBox_Init[0], $aPosMsgBox_Init[1]) Case _IsPressed("21", $g_hDLL) ; PageUp Key While _IsPressed("21", $g_hDLL) Sleep(10) Wend $aPosMsgBox = WinGetPos($hMsgBox) WinMove( $hMsgBox, "", Default, ($aPosMsgBox[1] + @DesktopHeight > 0) ? 0 : $aPosMsgBox[1] + @DesktopHeight ) Case _IsPressed("22", $g_hDLL) ; PageDown Key While _IsPressed("22", $g_hDLL) Sleep(10) Wend $aPosMsgBox = WinGetPos($hMsgBox) WinMove( $hMsgBox, "", Default, _ ($aPosMsgBox[3] + $aPosMsgBox[1] - @DesktopHeight < @DesktopHeight + 15) ? @DesktopHeight - $aPosMsgBox[3] : $aPosMsgBox[1] - @DesktopHeight ) Case _IsPressed("23", $g_hDLL) ; End Key $aPosMsgBox = WinGetPos($hMsgBox) WinMove($hMsgBox, "", Default, @DesktopHeight - $aPosMsgBox[3]) Case _IsPressed("24", $g_hDLL) ; Home Key WinMove($hMsgBox, "", Default, 0) Case _IsPressed("26", $g_hDLL) ; Up Key $aPosMsgBox = WinGetPos($hMsgBox) WinMove($hMsgBox, "", Default, ($aPosMsgBox[1] + 12 > 0) ? 0 : $aPosMsgBox[1] + 12) Case _IsPressed("28", $g_hDLL) ; Down Key $aPosMsgBox = WinGetPos($hMsgBox) WinMove( $hMsgBox, "", Default, _ ($aPosMsgBox[3] + $aPosMsgBox[1] - 12 < @DesktopHeight) ? @DesktopHeight - $aPosMsgBox[3] : $aPosMsgBox[1] - 12 ) EndSelect EndIf If Not BitAND(WinGetState($hMsgBox), $WIN_STATE_VISIBLE) Then ; one of MsgBox buttons was clicked ExitLoop EndIf Sleep(10) WEnd HotKeySet("{SPACE}") _WinAPI_SetClassLongEx($hMsgBox, $GCL_HCURSOR, $iPrev) ; needed, or cursor $OCR_SIZEALL will show... in final MsgBox from main loop EndIf Return $GUI_RUNDEFMSG EndFunc ;==>WM_HELP ;============================================== Func _Space() HotKeySet("{SPACE}") ; deactivate Hotkey If WinActive($g_sTitle) Then HotKeySet("{SPACE}", "_DoNothing") ; this part to avoid a MsgBox button being triggered, when Spacebar key is pressed too long. While _IsPressed("20", $g_hDLL) ; Spacebar key Sleep(10) Wend Else Send("{SPACE}") EndIf HotKeySet("{SPACE}", "_Space") ; reactivate Hotkey EndFunc ;==>_Space ;============================================== Func _DoNothing() EndFunc ;==>_DoNothing2 points -
Another AutoIt extension for Visual Studio Code
SOLVE-SMART reacted to genius257 for a topic
Thanks for the feedback @seadoggie01! Glad to hear it I did try to assign different syntax types to the word, dots and colon (for different colors), but had issues with limited default colors. Making custom color overrides would not be theme friendly I don't plan on making the standard UDF headers collapsible. It is a good idea, don't get me wrong. I just don't want to put too much work in the standard UDF headers. I also currently have done nothing in regards to code folding. All current code folding is pure vscode based on indentation. I could look into adding additional folding at some point, but won't for now, as the parser is not finished with cases like the with code block, so folding would haft to be re-done then anyway That is a cool solution! and yes, i plan on supporting and extending the DocBlock format in AutoIt3 The DocBlock fields are inspired, if not taken directly from PHPDoc and JSDoc formats. I will need to do something custom for documenting error flags at some point, and do have some ideas in mind. This is just to give you a heads-up that fields like "@return-Failure" and "@error-1" won't be handled by future static analysis for type checking or documentation generation out of the box. If you want to know more i got a draft issue/ticket for the feature here, or i can create a new discussion on GitHub for a longer back and forth on the details?1 point -
Another AutoIt extension for Visual Studio Code
genius257 reacted to seadoggie01 for a topic
I quite like the addition of the syntax highlighting to the UDF headers. It looks a bit strange right now since it's new, but it makes them much more readable. I haven't noticed any speed or performance issues, so (as my grandma says) it's good enough for who it's for With the addition of UDF comment support, what do you think about collapsing those definitions? They usually start with a single semi-colon and don't collapse as they're a series of single line comments, but IMHO they should collapse. I like documenting my own functions, but I like a script that quickly collapses even more as it helps with finding functions. If you want collapsing with the standard UDF headers, you might consider accepting a leading space before the comment. Currently, any space will cancel the syntax highlighting. That said, I may have solved my own problem. Since you've added your own format of UDF documentation, I may start using it if you plan to keep it around. I decided to hack extend it a bit and include my error values there as well. By adding a space before the start of each line you can control the comment collapsing as well. I came up with this snippet to add a UDF documentation header (I added it to %AppData%\Code\User\snippets\au3.json) "A UDF in Genius' format": { "prefix": ["udfNew"], "body": [ "#cs ${1:Function Description}", " # @param ${2:Parameter Type} $${3:Parameter Name} ${4:Parameter Description}", " # @return ${5:Return on Success}", " # @return-Failure ${6:Return on failure}", " # @error-1 ${7:Possible error values}", " #ce" ] } When it collapses, it leaves the function description outside of the collapsed region and hides the #ce because it's "indented" too.1 point -
WinGetClassList EnableExplicit Structure winparam hwnd.i title.s text.s result.s EndStructure Procedure EnumWinProc(hwnd.l, *ptr.winparam) Protected title${256} ; буфер GetWindowText_(hwnd, @title$, 256) If Asc(title$) And title$ = *ptr\title PokeL(@*ptr\hwnd, hwnd) ProcedureReturn 0 EndIf ProcedureReturn 1 EndProcedure Procedure EnumChildProc(hwnd.l, *ptr.winparam) Protected class${256}, text${256} GetClassName_(hwnd, @class$, 256) If Asc(class$) If Asc(*ptr\text) GetWindowText_(hwnd, @text$, 256) If text$ = *ptr\text *ptr\result + class$ + #LF$ EndIf Else *ptr\result + class$ + #LF$ EndIf EndIf ProcedureReturn 1 EndProcedure Procedure.s WinGetClassList(title$, text$ = "") Protected ptr.winparam ptr\title = title$ ptr\text = text$ EnumWindows_(@EnumWinProc(), @ptr) If ptr\hwnd EnumChildWindows_(ptr\hwnd, @EnumChildProc(), @ptr) ptr\result = RTrim(ptr\result, #LF$) ProcedureReturn ptr\result EndIf EndProcedure Debug WinGetClassList("Untitled — Notepad")1 point
-
My idea of a source being "secure" isn't just plain asm compiled. I fail to comprehend both the security merits, and the purpose of this. If your autoit code is going to be converted to another language, wouldn't it be easier to learn that language instead? Then you can VMP easily, end of story. Unless your only intent is to prevent kids who only know how to drag drop to get your 1337 source, this will not provide you the slightest help.0 points