Jump to content

NMS

Active Members
  • Posts

    27
  • Joined

  • Last visited

Everything posted by NMS

  1. Yep that makes total sense. Somehow going through the list and not realizing it had its own default behavior didn't occur to me. No need for Mod() either now.
  2. So as the title says. Let's say I have 20 items in the list view. I would like to navigate them using arrow keys, however on row's end it will jump to the first item in the next row, and vice-versa. #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> GUICreate("test", 500, 600) Global $idListview = GUICtrlCreateListView('', 10, 10, 480, 575, _ BitOR($LVS_SINGLESEL, $LVS_SHOWSELALWAYS, $LVS_NOCOLUMNHEADER, $LVS_REPORT)) _GUICtrlListView_SetView($idListview, 0) For $i = 0 To 20 _GUICtrlListView_AddItem($idListview, $i, $i) Sleep(10) Next GUISetState(@SW_SHOW) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Local $tNMHDR, $iIDFrom, $iCode, $iIndex $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $iIDFrom Case $idListview Switch $iCode Case $LVN_KEYDOWN Local $tInfo = DllStructCreate($tagNMLVKEYDOWN, $lParam) Local $iVK = Hex(DllStructGetData($tInfo, "VKey"), 2) $iIndex = _GUICtrlListView_GetSelectedIndices($idListview, True) If $iIndex[0] = 0 Then Return $GUI_RUNDEFMSG Switch $iVK Case 25 ConsoleWrite($iIndex[1] & @CRLF) If Mod($iIndex[1], 11) = 0 Then _GUICtrlListView_SetItemSelected($idListview, $iIndex[1] - 1, True, True) Case 26 ConsoleWrite($iIndex[1] & @CRLF) Case 27 ConsoleWrite($iIndex[1] & @CRLF) If Mod($iIndex[1], 10) = 0 And Not $iIndex[1] = 0 Then _GUICtrlListView_SetItemSelected($idListview, $iIndex[1] + 1, True, True) Case 28 ConsoleWrite($iIndex[1] & @CRLF) EndSwitch EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc The problem I'm having is figuring out why it skips the first item in the next row and directly goes to the next one. I tried various ways of getting the $iIndex however that isn't the issue. From the looks of it the moment I focus the item it "skips" (_GUICtrlListView_SetItemSelected($idListview, $iIndex[1] + 1, True, TRUE). But if I don't focus it can't continue on the next row.
  3. Hello, so the issue is quite simple, I need to keep child window behind the parent window in Z order. The child window will have regions clipped and other things done to it however it will serve no purpose other than cosmetics. "$WS_EX_MDICHILD, $hParent)" seemed like a simple solution however I can't get the window to stay behind parent. I've looked through the forums without any luck for this particular issue. Couple of things: 1. No WinActivate() 2. No loops 3. No WinMove with parent The script itself is over 17k lines with over a dozen of other windows depending on the parent so that's why the limitations from above. I did look into creating a blur behind a specific area only however it seems it ignores the rectangle coordinates and simply applies blur behind entire window. This idea was submitted on some other forum with a different language however it didn't work there either and I can't find the link. But if anyone has a solution to applying blur to a specific area that would be even better. #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> Global $hParent = GUICreate("test", 600, 400, -1, -1, BitOR($WS_POPUP, $WS_BORDER), -1) GUISetBkColor(0x202025, $hParent) GUICtrlCreateButton("Button Left", 10, 55, 100, 20) Global $idButton = GUICtrlCreateButton("Button Right", 190, 55, 100, 20) GUISetState(@SW_SHOW, $hParent) Local $tMargs = DllStructCreate("int cxLeftWidth;int cxRightWidth;int cyTopHeight;int cyBottomHeight") DllStructSetData($tMargs, 1, 180) DllStructSetData($tMargs, 2, 0) DllStructSetData($tMargs, 3, 0) DllStructSetData($tMargs, 4, 0) DllCall("dwmapi.dll", "int", "DwmExtendFrameIntoClientArea", "hwnd", $hParent, "ptr", DllStructGetPtr($tMargs)) Global $hChildMask = GUICreate("test", 182, 402, 1, 1, $WS_POPUP, $WS_EX_MDICHILD, $hParent) GUISetBkColor(0x202025, $hChildMask) GUISetState(@SW_SHOW, $hChildMask) WinSetTrans($hChildMask, "", 200) ;~ $hChildMask is here temporarily to show that I also need to add a color to the blurred area otherwise under solid white color nothing will be visible. I'll do this with GDI ;~ You can remove this GUI for testing Global $hChild = GUICreate("test", 182, 402, 1, 1, $WS_POPUP, $WS_EX_MDICHILD, $hParent) ; <------ This window should be at the bottom of Z order GUISetBkColor(0x000000, $hChild) GUISetState(@SW_SHOW, $hChild) Local $tStruct = DllStructCreate("int AccentState; int AccentFlags; int GradientColor; int AnimationId") Local $tStructData = DllStructCreate("dword Attribute; ptr DataBuffer; ulong Size") $tStruct.AccentState = 3 $tStructData.Attribute = 19 $tStructData.DataBuffer = DllStructGetPtr($tStruct) $tStructData.Size = DllStructGetSize($tStruct) DllCall("user32.dll", "bool", "SetWindowCompositionAttribute", "hwnd", $hChild, "ptr", DllStructGetPtr($tStructData)) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $idButton ExitLoop EndSwitch WEnd Desired result:
  4. So I've stumbled upon this thread: After applying this to a list view, highlight and selection colors remain the same. Modifying these colors works with _WinAPI_SetSysColors() however only when the dark mode is NOT applied. I thought that perhaps since we change the theme itself through uxtheme.dll we need to change those colors however I couldn't figure out which colors or how. https://learn.microsoft.com/en-us/windows/win32/api/uxtheme/nf-uxtheme-getthemecolor If nothing can be done I'll just redraw the items within the list with custom colors and text above using $WM_DRAWITEM. Any help is appreciated!
  5. Thanks for giving this another shot regardless. I'll keep trying and see if I can figure this out.
  6. No luck on the above either. I have found a reference to the function in a different program https://github.com/Artikash/Textractor/blob/master/GUI/mainwindow.cpp. On line 231 that seems to make the call, with most arguments unused other than $tagLEB, path, directory and process info. https://github.com/xupefei/Locale-Emulator-Core/blob/master/LoaderDll/LoaderDll.cpp
  7. Hello. I'm trying to call function "LeCreateProcess" in LoaderDLL.dll but having issues getting any results back. I barely understand C++. I got most values from here https://github.com/xupefei/Locale-Emulator within the https://github.com/xupefei/Locale-Emulator/blob/aa99dec3b25708e676c90acf5fed9beaac319160/LEProc/LoaderWrapper.cs I'm attaching also LocaleEmulator.dll but according to Dependency Walker the function is located in LoaderDLL.dll The goal is to run an application, in this instance, with a Japanese locale. Program itself works fine but in Windows 11 there's no easy way of adding custom options into Context menu where this program would be located if clicked on exe. #include <Date.au3> Local $sProgramPath = "PATH TO ANY EXE FILE" Local $hDLL = DllOpen("PATH TO LOADER.DLL") If @error Then MsgBox(0, "Error", "Failed to open dll") DllClose($hDLL) Exit EndIf Local $SHIFT_JIS = 932 Local $LANG_JAPANESE = 0x411 Local $SHIFTJIS_CHARSET = 128 Local $LEB = DllStructCreate("struct; UINT AnsiCodePage; UINT OemCodePage; UINT LocaleID; UINT DefaultCharset; UINT HookUiLanguageApi; WCHAR DefaultFaceName[64]; PTR Timezone; endstruct") ;Unsure about last two values DllStructSetData($LEB, "AnsiCodePage", $SHIFT_JIS) DllStructSetData($LEB, "OemCodePage", $SHIFT_JIS) DllStructSetData($LEB, "LocaleID", $LANG_JAPANESE) DllStructSetData($LEB, "DefaultCharset", $SHIFTJIS_CHARSET) DllStructSetData($LEB, "HookUiLanguageApi", 0) DllStructSetData($LEB, "DefaultFaceName", "") ;I'm not sure about this part DllStructSetData($LEB, "Timezone", _Date_Time_GetTimeZoneInformation()) ;This seems correct but I don't know if that information is formatted correctly Local $tProcessInfo = DllStructCreate($tagPROCESS_INFORMATION) ;From help file. I don't know if this is enough Local $aResult = DllCall($hDLL, "none", "LeCreateProcess", "struct*", $LEB, "wstr", $sProgramPath, "ptr", Null, "wstr", @WorkingDir, "ptr", Null, "ptr", Null, "struct*", $tProcessInfo, "ptr", Null, "ptr", Null, "ptr", Null, "ptr", Null) If @error Then MsgBox(0, "Error", "Error - " & @Extended) DllClose($hDLL) Exit EndIf DllClose($hDLL) Any help is appreciated! LoaderDll.dll LocaleEmulator.dll
  8. A solution I considered. I've seen it somewhere before tbh, not my idea. Don't remember where. Anyway, I can find workarounds for the first 2 however I'm not sure what to do with the third one. According to this article https://learn.microsoft.com/en-us/windows/win32/controls/stm-setimage the leak needs to be cleaned manually however it doesn't work. There's no error, _WinAPI_DeleteObject() should do the trick but it doesn't...
  9. FIrst of all, I apologize for the state of how it all looks as I had to remove thousands of lines to make a workable demo. It works, but it's not pretty. So if you see any inconsistencies just handwave it and they'll go away. 1. First issue is with Global $idPic = GUICtrlCreatePic('', 10, 45, 720, 405) on line 15. It works well however I want to center the image in the control by using $SS_CENTERIMAGE. The moment I add that style and click on a different image the new one simply repaints on top of the old one. Refer to function Func1 for repainting. I could always resize the picture control and place it in the middle based on the bitmap passed but seems like the $SS_CENTERIMAGE is (should be) the perfect solution. 2. Next is the fact that I couldn't find a way to make images scrollable with a horizontal bar only in the list view. Basically one row and infinite columns is what I'd like. I tried formatting the list with with just 1 item and all the rest are subitems however the images are not displayed. Seems like the isssue is with the _GUICtrlListView_SetView($idListview, 0). Specifically the fact that 0 value refers to large icons and the list is then treated differently. I'm wondering if there are any workarounds or similar solutions. 3. It seems there's a memory leak in function Func1. RAM increases each time a new thumbnail is loaded without releasing the old one when next one is drawn. Any help is much appreciated. Been stuck on couple of these for a few days now.
  10. @Nine I'll look into the overlapped functions, thanks. As for the other approach it's something that I'm already doing. I was just wondering if this way it would be much more efficient. As for the SoundPlay function it was an example I wanted to start with as that function specifically just "broke" at one point. It simply ran and didn't give an error (sound never played), but instead of looking into it I just replaced it with _SoundPlay. What was the cause I have no idea, perhaps caching of the sounds or something. @RTFC I will check these as well.
  11. Hello, I've been looking into offloading a couple functions outside of the main script as they are blocking. Such as FileCopy, PlaySound and anything else that has to parse large number of folders. So I've looked into C++ and dll files with the help of this topic among others. However I can't quite figure out how to work with these files. As of right now when I'm calling the file the script pauses until the function within the dll finishes running. I'm not sure if this has to do with the fact that AutoIt is waiting for a return. Is there a way to not need a return from let's say function number 1, but wait for return from function number 2 somewhere in the loop? In the future I will need to do both. Have the function execute without having any return and have another one return value while still not pausing main script in AutoIt. Does any of this have to do with DllCallbackRegister or is the pausing due to MessageBox function in C++ hanging main script because it was executed under it? $dll = DllOpen("A:\DLL functions\functions\Debug\functions.dll") If Random(1, 2, 1) = 1 Then DllCall($dll, "none:cdecl", "PlaySound", "str", "A:\test.wav") Else $aReturn = DllCall($dll, "int:cdecl", "Test", "int", 2, "int", 3) ConsoleWrite('Return: ' & $aReturn[0]) EndIf DllClose($dll) My C++ code looks like this (first time trying C++): Header: #ifndef _DLL_TUTORIAL_H_ #define _DLL_TUTORIAL_H_ #include <iostream> #define DECLDIR __declspec(dllexport) extern "C" { // Functions DECLDIR int Test(int a, int b); DECLDIR void PlaySound(const char* c); } #endif CPP file: #include <iostream> #include <Windows.h> #include <pch.h> #include "Header.h" #include <iostream> #include <string> extern "C" { DECLDIR int Test(int a, int b) //Function 1 { int sum = a + b; //std::string text = "Result is: " + std::to_string(sum); //MessageBox(0, TEXT(text.c_str()), TEXT("Title"), 0); return sum; } DECLDIR void PlaySound(const char* c) //Function 2 { //std::cout << "DLL Called!" << std::endl; std::string text = "Passed from AutoIt - "; text += c; MessageBox(0, TEXT(text.c_str()), TEXT("Title"), 0); return; //------------------------------------------------------------ //PlaySound() } } functions.dll
  12. While I appreciate the other responses they wouldn't work since: $sText = ' HYPERLINK "A:\test\folder\1"[Folder] more test text - HYPERLINK "A:\test\folder\1\6-07-02-2023-13-52-46-1.png"6-07-02-2023-13-52-46-1.png ' $sbefore = '- HYPERLINK "' $sAfter ='"6' ;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< This assumes it always ends at 6 $iStart = StringInStr($sText, $sbefore) $iEnd = StringInStr($sText, $sAfter) $iCount = $iEnd - $iStart - StringLen($sbefore) ConsoleWrite ($iStart & '|' & $iEnd & '|' & $iCount & @CRLF) $sResult = StringMid($sText, $iStart + StringLen($sbefore), $iCount) MsgBox(64, 'Result: ', $sResult, 15) #include <string.au3> $sText = ' HYPERLINK "A:\test\folder\1"[Folder] more test text - HYPERLINK "A:\test\folder\1\6-07-02-2023-13-52-46-1.png"6-07-02-2023-13-52-46-1.png ' local $ext='.png' local $_StringBetween=_StringBetween($sText,'- HYPERLINK "',$ext) ;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< While this, starts with - HYPERLINK " if not @error then MsgBox(64,'Result: ',$_StringBetween[0]&$ext) ...everything else is variable. I did change a little pixelsearch's answer to suit my case better and with less steps in the end: (?is)HYPERLINK "([^"]*?\.(?:png"))
  13. Hello. I've browsed the forums for a while however wasn't able to find exactly what I'm looking for. I have the following string as example with characters marked in bold as my desired match (full file path): test text "" HYPERLINK "A:\test\folder\1"[Folder] more test text - HYPERLINK "A:\test\folder\1\6-07-02-2023-13-52-46-1.png"6-07-02-2023-13-52-46-1.png This string has 2 hyperlinks with only one reffering to the actual file, while the other one points to the folder. The string can have only 1 full file path, however its placement can vary. This function is running inside the WM_NOTIFY message as I am getting the text that is currently under the mouse position so the less steps it takes to get the final link the better. Basically what I need is always in between HYPERLINK " and .png" $sLink = StringRegExpReplace($sText, '(HYPERLINK ")[\s\S]*?(?=png")', '$1') The above is best what I got and even that is far from the desired result.
  14. You are correct when it comes to W10. Removing the extended style does work however I require it. To elaborate on my problem a little bit more. I have a child window that by default is attached to the main window and is completely transparent with a *.png over it and a couple of labels on top acting as invisible buttons. I draw and update the image (yes it changes) with _WinAPI_UpdateLayeredWindow(). And if I want to detach it I simply delete the previous GUI and recreate a new one (...BitOR($WS_EX_LAYERED, $WS_EX_TOOLWINDOW)...) with all the labels. So removing the extended style would be quite troublesome. I did try looking into _WinAPI_SetWindowLong() as one of its parameters is $GWL_HWNDPARENT however that seems to do nothing. MSDN page on SetWindowLongA (from the page: "You must not call SetWindowLong with the GWL_HWNDPARENT index to change the parent of a child window. Instead, use the SetParent function.") Example is from my script simply to show what I meant above. $GUI_MainImage = GUICreate($PROGRAMNAME, 232, 232, $TempPos[0], $TempPos[1] + $TempPos[3] - 250, -1, BitOR($WS_EX_LAYERED, $WS_EX_TOOLWINDOW), $GUI_MainWindow) $GUI_MainImageTouch0 = GUICtrlCreateLabel('', 0, 0, 0, 0) ;Inactive $GUI_MainImageTouch1 = GUICtrlCreateLabel('', 70, 0, 120, 100) $GUI_MainImageTouch2 = GUICtrlCreateLabel('', 60, 150, 50, 40) $GUI_MainImageTouch3 = GUICtrlCreateLabel('', 80, 100, 40, 40) GUISetState(@SW_SHOWNOACTIVATE, $GUI_MainImage)
  15. Hello, I've stumbled upon an issue trying to change how one of my child windows behaves and looked through the forum for an answer however the closest I got to was this post: https://www.autoitscript.com/forum/topic/201385-solved-gui-design-layering-transparency-_winapi_setparent-with-guictrlcreatepic-doesnt-work/ So for the sake of simplicity I'll be borrowing the original code with a couple of changes. #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <WinAPI.au3> Local $hMainGUI = GUICreate("Main Background - Example 4", 500, 500, 0, 0, -1) GUISetBkColor(0x000000) GUISetState() Local $hGUIOverlay = GUICreate("Test 4", 500, 500, 0, 0, -1, $WS_EX_LAYERED) GUISetBkColor(0x0000F4) Local $idButton = GUICtrlCreateButton("C:\Program Files (x86)\AutoIt3\Examples\GUI\mslogo.jpg", 50, 50, 255, 40) GUICtrlCreatePic("C:\Program Files (x86)\AutoIt3\Examples\GUI\mslogo.jpg", 50, 100, 255, 40) _WinAPI_SetLayeredWindowAttributes($hGUIOverlay, 0x0000F4) GUISetState() _WinAPI_SetParent($hGUIOverlay, $hMainGUI) _WinAPI_MoveWindow($hGUIOverlay, 0, 0, 500, 500) ConsoleWrite(WinGetHandle($hMainGUI) & @CRLF) Local $Check While 1 $Msg = GUIGetMsg() Select Case $Msg = $idButton If $Check = True Then Local $hWndHandle = _WinAPI_SetParent($hGUIOverlay, $hMainGUI) ConsoleWrite($hWndHandle) ;~ $Pos = WinGetPos($hMainGUI) ;~ _WinAPI_MoveWindow($hGUIOverlay, 0, 0, 500, 500) $Check = False Else _WinAPI_SetParent($hGUIOverlay, 0) _WinAPI_MoveWindow($hGUIOverlay, 0, 0, 500, 500) $Check = True EndIf Case $Msg = $GUI_EVENT_CLOSE GUIDelete($hGUIOverlay) GUIDelete($hMainGUI) Exit EndSelect WEnd My problem is trying to attach the child window back to the main AFTER it was detached. Currently the way I'm overcoming this problem is by deleting and re-creating the child window with all its controls with the proper parent handle (example from my own script): ...BitOR($WS_EX_LAYERED, $WS_EX_TOOLWINDOW), $hMainGUI... To be honest, not sure if this is even possible.
  16. Sorry for resurrecting an OLD thread however this is a quite useful piece of code so I wanted to provide a solution for issue #2. It simply requires an ABGR value instead of RGB. In "RichEdit Hyperlink.au3" Global Const $COLOR_HYPERLINK = "0x00" & Hex(_WinAPI_SwitchColor(0xCC6600), 6)
  17. Well now that I see this I could've called the parameter as a string. I was not aware that I could do that and what I had was: DllStructGetData($tMsgFilter, $wParam) instead of DllStructGetData($tMsgFilter, 'wParam'). Thanks to both of you.
  18. Yeah that's what I've tried earlier. Seems to me like RichEdit has own messages (https://learn.microsoft.com/en-us/windows/win32/controls/rich-edit-control-event-mask-flags) it listens to and that's why I wanted to do it using WM_NOTIFY and event mask so I could have everything under single function for future.
  19. I'm getting a 0 only from that parameter. Unless I'm missing a step, fairly new to WM commands. I've actually seen that topic before however the richedit control seems to intercept the scrolling message and it won't detect scrolling when hovering over it.
  20. Hello, To make things short, for various reasons I'm using $WM_NOTIFY (I am aware of $WM_MOUSEWHEEL) to call the function and an event mask to detect multiple changes inside the edit control. However I am having trouble distinguishing scroll up and down. To me it seems like there's just no way to tell the difference between the two within the method that I'm using.
  21. Thank you both for the responses! In my case the solution with adding $WS_EX_COMPOSITED style to the main GUI works better as I also change that background image further down the code and this doesn't cause the elements to disappear. Adding BitOR($GUI_SS_DEFAULT_PIC, $WS_CLIPSIBLINGS) to the picture control works but only with the enabled controls. I have some buttons that have $GUI_DISABLE state from the beginning and they don't render.
  22. First I'd like to thank you for creating this UDF. It's simple to use and provides the perfect alternative to the buttons we have. However I have an issue where if I use a background image for a GUI the button does not render until I hover over it with a mouse. The button would also disappear until hovered over if I were to update the background picture. This applies to buttons with enabled and disabled state, but disabled ones won't draw at all until enabled first. Is there a solution to this? I've tried redrawing the window but it doesn't work. #include <GUIConstantsEx.au3> #include <GuiFlatButton.au3> $hGUI = GUICreate('test', 100, 100, -1, -1, $WS_POPUP + $WS_BORDER) GUICtrlCreatePic('C:\Windows\Web\Wallpaper\Windows\img0.jpg', 0, 0, 80, 100) GUICtrlSetState(-1, $GUI_DISABLE) GuiFlatButton_Create('test', 10, 40, 100, 20, $BS_LEFT) GUISetState(@SW_SHOW, $hGUI) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE GUIDelete($hGUI) Exit EndSwitch Sleep(10) WEnd
  23. No I did not. I'm using Lite 3.5.4 at the moment, but this gives me an idea to simply write a simple function to copy the file every time I run it if it's not compiled.
  24. Unfortunately that's the thing, I always do Ctrl+S. So supposedly the file would recover to that point but it didn't. Perhaps at the exact time as I was saving the blackout happened. But the save time is around 3 seconds so it's too close to tell... Anyway, thanks for the response.
  25. Hello, I was wondering if it's possible to recover the script file after a power outage, which happened as I was working in the editor. It seems there are correct numbers of characters in it (138249) however they're all replaced with "NULL" in one line. File size identical as well. I have a backup from couple of days ago but that's a lot of progress lost...
×
×
  • Create New...