Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 07/25/2025 in Posts

  1. You could grab the event sent by Excel before a workbook gets closed. Something like this: #include <Excel.au3> HotKeySet("+!e", "_Exit") ;Shift-Alt-E to Exit the script MsgBox(64, "Excel UDF: Events Example", "Hotkey to exit the script: 'Shift-Alt-E'!") ; Create application object and open a workbook Global $oExcel = _Excel_Open() Global $oWorkbook = _Excel_BookNew($oExcel) ObjEvent($oWorkbook, "Workbook_") While 1 Sleep(10) WEnd Exit Func Workbook_BeforeClose() MsgBox(0, "WorkbookBeforeClose", "Name: " & $oWorkbook.Name) _Excel_Close($oExcel) _Exit() EndFunc ;==>Workbook_BeforeClose Func _Exit() Exit EndFunc ;==>_Exit This example works for the workbook opened by this script. If the user opens and closes another workbook nothing will happen.
    2 points
  2. @argumentum The way in which you described how the scripts are run, whether compiled or not, and the way that you described the different methods for closing processes was absolutely perfect. I mean it, that was very beneficial to me and helped my understanding a lot. Thank you.
    1 point
  3. An AutoIt compiled script loads the script from an internal resource. And AutoIt (not compiled) loads the script from file as a resource. ProcessClose() or WinKill() should not be used, ever. That is like unplugging the PC (for the program). And both do the same thing. WinClose() will do nicely ( like Jos pointed out above ). If you have a script ( compiled or not ) running as user level, it will not have permissions to do anything to another running at an admin level ( that I guess is the "problem" you're having ) ...but by now ( am slow at typing ) the OP is satisfied but I wrote all this so..., here
    1 point
  4. @SOLVE-SMART, That Cheat Sheet in your signature is neat. @photonbuddy Checkout _INetGetSource() too.
    1 point
  5. Nine

    edit ListView sub-items

    You can't, not with standard functionality of a list view . Only the item (first column) can be edited in place using $LVS_EDITLABELS. If you truly want it, you would need a workaround, like creating an input box when you dbl-click on a subitem. Here a simple example : #include <GUIConstants.au3> #include <GuiListView.au3> Opt("GUICloseOnESC", 0) Opt("MustDeclareVars", True) Global $hList, $idDummy Example() Func Example() Local $hMain = GUICreate("Example", 230, 170) Local $idList = GUICtrlCreateListView("Column 1|Column 2", 10, 10) GUICtrlCreateListViewItem("Item 1|Item 2", $idList) GUICtrlCreateListViewItem("Item 3|Item 4", $idList) $hList = GUICtrlGetHandle($idList) $idDummy = GUICtrlCreateDummy() GUIRegisterMsg($WM_NOTIFY, WM_NOTIFY) GUISetState() Local $iItem, $iSubItem, $aRect, $sData, $aPos = ControlGetPos($hMain, "", $idList) While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $idDummy $iItem = _WinAPI_LoWord(GUICtrlRead($idDummy)) $iSubItem = _WinAPI_HiWord(GUICtrlRead($idDummy)) If $iSubItem = 0 Then ContinueLoop $aRect = _GUICtrlListView_GetSubItemRect($idList, $iItem, $iSubItem) $sData = GUICreateInput($hMain, _GUICtrlListView_GetItemText($idList, $iItem, $iSubItem), $aRect[0] + $aPos[0], $aRect[1] + $aPos[1], $aRect[2] - $aRect[0], $aRect[3] - $aRect[1]) If $sData Then _GUICtrlListView_SetItemText($idList, $iItem, $sData, $iSubItem) EndSwitch WEnd EndFunc ;==>Example Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam) If $tInfo.hWndFrom = $hList And $tInfo.Code = $NM_DBLCLK Then GUICtrlSendToDummy($idDummy, _WinAPI_MakeLong($tInfo.Index, $tInfo.SubItem)) Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Func GUICreateInput($hWnd, $sText, $iLeft, $iTop, $iWidth, $iHeight) Local $hGUI = GUICreate("", $iWidth, $iHeight, $iLeft, $iTop + 1, $WS_POPUP, $WS_EX_MDICHILD, $hWnd) Local $idInput = GUICtrlCreateInput($sText, 0, 1, $iWidth, $iHeight - 1) Local $idOut = GUICtrlCreateDummy() GUISetState() GUISetState(@SW_DISABLE, $hWnd) Local $aAccel[2][2] = [["{ENTER}", $idInput], ["{ESC}", $idOut]], $sInput GUISetAccelerators($aAccel, $hGUI) While True Switch GUIGetMsg() Case $idInput $sInput = GUICtrlRead($idInput) ExitLoop Case $idOut ExitLoop EndSwitch WEnd GUIDelete($hGUI) GUISetState(@SW_ENABLE, $hWnd) GUISetState(@SW_RESTORE, $hWnd) Return $sInput EndFunc ;==>GUICreateInput
    1 point
×
×
  • Create New...