Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 03/07/2017 in all areas

  1. That's an internal Autoit ID. To find out simply write variable $Button1 to the Console. I see. Use the AutoIt code tag in the editor (button "<>") to insert code.
    2 points
  2. Next version using a function of the Excel UDF to insert the blank line: ;~ #includes #include <Excel.au3> ;reference that Excel UDF is included #include <GUIConstantsEx.au3> ;Grafical User Interface ;~ $variables Local $counter ;~ Read Only File Local $sReadFile = @ScriptDir & "\5_Zeiterfassung mit GUI input.xlsx" ;~ Save File Name Local $sSaveFile = @ScriptDir & "\SaveFile.xlsx" ;~ counting variable Global $aCounter[3] = [0, 0, 0] ;~GUI desginged in Kodpe #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 350, 50, 192, 124) $Button1 = GUICtrlCreateButton("A", 16, 16, 75, 25) ; <== ID 3 $Button2 = GUICtrlCreateButton("B", 112, 16, 75, 25) ; <== ID 4 $Button3 = GUICtrlCreateButton("C", 200, 16, 75, 25) ; <== ID 5 GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### ;~ Open Excel --- $oExcel=the variable standing for the open Excel-window $oExcel = _Excel_Open() ;~ Open ReadFile.xlsx as Read Only --- $oWorkBook=the variable standing for the open Excel workbook ; $oWorkBook = _Excel_BookOpen($oExcel, $sReadFile, False, True) ; <== For testing purpose $oWorkBook = _Excel_BookNew($oExcel) ; <== For testing purpose While 1 ; <== Added $nMsg = GUIGetMsg() ;opens the GUI Switch $nMsg ;conditional statement Case $Button1, $Button2, $Button3 ; <== Changed If $nMsg = $Button1 Then $machine = "A" If $nMsg = $Button2 Then $machine = "B" If $nMsg = $Button3 Then $machine = "C" Local $time[8] = [$aCounter[$nMsg - 3], $machine, @YEAR, @MON, @MDAY, @HOUR, @MIN, @SEC] ; time information $transposetime = _ArrayTranspose($time) ;transposed time information _Excel_RangeInsert($oWorkbook.Activesheet, "11:11", $xlShiftDown) ; insert empty row and shift data to the end <== added _Excel_RangeWrite($oWorkBook, 1, $time, "D11") ; write line ;~ increase counter $aCounter[$nMsg - 3] += 1 Case $GUI_EVENT_CLOSE ;pressing the close button in the corner Exit ;GUI is being closed EndSwitch WEnd ; <== Added
    1 point
  3. Because the loop was missing and the Case statement was wrong. I marked the changed lines with "<==" ;~ #includes #include <Excel.au3> ;reference that Excel UDF is included #include <GUIConstantsEx.au3> ;Grafical User Interface #include <WindowsConstants.au3> ;including window cosntants of the au3 script #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> ;~ $variables Local $counter ;~ Read Only File Local $sReadFile = @ScriptDir & "\5_Zeiterfassung mit GUI input.xlsx" ;~ Save File Name Local $sSaveFile = @ScriptDir & "\SaveFile.xlsx" ;~ counting variable $counter1 = 1 $counter2 = 1 $counter3 = 1 ;~GUI desginged in Kodpe #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 350, 50, 192, 124) $Button1 = GUICtrlCreateButton("A", 16, 16, 75, 25) $Button2 = GUICtrlCreateButton("B", 112, 16, 75, 25) $Button3 = GUICtrlCreateButton("C", 200, 16, 75, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### ;~ Open Excel --- $oExcel=the variable standing for the open Excel-window $oExcel = _Excel_Open() ;~ Open ReadFile.xlsx as Read Only --- $oWorkBook=the variable standing for the open Excel workbook $oWorkBook = _Excel_BookOpen($oExcel, $sReadFile, False, True) While 1 ; <== Added $nMsg = GUIGetMsg() ;opens the GUI Switch $nMsg ;conditional statement Case $Button1, $Button2, $Button3 ; <== Changed If $Button1 = "1" Then $machine = "A" If $Button2 = "1" Then $machine = "B" If $Button3 = "1" Then $machine = "C" Dim $time[8] = [$counter, $machine, @YEAR, @MON, @MDAY, @HOUR, @MIN, @SEC] ; time information $transposetime = _ArrayTranspose($time) ;transposed time inforamtion _Excel_RangeWrite($oWorkBook, 1, $time, "D10") ;write in B2 $oExcel.Range("D2:L2").Select $oExcel.Selection.Copy $oExcel.Range("D10:L10").Select $oExcel.Selection.Insert(-4121) ;~ increase counter $counter1 = $counter1 + 1 Case $GUI_EVENT_CLOSE ;pressing the close button in the corner Exit ;GUI is being closed EndSwitch WEnd ; <== Added
    1 point
  4. @rootx $g_hListView = _GUICtrlListView_Create($hGUI, "test header", 2, 2, 394, 268, BitOR($LVS_DEFAULT, $LVS_NOCOLUMNHEADER))
    1 point
  5. Hi @DLS You can use _WinAPI_SetWindowsHookEx with $WH_KEYBOARD_LL (see the example in the function reference). The scan code is in the $tagKBDLLHOOKSTRUCT and if you return 1 in the hook procedure, you can prevent the key from doing anything else.
    1 point
  6. As you can see in the code posted by Subz he uses a prefix for variables. So you always know what to expect when using a variable (a string, an object, an integer ...). More Good Coding Practices are described here.
    1 point
  7. As water mentioned: #include <Excel.au3> ;~ Read Only File Local $sReadFile = @ScriptDir & "\ReadFile.xlsx" ;~ Save File Name Local $sSaveFile = @ScriptDir & "\SaveFile.xlsx" ;~ Create Array Local $aPeople[3][2] = [["John",34],["Steve",23],["Bob",41]] ;~ Open Excel $oExcel = _Excel_Open() ;~ Open ReadFile.xlsx as Read Only $oWorkBook = _Excel_BookOpen($oExcel, $sReadFile, True) ;~ Write Array to Excel starting at A1 _Excel_RangeWrite($oWorkBook, $oWorkBook.ActiveSheet, $aPeople) ;~ Save WorkBook _Excel_BookSaveAs($oWorkBook, $sSaveFile, Default, True) ;~ Rewrite $aPeople to next empty row in Cell A _Excel_RangeWrite($oWorkBook, $oWorkBook.ActiveSheet, $aPeople, "A" & $oWorkBook.ActiveSheet.UsedRange.Rows.Count + 1) _Excel_BookSave($oWorkBook)
    1 point
  8. Maybe replace SetParent to create child for child? #include <GuiConstants.au3> $Main_GUI = GUICreate("Main", 500, 500) GUISetBkColor(0x1B5583, $Main_GUI) GUISetState(@SW_SHOW, $Main_GUI) $Child1_GUI = GUICreate("ExitGUI", 480, 480, 10, 10, $WS_CHILD, -1, $Main_GUI) GUISetState(@SW_SHOW, $Child1_GUI) $Child2_GUI = GUICreate("Child", 200, 100, 10, 50, BitOR($WS_CAPTION, $WS_CHILD), -1, $Child1_GUI) $Btn_Test = GUICtrlCreateButton("Test", 10, 10, 90, 20) GUISetState(@SW_SHOW, $Child2_GUI) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $Btn_Test MsgBox(0, "Test", "Hit Button on Child Window") EndSwitch WEnd
    1 point
  9. fopetesl, I knew this problem rang a bell - I ran into it some years ago when working with child windows. You need to have at least one control in the parent window or you run into focus problems - just as you do here when you can no longer focus on the main GUI to action the [X]. I asked the Devs about it at the time (in a private section of the forum) at the time and no-one was able to explain why this happened - so I cannot offer anything further. You can see that the "solution" works in this code: #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> $Main_GUI = GUICreate("Main", @DesktopWidth * 1, @DesktopHeight * 1, 0, 0,-1, $WS_EX_COMPOSITED) GUISetState(@SW_SHOW, $Main_GUI) $Child1_GUI = GUICreate("ExitGUI", 480, 480, 10, 10, $WS_CHILD, -1, $Main_GUI) ;$Btn_Exit = GUICtrlCreateButton("E&xit", -1, -1, 90, 20) GUICtrlCreateLabel("", 1, 1, 0, 0) ; A control added to the parent window <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< GUISetState(@SW_SHOW, $Child1_GUI) $Child2_GUI = GUICreate("Child", 200, 100, 10, 50, $WS_CAPTION) $Btn_Test = GUICtrlCreateButton("Test", 10, 10, 90, 20) GUISetState(@SW_SHOW, $Child2_GUI) ; this puts the 'child' GUI within 'master' GUI... DllCall("user32.dll", "int", "SetParent", "hwnd", WinGetHandle($Child2_GUI), "hwnd", WinGetHandle($Child1_GUI)) ;sleep(5000) ;Exit While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE; And now this works <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Exit Case $Btn_Test MsgBox(0, "Test", "Hit Button on Child Window") EndSwitch WEnd M23
    1 point
  10. Maybe this sheds some light onto the subject: https://support.mozilla.org/t5/Basics/What-is-the-winmail-dat-attachment/ta-p/15886 Edit: Or even better: https://www.lifewire.com/prevent-sending-winmail-dat-attachments-1173717
    1 point
  11. You don't require a loop, just use the iIndex as the Array row number. As I don't have the same Excel UDF, created the object manually, but this returns fairly quickly for me. Func ViewClick() $sFilePath = @ScriptDir & "\MASTERLIST.xls" $oExcel = ObjCreate("Excel.Application") $oWorkBook = $oExcel.Workbooks.Open($sFilePath, Default, Default, Default, Default, Default) $aArray = $oExcel.Transpose($oWorkbook.ActiveSheet.UsedRange.value) $sSearch = GUICtrlRead($Input11) If @error Then Exit If GUICtrlRead($Input11) = "" Then MsgBox(64,"Warning!","Input Code. Thanks!") Return EndIf $iIndex = _ArraySearch($aArray,$sSearch, 1, 0, 0, 0, 1, 0) If @error Then MsgBox(0, "", $sSearch & " not Found!") Return Else GUICtrlSetData($Input1, $aArray[$iIndex][1]) GUICtrlSetData($Input2, $aArray[$iIndex][2]) GUICtrlSetData($Input3, $aArray[$iIndex][3]) GUICtrlSetData($Input4, $aArray[$iIndex][4]) GUICtrlSetData($Input5, $aArray[$iIndex][5]) GUICtrlSetData($Input6, $aArray[$iIndex][6]) GUICtrlSetData($Input7, $aArray[$iIndex][7]) GUICtrlSetData($Input8, $aArray[$iIndex][8]) GUICtrlSetData($Input9, $aArray[$iIndex][9]) GUICtrlSetData($Input10, $aArray[$iIndex][10]) EndIf EndFunc
    1 point
  12. Welcome to the club
    1 point
  13. Yargo

    Get Date Syntax

    Local $currentDate=@MDAY & @MON & @YEAR You may play with it as you need. E.G.: Local $currentDate=@YEAR & "_" & @MON & "_" & @MDAY HTH, Yaron Golan
    1 point
×
×
  • Create New...