Good morning community!
I was working on a script which read the content of a .ini file to retrieve the file that has to open, and, based on the value of a second key stored in the .ini file, set the window on top, minimized or maximized...
I did something like this, but seems to not work properly...
Could anyone please tell me what I'm doing wrong?
#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Outfile_x64=prova.exe #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <MsgBoxConstants.au3> #include <AutoItConstants.au3> ;#include <WinAPIEx.au3> #include <Array.au3> Local $sFileConfigurazione = @ScriptDir & "\configurazione_exe.ini" If(FileExists($sFileConfigurazione)) Then Local $aSezioneIni = IniReadSection($sFileConfigurazione, "CONFIGURAZIONE_EXE") If @error Then MsgBox($MB_ICONERROR, "Errore!", "Errore durante l'apertura del file: " & @CRLF & $sFileConfigurazione & @CRLF & "Errore: " & @error) Else ; Lancio dell'applicativo indicato nel file di configurazione Local $iPID = ShellExecute($aSezioneIni) Local $hWnd If($iPID <> 0) Then Local $aWinList = WinList() For $i = 1 To $aWinList If(WinGetProcess($aWinList[$i] = $iPID)) Then $hWnd = $aWinList[$i] EndIf Next Switch($aSezioneIni) Case $aSezioneIni = "MIN" ToolTip("MIN", 0, 0) WinSetState($hWnd, WinGetTitle($hWnd), @SW_MINIMIZE) Case $aSezioneIni = "MAX" ToolTip("MAX", 0, 0) WinSetState($hWnd, WinGetTitle($hWnd), @SW_MAXIMIZE) Case $aSezioneIni = "TOP" ToolTip("TOP", 0, 0) WinSetOnTop($hWnd, WinGetTitle($hWnd), $WINDOWS_ONTOP) EndSwitch EndIf EndIf EndIf And the .ini file is like this:
[CONFIGURAZIONE_EXE] PercorsoExe=Here goes the path and the .exe to execute ModalitaAperturaExe=Here goes one of the value below /* TOP Shows the windows on top */ /* MIN Shows the window minimized */ /* MAX Shows the window maximized */
I'm trying to make cursor for my program, and I need to make it on top but not active when pressed on start menu, taskbar or etc. (cursor appears behind taskbar/start menu).
Somebody could help me with this problem?
; A bit of my script #include <GUIConstants.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> #include <GDIPlus.au3> #include <GuiListBox.au3> Global $Bitmap_Mouse_Pic_Dir = @ScriptDir&"\Cursor.png" Global $Bitmap_Mouse_Pic = _GetWHI($Bitmap_Mouse_Pic_Dir) Global $Bitmap_Mouse_PicSel_Dir = @ScriptDir&"\Selection.png" Global $Bitmap_Mouse_PicSel = _GetWHI($Bitmap_Mouse_PicSel_Dir) Global $Bitmap_Mouse_Opt = 255 ; ... For $i = 0 to 0 $GP_guicur[$i] = GUICreate("GP Cursor", 64, 64, $POS[$i], $POS[$i], $WS_POPUP, $WS_EX_LAYERED, $GUI) WinSetOnTop($GP_curgui[$i],"",1) SetBitmap($GP_curgui[$i], $Bitmap_Mouse_Pic, $Bitmap_Mouse_Opt) GUISetState(@SW_SHOW) Next ; ... For ; ... Sleep(1000) MouseClick("left",5,@DesktopHeight-5) ; ... Next Exit ;______________________________________________________________________; ; Original program by Ejoc ; ; Improved by Adam1213 (autoit 3.2 compatiblity + improved labels; ;______________________________________________________________________; ; $sImage = Path to your image ; Returns = Array ; $Array = Width ; $Array = Height ; $Array = handle to a HBITMAP ; when the image is no longer needed use _WinAPI_DeleteObject($Array) Func _GetWHI($sImage) Local $hImage, $aBitmap _GDIPlus_Startup() $hImage = _GDIPlus_ImageLoadFromFile($sImage) $aBitmap = _GDIPlus_ImageGetWidth($hImage) $aBitmap = _GDIPlus_ImageGetHeight($hImage) $aBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) _GDIPlus_ImageDispose($hImage) _GDIPlus_Shutdown() Return $aBitmap EndFunc ;==>_GetWHI ; I changed this so I could shutdown gdiplus once an image has been loaded by _GetWHI() ; just pass it the array returned by _GetWHI() Func SetBitmap($hGUI, $aBitmap, $iOpacity) Local Const $AC_SRC_ALPHA = 1 Local $hScrDC, $hMemDC, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend $hScrDC = _WinAPI_GetDC(0) $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC) $hOld = _WinAPI_SelectObject($hMemDC, $aBitmap) $tSize = DllStructCreate($tagSIZE) $pSize = DllStructGetPtr($tSize) DllStructSetData($tSize, "X", $aBitmap) DllStructSetData($tSize, "Y", $aBitmap) $tSource = DllStructCreate($tagPOINT) $pSource = DllStructGetPtr($tSource) $tBlend = DllStructCreate($tagBLENDFUNCTION) $pBlend = DllStructGetPtr($tBlend) DllStructSetData($tBlend, "Alpha", $iOpacity) DllStructSetData($tBlend, "Format", $AC_SRC_ALPHA) _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA) _WinAPI_ReleaseDC(0, $hScrDC) _WinAPI_SelectObject($hMemDC, $hOld) _WinAPI_DeleteDC($hMemDC) EndFunc ;==>SetBitmap
I'd like to move a window to the top of the stack without it being active.
I think it's called z-order in programming?
I've tried these 2 options (commenting out 1 at a time obviously), but the 1st doesn't seem to do anything, and the 2nd prevents it from being moved behind the other programs even after clicking on it and then clicking on another window behind it:
Local $hWnd = WinGetHandle("[CLASS:MSPaintApp]")
_WinAPI_SetWindowPos($hWnd, $HWND_TOP, 0, 0, 0, 0, BitOR($SWP_FRAMECHANGED, $SWP_NOMOVE, $SWP_NOSIZE))
_WinAPI_SetWindowPos($hWnd, $HWND_TOPMOST, 0, 0, 0, 0, BitOR($SWP_FRAMECHANGED, $SWP_NOMOVE, $SWP_NOSIZE))
What can I do to move something to the top of the z-order while allowing it to be manually moved back in the z-order?
I am trying to change the z-ordering of controls in my GUI using GUICtrlSetState. How come this example don't work? (I want $LABEL1 to be above $LABEL2)
#include <GUIConstantsEx.au3> $GUI = GUICreate("Test", 800, 600) GUISetState() $LABEL1 = GUICtrlCreateLabel("under", 20, 20, 500, 300) GUICtrlSetBkColor(-1, 0xFF0000) $LABEL2 = GUICtrlCreateLabel("above", 40, 60, 500, 300) GUICtrlSetBkColor(-1, 0x00FF00) GUICtrlSetState($LABEL1, $GUI_ONTOP) Do Sleep(50) Until GUIGetMsg() = -3 Exit Is there another method to change the z ordering and the order controls receive clicks? I know that the controls should be created in the correct order, but I can't in the script I am doing now.
[EDIT] Solution is in post #5
I'm currently trying to solve a problem I'm having with the GUIExtender-UDF by Melba23, but I can't relly get the hang of it and I think I need someone to straightening this out for me.
What I'm trying to achieve is a "menu-ish" GUI with buttons that takes you deeper and further into the menues, and aswell to have a back-button which lets you return to the previously extended section. I've done this before with the use of multiple child GUIs being hidden/shown, but that was taking too much out of the computer as I'll be working with 20+ windows/sections.
What I've been testing so far is the following:
#include "GUIExtender.au3" #include <GUIConstantsEx.au3> $GUI = GUICreate("Test",500,300,-1,-1) _GUIExtender_Init($GUI, 1) $Back = GUICtrlCreateButton("Back",50,20,50,25) $Window1 = _GUIExtender_Section_Start(50, 500) _GUIExtender_Section_Action($Window1) $Button1 = GUICtrlCreateButton("Button1",100,100,100,30) _GUIExtender_Section_End() $Window2 = _GUIExtender_Section_Start(50, 500) _GUIExtender_Section_Action($Window2) $Button2 = GUICtrlCreateButton("Button2",150,100,100,30) _GUIExtender_Section_End() $Window3 = _GUIExtender_Section_Start(50, 500) _GUIExtender_Section_Action($Window3) $Button3 = GUICtrlCreateButton("Button3",250,100,100,30) _GUIExtender_Section_End() _GUIExtender_Section_Extend(0, False,0) _GUIExtender_Section_Extend($Window1, True,0) GUISetState() while 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit case $Button1 _GUIExtender_Section_Extend(0, False,0) _GUIExtender_Section_Extend($Window2, True,0) case $Button2 _GUIExtender_Section_Extend(0, False,0) _GUIExtender_Section_Extend($Window3, True,0) case $Button3 _GUIExtender_Section_Extend(0, False,0) _GUIExtender_Section_Extend($Window1, True,0) case $Back EndSwitch WEnd
When I just had 2 sections created the extend/retract worked as I think it should, which is hideing one and showing the other. But as I added the 3rd section by using the same terms as the precious 2 it's now having both section 2 & 3 extended at same time and somewhat linking them togeather, idk.
I've tried to get the hang of this by the examples provided by Melba and by the UDF itself, but it seem like I got something wrong..