Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 03/08/2016 in all areas

  1. water

    OutlookEX

    Version 1.7.0.1

    10,051 downloads

    Extensive library to control and manipulate Microsoft Outlook. This UDF holds the functions to automate items (folders, mails, contacts ...) in the background. Can be seen like an API. There are other UDFs available to automate Outlook: OutlookEX_GUI: This UDF holds the functions to automate the Outlook GUI. OutlookTools: Allows to import/export contacts and events to VCF/ICS files and much more. Threads: Development - General Help & Support - Example Scripts - Wiki BTW: If you like this UDF please click the "I like this" button. This tells me where to next put my development effort KNOWN BUGS (last changed: 2020-02-09) None
    1 point
  2. spudw2k

    Win10 - profile problem

    Make sure the new user account has full control permissions to the profile directory? You can verify the assigned profile directory by inspecting the following registry key/value. HKLM\Software\Microsoft\Windows NT\CurrentVersion\ProfileList\{SID}\ProfileImagePath
    1 point
  3. What sort of discussion would you expect'? Bug reports are quite important. This is the kind of project which will see downloads, likes and appraisal comments over a long time. Most veterans of autoit are happy to use the vast _WinAPI library, or knock a call up themselves, the noobs that will find this most useful are the ones unlikely to post other than to report a bug. A lot of people have posted things here in examples which get zero replies, it's a cold cold place, so needy people should avoid it really, or try to contain their disappointment that everyone else does not share their enthusiasm or sense of acheivement. I seen someone post something here not to long ago, then remove it because he never got the ego stroking he expected, was one of the most pathetic things I've ever seen online, and I'd hate to ever see something like that again. So please, if thid project interests you, please do not be put off passing bug reports.
    1 point
  4. jvanegmond

    How computers work

    Maybe nitpicking but, INC is not atomic in x86 and you missed bad branch predictions as a leading cause of performance woes, which is arguably the most important next to caching behavior. @JohnOne you may enjoy http://www.nand2tetris.org/ . I can highly recommend it. Skip the stuff you already know and get programming. You can even do it in AutoIt if you are uncomfortable doing the instructions as suggested.
    1 point
  5. VenusProject2, You were exiting the clock within the _ExitClock function which was called by a HotKey. This function deleted the clock GUI, but did not affect the loop inside the _DigitalClock function, so the _draw function was still called and, as the only GUI left was the main one, that is where the function drew the clock. I suggest you use a flag to show when the clock has been killed in the HotKey function and look for that flag in the loop - like this: #include <Misc.au3> #include <GUIConstants.au3> #include <Date.au3> Opt("TrayIconDebug", 1) Global $fClose = False HotKeySet("{ESC}", "_ExitClock");To Exit Digital Clock use "Esc" key held for >3sec Dim $aXY[2] Global $Init0, $PausedTimer, $iTimerHours, $iTimerMins, $iTimerSecs Global $sec = @SEC Global $hDLL = DllOpen("user32.dll") Global $iEvent = 0 Global $AlarmHour = 0 Global $AlarmMin = 0 Global $AlarmSec = 0 Global $SecSquare = GUICtrlCreateGraphic(0, 0, 0, 0) Global $ClockSquare = GUICtrlCreateGraphic(5, 5, 180, 30);Local Time Global $TimerSquare = GUICtrlCreateGraphic(205, 5, 220, 30);Timer Global $AlarmSquare = GUICtrlCreateGraphic(480, 5, 220, 30);Alarm Time Global $gui Dim $aDigChar[14] _initDigChar($aDigChar) ; Create a GUI with various controls. Local $Form1 = GUICreate("Example") Local $StartB = GUICtrlCreateButton("Use 'Alt+S' to start Clock", 130, 200, 150, 25) Local $PauseB = GUICtrlCreateButton("Use 'Alt+P' to pause Clock", 130, 250, 150, 25) Local $ResumeB = GUICtrlCreateButton("Use 'Alt+R' to resume Clock", 130, 300, 150, 25) GUICtrlSetState($StartB, $GUI_DISABLE) GUICtrlSetState($PauseB, $GUI_DISABLE) GUICtrlSetState($ResumeB, $GUI_DISABLE) Local $OK = GUICtrlCreateButton("Display Clock", 270, 370, 125, 25) ; Display the GUI. GUISetState(@SW_SHOW, $Form1) ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $idOK ExitLoop Case $OK _DigitalClock() EndSwitch WEnd ; Delete the previous GUI and all controls. GUIDelete($Form1) Func _DigitalClock() $gui = GUICreate("Digital Timer", 702, 40, -1, -1, -1, $WS_EX_TOPMOST) ;$gui = GUICreate("Test", 702, 702) GUISetBkColor(0x000000) GUISetState() $SecSquare = GUICtrlCreateGraphic(0, 0, 0, 0) $ClockSquare = GUICtrlCreateGraphic(5, 5, 180, 30);Local Time $TimerSquare = GUICtrlCreateGraphic(205, 5, 220, 30);Timer $AlarmSquare = GUICtrlCreateGraphic(480, 5, 220, 30);Alarm Time Dim $msg[1] ;$AddMinutes = 10 While 1 ; main loop, waits until @sec changes and then executes main drawing management function While @SEC = $sec $msg = GUIGetMsg(1) If $msg[0] = -3 Then DllClose($hDLL) Return EndIf If _IsPressed("12", $hDLL) Then;'Alt' ConsoleWrite("_IsPressed - Alt Key was pressed." & @CRLF) ; Wait until key is released. While _IsPressed("12", $hDLL); If _IsPressed("53",$hDLL) Then;'s' ConsoleWrite("_IsPressed - 'o' Key was pressed." & @CRLF) start_timer() EndIf If _IsPressed("50",$hDLL) Then;'p' ConsoleWrite("_IsPressed - 'p' Key was pressed." & @CRLF) pause_timer() EndIf If _IsPressed("52",$hDLL) Then;'r' ConsoleWrite("_IsPressed - 'r' Key was pressed." & @CRLF) resume_timer() EndIf Sleep(300);(250) WEnd ElseIf _IsPressed("1B", $hDLL) Then MsgBox($MB_SYSTEMMODAL, "_IsPressed", "The Esc Key was pressed, therefore we will close the application.") ExitLoop EndIf Sleep(10) WEnd If $fClose Then $fClose = False AdlibUnRegister("show_timer") GUIDelete($gui) GUISetState(@SW_ENABLE, $Form1);enable parent GUI GUISetState(@SW_SHOW,$Form1) Return Else _draw() Sleep(50) $sec = @SEC EndIf WEnd EndFunc; ==> _DigitalCLock Func _ExitClock();Press Escape key for >5sec Local $Count = 0 If _IsPressed("1B",$hDLL) Then $Return = _KeyPressed("1B", $Count) ConsoleWrite("Escape Key Held for - " & $Return & "mS" & @CRLF) If $Return > 3000 Then $fClose = True EndIf Endif EndFunc;==>_ExitClock() Func _KeyPressed($kp_Key, ByRef $kp_Count) $kp_Count += 1 Local $kp_Timer = TimerInit() While _IsPressed("1B") Sleep(100) WEnd Return TimerDiff($kp_Timer) EndFunc ;==>_KeyPressed ;################ Functions from StopwatchUDF.au3 ##################### ; The function that starts or resets the stopwatch Func start_timer() HotKeySet("{NUMPADMULT}") ;disable resume timer HotKeySet("{NUMPADSUB}", "pause_timer") ;enable pause timer $PausedTimer = 0 $Init0 = TimerInit() AdlibRegister("show_timer", 60) EndFunc ;==>start_timer ; The function that pauses the stopwatch Func pause_timer() HotKeySet("{NUMPADSUB}") ;disable pause timer HotKeySet("{NUMPADMULT}", "resume_timer") ;enable resume timer $PausedTimer += Int(TimerDiff($Init0)) AdlibUnRegister() EndFunc ;==>pause_timer ; The function that resumes the stopwatch Func resume_timer() HotKeySet("{NUMPADMULT}") ;disable resume timer HotKeySet("{NUMPADSUB}", "pause_timer") ;enable pause timer $Init0 = TimerInit() AdlibRegister("show_timer", 60) EndFunc ;==>resume_timer Func show_timer() ; _TicksToTime to get hours, mins, seconds _TicksToTime(Int(TimerDiff($Init0) + $PausedTimer), $iTimerHours, $iTimerMins, $iTimerSecs) ;StringFormat to display the time as HH:MM:SS ;ToolTip("HH:MM:SS = " & StringFormat("%02i:%02i:%02i", $iHours, $iMins, $iSecs), 0, 0, "Timer") EndFunc ;==>show_timer ; Exit Func Quit() Exit EndFunc ;==>Quit ;################ Functions from StopwatchUDF.au3 ##################### Func _draw($forceDraw = False) ; calculates angles for min/sec dials, manages execution of drawing routines Local $doDraw = False Sleep(25) ;_drawSec() _DrawClock() _DrawTimer();Digital Cue Timer 00:00:00 _DrawAlarmTime($iEvent);Event no. in Sequence with Hints in test string GUICtrlSetGraphic($SecSquare, $GUI_GR_REFRESH) EndFunc ;==>_draw ;#cs Func _DrawClock();Digital System Time ;return ; manages execution of write commands for HH MM SS characters GUICtrlDelete($ClockSquare) $ClockSquare = GUICtrlCreateGraphic(5, 5, 180, 30);5, 5, 200, 30 _timeWrite(0, Int(@HOUR / 10), "regular", $ClockSquare);e.g. 1pm = 13 /10 =1 _timeWrite(20, Mod(@HOUR, 10), "regular", $ClockSquare);e.g. 1pm = 13Mod10 = 1 with 3 remainder _timeWrite(50, Int(@MIN / 10), "regular", $ClockSquare) _timeWrite(70, Mod(@MIN, 10), "regular", $ClockSquare) _timeWrite(100, Int(@SEC / 10), "regular", $ClockSquare) _timeWrite(120, Mod(@SEC, 10), "regular", $ClockSquare) EndFunc ;==>_drawTime ;#ce Func _DrawTimer();Digital Cue Timer 00:00:00 ;return ; manages execution of write commands for HH MM SS characters GUICtrlDelete($TimerSquare) $TimerSquare = GUICtrlCreateGraphic(205, 5, 220, 30);Timer _timeWrite(0, 13, "Timer", $TimerSquare);C _timeWrite(20, 11, "Timer", $TimerSquare);L _timeWrite(50, 12, "Timer", $TimerSquare);- _timeWrite(80, Int($iTimerHours / 10), "Timer", $TimerSquare) _timeWrite(100, Mod($iTimerHours, 10), "Timer", $TimerSquare) _timeWrite(130, Int($iTimerMins / 10), "Timer", $TimerSquare) _timeWrite(150, Mod($iTimerMins, 10), "Timer", $TimerSquare) _timeWrite(180, Int($iTimerSecs / 10), "Timer", $TimerSquare) _timeWrite(200, Mod($iTimerSecs, 10), "Timer", $TimerSquare) EndFunc ;==>_drawTime ;#cs Func _drawAlarmTime($iEvent);Digital Time ;Return ; manages execution of write commands for HH MM SS characters for the Alarm time GUICtrlDelete($AlarmSquare) $AlarmSquare = GUICtrlCreateGraphic(480, 5, 220, 30) _timeWrite(0, 10, "Alarm", $AlarmSquare);A _timeWrite(20, 11, "Alarm", $AlarmSquare);L _timeWrite(50, 12, "Alarm", $AlarmSquare);- _timeWrite(80, Int($AlarmHour / 10), "Alarm", $AlarmSquare) _timeWrite(100, Mod($AlarmHour, 10), "Alarm", $AlarmSquare) _timeWrite(130, Int($AlarmMin / 10), "Alarm", $AlarmSquare) _timeWrite(150, Mod($AlarmMin, 10), "Alarm", $AlarmSquare) _timeWrite(180, Int($AlarmSec / 10), "Alarm", $AlarmSquare) _timeWrite(200, Mod($AlarmSec, 10), "Alarm", $AlarmSquare) EndFunc ;==>_drawAlarmTime ;#ce Func _timeWrite($pos, $num, $type, $graph) ; $type is "Regular" or "Alarm" or "Timer" ; manages coloring and writing of 7 segement LEDs for time writing _setColorAndPenForWrite(StringMid($aDigChar[$num], 1, 1), $type);0 _line($graph, $pos + 5, 2, $pos + 3, 10) _setColorAndPenForWrite(StringMid($aDigChar[$num], 2, 1), $type);1 _line($graph, $pos + 2, 14, $pos + 0, 22) _setColorAndPenForWrite(StringMid($aDigChar[$num], 3, 1), $type);2 _line($graph, $pos + 5 + 2, 0, $pos + 5 + 8, 0) _setColorAndPenForWrite(StringMid($aDigChar[$num], 4, 1), $type);3 _line($graph, $pos + 2 + 2, 12, $pos + 2 + 8, 12) _setColorAndPenForWrite(StringMid($aDigChar[$num], 5, 1), $type);4 _line($graph, $pos + 2, 24, $pos + 8, 24) _setColorAndPenForWrite(StringMid($aDigChar[$num], 6, 1), $type);5 _line($graph, $pos + 5 + 10, 2, $pos + 3 + 10, 10) _setColorAndPenForWrite(StringMid($aDigChar[$num], 7, 1), $type);6 _line($graph, $pos + 2 + 10, 14, $pos + 10, 22) EndFunc ;==>_timeWrite ;#cs Func _line($graph, $x1, $y1, $x2, $y2);Seven Segment Display ;Return ; draws line for time writing GUICtrlSetGraphic($graph, $GUI_GR_MOVE, $x1 + 2, $y1 + 2) GUICtrlSetGraphic($graph, $GUI_GR_LINE, $x2 + 2, $y2 + 2) EndFunc ;==>_line ;#ce Func _setColorAndPenForWrite($char, $type) ; sets color and pen for next line in time writing, based on '0' or '1' in the DigChar array If $char = "1" Then;7 Segment display ON=1 or OFF=0 If $type = "Alarm" Then GUICtrlSetGraphic($AlarmSquare, $GUI_GR_PENSIZE, 2) GUICtrlSetGraphic($AlarmSquare, $GUI_GR_COLOR, 0xCCCCCC, 0xCCCCCC) ElseIf $type = "Timer" Then GUICtrlSetGraphic($TimerSquare, $GUI_GR_PENSIZE, 2) GUICtrlSetGraphic($TimerSquare, $GUI_GR_COLOR, 0x00ff00, 0x00ff00);ct - Bright Green RGB Else GUICtrlSetGraphic($ClockSquare, $GUI_GR_PENSIZE, 2) GUICtrlSetGraphic($ClockSquare, $GUI_GR_COLOR, 0xEE0000, 0xEE0000) EndIf Else If $type = "Alarm" Then GUICtrlSetGraphic($AlarmSquare, $GUI_GR_PENSIZE, 2) GUICtrlSetGraphic($AlarmSquare, $GUI_GR_COLOR, 0x222222, 0x222222) ElseIf $type = "Timer" Then;ct GUICtrlSetGraphic($TimerSquare, $GUI_GR_PENSIZE, 2) GUICtrlSetGraphic($TimerSquare, $GUI_GR_COLOR, 0x002200, 0x002200);ct - Lite Green RGB Else GUICtrlSetGraphic($ClockSquare, $GUI_GR_PENSIZE, 2) GUICtrlSetGraphic($ClockSquare, $GUI_GR_COLOR, 0x330000, 0x330000) EndIf EndIf EndFunc ;==>_setColorAndPenForWrite Func _drawSec() Return ; draws circle seconds indicator $aXY = _getXY(@SEC, 240) GUICtrlDelete($SecSquare) $SecSquare = GUICtrlCreateGraphic(350 + $aXY[0] - 8, 350 + $aXY[1] - 8, 16, 16) GUICtrlSetGraphic($SecSquare, $GUI_GR_COLOR, 0x0000FF, 0x0000FF) GUICtrlSetGraphic($SecSquare, $GUI_GR_ELLIPSE, 0, 0, 16, 16) EndFunc ;==>_drawSec Func _getXY($sec, $hypo) ; returns array with X,Y coordinates for the seconds points for $sec seconds, with $hypo(tenuse) distance from center Dim $result[2] Local $pi = 3.14159265358979 Local $degToRad = $pi / 180 Local $degrees = $sec * 6 - 90 Local $x = Cos($degrees * $degToRad) * $hypo Local $y = Sin($degrees * $degToRad) * $hypo $result[0] = $x $result[1] = $y Return $result EndFunc ;==>_getXY Func _initDigChar(ByRef $aDigChar) ; define leds for digital numbers: 1 or 0 for leds on/off in 7-led digital clock characters $aDigChar[0] = "1110111" $aDigChar[1] = "0000011" $aDigChar[2] = "0111110" $aDigChar[3] = "0011111" $aDigChar[4] = "1001011" $aDigChar[5] = "1011101" $aDigChar[6] = "1111101" $aDigChar[7] = "0010011" $aDigChar[8] = "1111111" $aDigChar[9] = "1011111" $aDigChar[10] = "1111011" ; A $aDigChar[11] = "1100100" ; L $aDigChar[12] = "0001000" ; - $aDigChar[13] = "1110100" ;C EndFunc ;==>_initDigChar M23
    1 point
  6. RTFC

    How computers work

    Do I detect subliminal remnants of those silly TRON motorcycles zipping around your brain?
    1 point
  7. RTFC

    How computers work

    Hey, don't put yourself down like that, JohnOne. It's a good question; it's just that a CPU is an incredibly sophisticated and complicated piece of kit (other chips on the motherboard are much simpler beasts, with the possible exception of the GPU), so the moment you leave the highest abstraction layer, you slide down the rabbit hole and have to deal with odd analogies to get a handle on what's going on (funnily enough, when you dig even deeper to the core hardware, things appear to get simpler, but then quantum effects start to kick in and then you're truly lost). But if everyone were satisfied just clicking buttons and sharing cat videos, we'd never get anywhere interesting and new.
    1 point
  8. toasterking

    How computers work

    Because the two actually have little to do with each other. A race condition doesn't occur when the CPU does more than one thing at a time; a race condition occurs when two separate code paths (each representing many, many individual CPU instructions) have each been partially executed and the next one to have a turn is not aware of what the other one has been working on and makes an assumption. Imagine you're a customer (line of code) in a store (execution environment). There are two lines (threads) of customers all waiting to check out, but only a single cashier (CPU) who services each line of customers arbitrarily (preemptive multitasking). The cashier (CPU) is processing all the transactions (instructions) that keep the store (OS) running, but you don't necessarily care how the cashier does their job because you're just a shopper (a programmer of code in a high-level language) and that's not your job. You're waiting to buy a box of allergy medication (obtain a handle to a resource) which is stocked behind the counter. When you get in line, you count the number of people in front of you and calculate that there are enough boxes of the medication on the shelf for you to get one even if every person in front of you does. Just before you get to the register, someone buys the last box. What happened? Oh sh*t, you weren't paying attention to the other line. The cashier is oblivious to your massive fail and continues processing transactions like normal. You exit the store anyway (you did no error checking) and are stungbitten by a vampire bee. Without your medication (resource) you have an allergic reaction and die. You've crashed due to a race condition! Okay, so my analogy could probably use a little work, but hopefully you get the idea. When I was learning this stuff, a video of a talk that Allen Downey gave on his book The Little Book of Semaphores and the demonstrations he gave made a lot of sense to me. Unfortunately, it appears that the video has been removed from YouTube. But look, I can still prove that it once existed! http://web.archive.org/web/20150511150444/https://www.youtube.com/watch?v=RaEUw107dpg
    1 point
  9. Amazing stuff, @tarretarretarre! This is a very ambitious project. Like @JohnOne, I never fully committed to making this happen myself. The code generator I posted did enough of what I wanted it to do and I moved on. It was actually selfishly inspired by my own laziness and apathy for the process. I didn't want to have to deal with the tedium of shoehorning DLLs into AutoIt scripts again and realized that I duplicated a lot of code every time I did it, so the code generator helped me to be lazier, and I haven't looked back. But your project is bringing me a lot closer to this utopian dream of mine than I ever was before. I'm glad my humble little project inspired something bigger. I had never planned to continue it but this is what I was hoping for! I have to say, though, that I'm a little disappointed that this has been here almost a week and the only discussion I'm seeing so far is bug reports.
    1 point
  10. AZJIO

    A gift of flowers

    a gift for tomorrow
    1 point
  11. RTFC

    How computers work

    In machine code, an INC(rement) opcode (or an ADD, for that matter) acting on a register (assuming your int is already loaded into that register) or memory location is itself atomic, taking one clock cycle (or tick) on an ALU (which is part of your CPU), and depending on your architecture, multiple INCs (3 is common) can even be handled within a single clock tick, although other bottlenecks in the pipeline may limit this again). See these tables to get an idea of the basic latencies of various instructions. But in your high-level world of compiled or interpreted instructions, you're doing much more than that: you allocate some memory for your integer variable first, then you fill it with an initial value, you add unity to that memory location using an ADD or INC instruction, either directly or indirectly (if you had stored that value of one somewhere else before, and have to load it first), and then you may wish to evaluate the result and decide to do something depending on the outcome, as in trancexx's example. All of those steps cost clock ticks; some are handled by ALUs, others by AGUs, floating point maths is handled by your FPU, etc. Many instructions require multiple CPU units to interact, and some single opcodes require over one hundred clock ticks to complete. Special scheduling units attempt to keep the pipelines optimally filled, but cache misses, faults, exceptions, and even suboptimal memory alignment of addresses and buffer sizes all degrade performance. Now imagine this in an environment where dozens or hundreds of threads are vying for processing time and memory, and the CPU is always simultaneously playing catch-up and divide-and-conquer. So you're missing the point if you're thinking purely in terms of your single INC in a single thread. Your CPU itselfs consists of numerous parts working on numerous jobs, and constantly switching to keep as many tasks going in parallel as possible, as efficiently as possible. This means that any thread can be temporarily suspended at any point (and not necessarily always when a full instruction is completed, if that instruction takes more than one clock tick), so if any information is shared between threads, or acted upon and evaluated by multiple threads, race conditions may occur, unless the programmer explicitly adds safeguards to prevent this.
    1 point
  12. Added to the list: https://www.autoitscript.com/wiki/User_Defined_Functions
    1 point
  13. yucatan, I would use an Accelerator key - these are like HotKeys but only work within your app rather than on all running processes. You could code it like this - look for the <<<<<<<<<<<<<<< lines: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> #Include <GuiEdit.au3> Global $fDblClk = 0, $fEdited = False Global $hListView = 0, $hEdit, $hDC, $hBrush, $aHit Global $iListView_ID, $sItemText Global $aLV_Handles[7] Global $hGUI = GUICreate("Test", 600, 500) For $i = 1 To 3 For $j = 0 To 1 $hListView = _GUICtrlListView_Create($hGUI, "Col 1", 2 + (200 * ($i - 1)), 2 + (200 * $j), 196, 196, BitOR($LVS_REPORT, $LVS_SINGLESEL, $WS_BORDER), $LVS_EX_FULLROWSELECT) _GUICtrlListView_SetExtendedListViewStyle($hListView, $LVS_EX_FULLROWSELECT) $aLV_Handles[$i + ($j * 3)] = $hListView _GUICtrlListView_AddColumn($hListView, "Col 2") _GUICtrlListView_AddColumn($hListView, "Col 3") ControlDisable($hGUI, "", HWnd(_GUICtrlListView_GetHeader($hListView))) _GUICtrlListView_SetColumnWidth($hListView, 0, 60) _GUICtrlListView_SetColumnWidth($hListView, 1, 60) _GUICtrlListView_SetColumnWidth($hListView, 2, $LVSCW_AUTOSIZE_USEHEADER) For $k = 1 To 4 _GUICtrlListView_AddItem($hListView, "Item " & $i + ($j * 3) & $k) _GUICtrlListView_AddSubItem($hListView, $k - 1, "Sub " & $i + ($j * 3) & Chr(64 + $k), 1) _GUICtrlListView_AddSubItem($hListView, $k - 1, "Sub " & $i + ($j * 3) & Chr(77 + $k), 2) Next Next Next $hEdit = GUICtrlCreateEdit("", 10, 410, 580, 80) ; Create dummy control for the accelerator to action $hAccel_Enter = GUICtrlCreateDummy() ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< GUISetState() GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") ; Set accelerator for Enter to use if editing Dim $aAccelKeys[1][2]=[["{ENTER}", $hAccel_Enter]] ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $hAccel_Enter ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< _End_SubItemEdit() ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< EndSwitch ; If an item was double clicked If $fDblClk Then $hListView = $aLV_Handles[$fDblClk] $iListView_ID = $fDblClk $aHit = _GUICtrlListView_SubItemHitTest($hListView) If $aHit[0] <> -1 Then _Start_ItemEdit() EndIf $fDblClk = 0 EndIf If $fEdited Then $fEdited = False ConsoleWrite("ListView " & $iListView_ID & " : Row " & $aHit[0] + 1 & @CRLF & "has been altered" & @CRLF) EndIf WEnd Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Local $hWndFrom, $iCode, $tNMHDR $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iCode = DllStructGetData($tNMHDR, "Code") For $i = 1 To 6 If $aLV_Handles[$i] = $hWndFrom Then Switch $iCode Case $NM_DBLCLK $fDblClk = $i EndSwitch ExitLoop EndIf Next Return $GUI_RUNDEFMSG EndFunc Func WM_COMMAND($hWnd, $Msg, $wParam, $lParam) #forceref $hWnd, $Msg, $wParam Local $iCode = BitShift($wParam, 16) Switch $lParam Case $hEdit Switch $iCode Case $EN_KILLFOCUS _End_SubItemEdit() EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND Func _Start_ItemEdit() $sItemText = _GUICtrlListView_GetItemText($hListView, $aHit[0], $aHit[1]) Local $iLen = _GUICtrlListView_GetColumnWidth($hListView, $aHit[1]) Local $aRect = _GUICtrlListView_GetSubItemRect($hListView, $aHit[0], $aHit[1]) Local $aPos = WinGetPos($hListView) Local $tPoint = DllStructCreate("int X;int Y") DllStructSetData($tPoint, "X", $aPos[0]) DllStructSetData($tPoint, "Y", $aPos[1]) _WinAPI_ScreenToClient($hGUI, $tPoint) Local $iEdit_X = DllStructGetData($tPoint, "X") + $aRect[0] Local $iEdit_Y = DllStructGetData($tPoint, "Y") + $aRect[1] $hEdit = _GUICtrlEdit_Create($hGUI, $sItemText, $iEdit_X + 6, $iEdit_Y, $iLen - 7, 17, BitOR($WS_CHILD, $WS_VISIBLE, $ES_AUTOHSCROLL, $ES_LEFT)) _GUICtrlEdit_SetSel($hEdit, 0, -1) _WinAPI_SetFocus($hEdit) $hDC = _WinAPI_GetWindowDC($hEdit) $hBrush = _WinAPI_CreateSolidBrush(0) Local $stRect = DllStructCreate("int;int;int;int") DllStructSetData($stRect, 1, $iLen + 10) DllStructSetData($stRect, 2, 0) DllStructSetData($stRect, 3, 0) DllStructSetData($stRect, 4, 17) DllCall("user32.dll", "int", "FrameRect", "hwnd", $hDC, "ptr", DllStructGetPtr($stRect), "hwnd", $hBrush) ; Set acclerator key GUISetAccelerators($aAccelKeys) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< EndFunc Func _End_SubItemEdit() Local $sText = _GUICtrlEdit_GetText($hEdit) If $sText <> $sItemText Then _GUICtrlListView_SetItemText($hListView, $aHit[0], $sText, $aHit[1]) $fEdited = True EndIf _WinAPI_DeleteObject($hBrush) _WinAPI_ReleaseDC($hEdit, $hDC) _WinAPI_DestroyWindow($hEdit) $hListView = 0 ; Clear accelerator key GUISetAccelerators(0) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< EndFuncThe edit control is just there so that you can see that the ENTER key works normally when you are not editing the ListView. M23
    1 point
×
×
  • Create New...