Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 10/28/2020 in all areas

  1. If you're using + - from the numeric keypad. It will react the way you're talking about. You could just use the + and - from the keys above [TY] and [^$] It will react as you want. It can be a bit messy on laptop. Not sure if it's AZERTY reaction, because I'm french too and it always did that. Not an issue for me. It is doing this with SciTE normal and SciTE full with all extension.
    2 points
  2. I reworked a bit Func WM_NCHITTEST() so it should be more flexible. For example, maybe someone doesn't want the vertical scrolling to happen when you drag the mouse anywhere in the child windows. Also I posted all 26 WM_NCHITTEST() return values, sorted by code (then by value +++) in this link (test forum) . It's interesting to see in the console what's the return value when you move your mouse here & there, by uncommenting this line : ; ConsoleWrite($iRet) This amended version of Func WM_NCHITTEST() should be useful to rework in case the child windows are resizable, got a caption etc... The point is to first check WM_NCHITTEST() return value, only then decide what to do. WM_NCHITTEST is a really surprising message, very useful #include <GUIConstants.au3> #include <GUIScrollbars.au3> #include <WindowsConstants.au3> Opt("GUIOnEventMode", 1) ; Change to OnEvent mode Global $width=500, $height=500, $titel="Tabtest in Childwindow", $hDll = DllOpen("user32.dll") ; create the parentwindow $mainwindow = GUICreate($titel, $width, $height, -1, -1) GUISetBkColor(0x00ffff) ; show the parentwindow GUISetState(@SW_SHOW,$mainwindow) ; create the 1st childwindow with the scrollbars active $childwindo1 = GUICreate("child", 220, $height, 10, 10, $WS_CHILD, $WS_EX_CONTROLPARENT, $mainwindow) _GUIScrollBars_Init($childwindo1, 100, 100) GUISetBkColor(0xff0000, $childwindo1) GUISetState(@SW_SHOW, $childwindo1) $input_1 = GUICtrlCreateInput("Scroll Works",10,10) $input_2 = GUICtrlCreateInput("Tab too",10,40) $label_2a = GUICtrlCreateLabel("Low label 1", 10, $height + 100) ; create the 2nd childwindow with the scrollbars active $childwindo2 = GUICreate("child", 220, $height, 240, 10, $WS_CHILD, $WS_EX_CONTROLPARENT, $mainwindow) _GUIScrollBars_Init($childwindo2, 100, 100) GUISetBkColor(0xff0000, $childwindo2) GUISetState(@SW_SHOW, $childwindo2) $input_3 = GUICtrlCreateInput("Tab Works",10,10) $input_4 = GUICtrlCreateInput("Scroll too",10,40) $label_4a = GUICtrlCreateLabel("Low label 2", 10, $height + 100) GUIRegisterMsg($WM_VSCROLL, "WM_VSCROLL") GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST") ; register close GUISetOnEvent($GUI_EVENT_CLOSE, "close_it",$mainwindow) ;loop While 1 Sleep(100) ; Idle around WEnd ;=============================================== Func close_it() ; exit application GUIDelete($mainwindow) DllClose($hDll) exit EndFunc ;=============================================== Func WM_VSCROLL($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $wParam, $lParam Local $iScrollCode = BitAND($wParam, 0x0000FFFF) Local $iIndex = -1, $iCharY, $iPosY Local $iMin, $iMax, $iPage, $iPos, $iTrackPos For $x = 0 To UBound($__g_aSB_WindowInfo) - 1 If $__g_aSB_WindowInfo[$x][0] = $hWnd Then $iIndex = $x $iCharY = $__g_aSB_WindowInfo[$iIndex][3] ExitLoop EndIf Next If $iIndex = -1 Then Return 0 ; Get all the vertial scroll bar information Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_VERT) $iMin = DllStructGetData($tSCROLLINFO, "nMin") $iMax = DllStructGetData($tSCROLLINFO, "nMax") $iPage = DllStructGetData($tSCROLLINFO, "nPage") ; Save the position for comparison later on $iPosY = DllStructGetData($tSCROLLINFO, "nPos") $iPos = $iPosY $iTrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos") Switch $iScrollCode Case $SB_TOP ; user clicked the HOME keyboard key DllStructSetData($tSCROLLINFO, "nPos", $iMin) Case $SB_BOTTOM ; user clicked the END keyboard key DllStructSetData($tSCROLLINFO, "nPos", $iMax) Case $SB_LINEUP ; user clicked the top arrow DllStructSetData($tSCROLLINFO, "nPos", $iPos - 1) Case $SB_LINEDOWN ; user clicked the bottom arrow DllStructSetData($tSCROLLINFO, "nPos", $iPos + 1) Case $SB_PAGEUP ; user clicked the scroll bar shaft above the scroll box DllStructSetData($tSCROLLINFO, "nPos", $iPos - $iPage) Case $SB_PAGEDOWN ; user clicked the scroll bar shaft below the scroll box DllStructSetData($tSCROLLINFO, "nPos", $iPos + $iPage) Case $SB_THUMBTRACK ; user dragged the scroll box DllStructSetData($tSCROLLINFO, "nPos", $iTrackPos) EndSwitch ; // Set the position and then retrieve it. Due to adjustments ; // by Windows it may not be the same as the value set. DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS) _GUIScrollBars_SetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO) _GUIScrollBars_GetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO) ;// If the position has changed, scroll the window and update it $iPos = DllStructGetData($tSCROLLINFO, "nPos") If ($iPos <> $iPosY) Then _GUIScrollBars_ScrollWindow($hWnd, 0, $iCharY * ($iPosY - $iPos)) $iPosY = $iPos EndIf Return $GUI_RUNDEFMSG EndFunc ;==>WM_VSCROLL ;=============================================== Func WM_NCHITTEST($hWnd, $iMsg, $wParam, $lParam) ;~ If $hWnd = $childwindo1 Or $hWnd = $childwindo2 Then ;~ Return $HTVSCROLL ;~ EndIf If $hWnd = $childwindo1 Or $hWnd = $childwindo2 Then ; This works but opens & closes user32.dll plenty of times => commented. ; Local $iRet = _WinAPI_DefWindowProc($hWnd, $iMsg, $wParam, $lParam) ; Same as _WinAPI_DefWindowProc() in WinAPISysWin.au3 but uses $hDll Local $iRet = DllCall($hDll, "lresult", "DefWindowProc", "hwnd", $hWnd, _ "uint", $iMsg, "wparam", $wParam, "lparam", $lParam)[0] ; ConsoleWrite($iRet) Switch $iRet Case $HTVSCROLL Return $HTVSCROLL Case Else Return $HTCLIENT EndSwitch EndIf Return $GUI_RUNDEFMSG EndFunc ;==>WM_NCHITTEST
    2 points
  3. v0.3.1.0 has been released with the following updates -- Changed: Cleanup _WD_DownloadFile Revise error list in header Remove leftover $_WD_HTTPRESULT coding Return $_WD_ERROR_NotFound instead of $_WD_ERROR_InvalidValue Changed (_WD_WaitElement): Added optional parameter to return element instead of 0/1 Chore: Update function headers (Danp2 and seadoggie01) Fix (_WD_Screenshot): Edit return value for Base64 screenshots (seadoggie01) Fix (_WD_WaitElement): Clear variable holding element ID if visibility or enabled check fails
    1 point
  4. Here are my 2 cents worth: The script needs to be started by the Task Scheduler. It waits for n minutes for a mail with a specific subject. If this mail arrives the script ends. If n minutes have passed the script ends as well. Sending an error message to another user can easily be implemented. #AutoIt3Wrapper_Au3Check_Parameters= -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #AutoIt3Wrapper_Au3Check_Stop_OnWarning=Y #include <OutlookEX.au3> ; ***************************************************************************** ; Handle Outlook NewmailEX event when a new mail arrives. ; This script waits for 5 minutes to make sure an expected mail has arrived ; in this time frame. ; ***************************************************************************** HotKeySet("+!e", "_Exit") ;Shift-Alt-E to Exit the script MsgBox(64, "OutlookEX UDF Example Script", "Hotkey to exit the script: 'Shift-Alt-E'!") ; ------- Change the following lines to your liking Global $sScriptName = "<Name of your script goes here>" Global $sSubject = "<Subject of your expected mail>" Global $iWaittime = 5 ; Duration in minutes of the window we will wait for the expected mail ; ------- End Global $sStartTime = _NowCalc() ; Start (date/time) of the window we will wait for the expected mail Global $bFound = False ; Mail has not been found so far AdlibRegister(_CheckTime, 10000) ; Check expiration of $iWaittime every 10 seconds Global $oOutlook = _OL_Open() ; Connect to Outlook If @error <> 0 Then Exit MsgBox(16, $sScriptName, "Error creating a connection to Outlook. @error = " & @error & ", @extended = " & @extended) Global $test = ObjEvent($oOutlook, "oOApp_") Global $sCurrentUser = $oOutlook.GetNameSpace("MAPI").CurrentUser.Name While 1 Sleep(10) WEnd ; Outlook 2007 - NewMailEx event - http://msdn.microsoft.com/en-us/library/bb147646%28v=office.12%29.aspx Func oOApp_NewMailEx($sEntryIDs) Local $iItemCount, $oItem, $aEntryIDs = StringSplit($sEntryIDs, ",", $STR_NOCOUNT) $iItemCount = UBound($aEntryIDs) For $i = 0 To $iItemCount - 1 $oItem = $oOutlook.Session.GetItemFromID($aEntryIDs[$i], Default) If $oItem.Subject = $sSubject Then $bFound = True _Exit() ; Mail with correct subject arrived in the time window => Exit script EndIf Next EndFunc ;==>oOApp_NewMailEx Func _Exit() If $bFound = False Then ; .... Send error mail to recipient EndIf _OL_Close($oOutlook) Exit EndFunc ;==>_Exit Func _CheckTime() If _DateDiff("n", $sStartTime, _NowCalc()) >= $iWaittime Then _Exit() EndFunc ;==>_CheckTime
    1 point
  5. To make things easier for you if you want to try the lines I gave you : First you setup your test environment (you don't need this for the last code you provided) : You create a folder into your mailbox : to use my code example create one called: Test12345 After that : You fix your code. First follow what water say just above. And you try it with F5 into SciTE editor. If you got error please past us the result from this area : Each time you press F5 into SciTE editor it will run the code and then if you got error inside your code it will be wrote into this field. Then if you got no error running this script. You can try to email yourself with subject : "Today's International Red Alert Report" Also in good practice you have to change the position of this : Global $sCurrentUser You should replace the way you declare this variable global. Add at the line 15 : Global $sCurrentUser And remove at line 43 or 44 depending on if you already made the first modification the Global word. You should never declare a global variable into a function. Try to get goo indentation in your code so it does not break your mind when you read your code too : this : #AutoIt3Wrapper_Au3Check_Parameters= -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #AutoIt3Wrapper_Au3Check_Stop_OnWarning=Y #include <OutlookEX.au3> HotKeySet("+!e", "_Exit") ;Shift-Alt-E to Exit the script MsgBox(64, "OutlookEX UDF Example Script", "Hotkey to exit the script: 'Shift-Alt-E'!") Global $oOApp = ObjCreate("Outlook.Application") Global $test = ObjEvent($oOApp, "oOApp_") Global $oOutlook = _OL_Open() If @error <> 0 Then Exit MsgBox(16, _ "OutlookEX UDF", _ "Error creating a connection to Outlook. @error = " & @error & ", @extended = " & @extended) While 1 Sleep(10) WEnd Func oOApp_NewMailEx($sOL_EntryId) Local $oOL_Item = $oOApp.Session.GetItemFromID($sOL_EntryId, Default) If $oOL_Item.Subject = "Today's International Red Alert Report" then MsgBox(64, "OutlookEX UDF Example Script", "New mail has arrived!" & @CRLF & @CRLF & _ "From: " & $oOL_Item.SenderName & @CRLF & _ "Subject: " & $oOL_Item.Subject) Global $sCurrentUser = $oOutlook.GetNameSpace("MAPI").CurrentUser.Name _OL_Wrapper_SendMail($oOutlook, _ $sCurrentUser, _ "", _ "", _ "TestSubject", _ "Body<br><b>fett</b> normal.", _ @ScriptDir & "\_OL_Wrapper_SendMail.au3", _ $olFormatHTML, _ $olImportanceHigh) If @error <> 0 Then Exit MsgBox(16, _ "OutlookEX UDF: _OutlookSendMail Wrapper Script", _ "Error sending mail. @error = " & @error & ", @extended: " & @extended) MsgBox(64, _ "OutlookEX UDF: _OutlookSendMail Wrapper Script", _ "Mail successfully sent to user '" & $sCurrentUser & "'!") _OL_Close($oOutlook) EndIf EndFunc ;==>oOApp_NewMailEx Func _Exit() Exit EndFunc ;==>_Exit Is better than the precedent one. A last hint for that snippet if I would be you I would change the place of line _OL_Close($oOutlook) just before the Exit into the _Exit function. Or this code will run only one time. And it's not really the expected behavior of : Func oOApp_NewMailEx which should run a verification on each mail. You could notice I'm not correcting for you so you start learning.
    1 point
  6. The only one way to send mouse action in your desktop in remote access is to have desktop present. Which is not the case when you log off from a remote session. If you want to keep a script running with a remote session is to keep the session active. A workaround that is to remote the target computer from another remote computer. Let's say your target computer remain active : A So you're going to use another computer : B to remote access to A And if you start your script from B into A you can log off from B the script will remain active on A. Tested.
    1 point
  7. I have a pair of DOS batch scripts (one on each machine) which in turn launch a VB script, that are triggered twice daily, 11:00 and 23:00, by windows scheduler. The triggers are offset such that the emails arrive simultaneously in my gmail account, one says NB3 should be rebooting and the other says NB3 has just rebooted. I have been running these scripts for several years now and never get tired of deleting them as soon as they arrive in my inbox. On several occasions they have alerted me that NB3 has gone down. I did it this way as I had no need or desire to delve into the complexities of Outlook. This is not an AutoIt solution but I thought I would throw it in the ring. It demonstrates how to send emails from your gmail account. I keep my little tools in C:\WinBin My android devices all ping an audio alert whenever an email arrives and it gives me great satisfaction to hear them all go off at once around the house, much to the consternation of visitors. :: With no args this will send an email "%COMPUTERNAME% reboot ok %date% %time%" :: With -pre it will send a prealert email saying arg1 sb rebooting @echo off cd C:\WinBin set To=YOUREMAIL@gmail.com set Subj=%COMPUTERNAME% reboot ok %date% %time% if .%1==.-pre set Subj=%2 sb rebooting %date% %time% set Body=%Subj% set From=YOUREMAIL@gmail.com set Serv=smtp.gmail.com set Auth=YOUREMAIL@gmail.com set Pass=YOURPASSWORD set fileattach= call :createVBS email-bat.vbs call :send %From% %To% "%Subj%" "%Body%" %Serv% %Auth% %Pass% echo email has been sent (if parameters were correct) if exist email-bat.vbs del email-bat.vbs >nul goto :EOF exit :send echo (echo) cscript.exe /nologo "%vbsfile%" %1 %2 %3 %4 %5 %6 %7 %8 cscript.exe /nologo "%vbsfile%" %1 %2 %3 %4 %5 %6 %7 %8 goto :EOF :createVBS set "vbsfile=%~1" if exist "%vbsfile%" del "%vbsfile%" >nul set cdoSchema=http://schemas.microsoft.com/cdo/configuration echo > "%vbsfile%" Set objArgs = WScript.Arguments echo >>"%vbsfile%" Set objEmail = CreateObject("CDO.Message") echo >>"%vbsfile%" objEmail.From = objArgs(0) echo >>"%vbsfile%" objEmail.To = objArgs(1) echo >>"%vbsfile%" objEmail.Subject = objArgs(2) echo >>"%vbsfile%" objEmail.Textbody = objArgs(3) if defined fileattach echo >>"%vbsfile%" objEmail.AddAttachment "%fileattach%" echo >>"%vbsfile%" with objEmail.Configuration.Fields echo >>"%vbsfile%" .Item ("%cdoSchema%/sendusing") = 2 ' not local, smtp echo >>"%vbsfile%" .Item ("%cdoSchema%/smtpserver") = objArgs(4) :: 465 for Gmail. Other values for other servers. echo >>"%vbsfile%" .Item ("%cdoSchema%/smtpserverport") = 465 echo >>"%vbsfile%" .Item ("%cdoSchema%/smtpauthenticate") = 1 ' cdobasic echo >>"%vbsfile%" .Item ("%cdoSchema%/sendusername") = objArgs(5) echo >>"%vbsfile%" .Item ("%cdoSchema%/sendpassword") = objArgs(6) :: True for Gmail, False for "other" ::echo >>"%vbsfile%" .Item ("%cdoSchema%/smtpusessl") = False echo >>"%vbsfile%" .Item ("%cdoSchema%/smtpusessl") = True echo >>"%vbsfile%" .Item ("%cdoSchema%/smtpconnectiontimeout") = 25 echo >>"%vbsfile%" .Update echo >>"%vbsfile%" end with echo >>"%vbsfile%" objEmail.Send goto :EOF exit
    1 point
  8. 1 point
  9. The hint from @caramen is correct. Now I understand the problem. The minus sign from the NUM block is used to comment a line in or out. I haven't even thought about this issue, because I've been using it for ages .
    1 point
  10. I don't think there is any issue doing that, but I would recommend making the variable name a little more meaningful. For your purposes, you know what they mean, so do as you wish; but if it were me, I might do something like this. #include <Array.au3> Local Enum $eColA, $eColB, $eColC, $eColD, $eColE, $eColF, $eColG, $eColH, $eColSize Local Enum $eRow8, $eRow7, $eRow6, $eRow5, $eRow4, $eRow3, $eRow2, $eRow1, $eRowSize Local $aBoard[$eColSize][$eRowSize] $aBoard[$eRow1][$eColA]="rook" _ArrayDisplay($aBoard) You'll notice a few small changes; Added a prefix to each variable (following best coding practices formats) to make the variable names more meaningful to coders. Added 9th variable at the end of the Enum statements to simplify the array defining. Changed Row and Col dimensions of the array, which is is what @pseakins was trying to illustrate (totally optional since array is a square as long as you are consistent with which dimension is which--but if you ever need or want to use _ArrayDisplay to view the contents, swapping them as I did makes ArrayDisplay represent the "real" board, better.
    1 point
  11. _WD_ElementOptionSelect ($ gsSession, $ _WD_LOCATOR_ByXPath, "// select [@ name = 'PartnerGroup'] / option [@ value = '1']") Thank @CYCho and @TheXman This works fine for my case. Thank you everyone for the support.
    1 point
  12. Row 0, Column 7 Did you try running the code for yourself?
    1 point
  13. Nine

    convert tabs to spaces

    497 ms : #include <String.au3> #include <File.au3> Local $hTimer = TimerInit() Local $aFileLines _FileReadToArray("Temp\AutoIt3Wrapper.au3",$aFileLines) if @error Then Exit MsgBox ($MB_SYSTEMMODAL,"",@error) For $i = 1 to $aFileLines[0] $aFileLines[$i] = _TabsToSpaces($aFileLines[$i]) Next _FileWriteFromArray("Temp\AutoIt3Wrapper New.au3",$aFileLines,1) MsgBox ($MB_SYSTEMMODAL,"",TimerDiff($hTimer)) Func _TabsToSpaces($sString, $iTabLen = 8) Local $iMod, $iSpaceLeft Local $iTabPos = StringInStr($sString, @TAB) While $iTabPos $iMod = Mod($iTabPos, $iTabLen) $iSpaceLeft = $iMod ? $iTabLen - $iMod : 0 $sString = StringReplace($sString, Chr(9), _StringRepeat(" ", $iSpaceLeft + 1), 1) $iTabPos = StringInStr($sString, @TAB) WEnd Return $sString EndFunc ;==>_TabsToSpaces
    1 point
  14. Hi @Professor_Bernd, feel free to use it as you better like... You are welcome. I'm glad You find it useful The key here is in the mod () function in this case you can see the result of the mod function as if it tells you how many characters you have already used among those available before reaching the next tabstop; therefore, to know how many "spaces" remain available, just subtract this number from the "length of the tabulator" and the result gives us the number of spaces needed to replace the @tab in the string. while the StringFormat function is used in a somewhat unusual way here, ie to generate a string with a certain number of spaces at will. (for an example about this, have a look to this function I posted some time ago that uses this technique) with the union of these two we can easily achieve our goal as an example is better than many words, I put here a slightly revised and more explanatory version of the function $sInputString = "This" & Chr(9) & "is" & Chr(9) & "a" & Chr(9) & "nice" & Chr(9) & "longbutnolittle" & Chr(9) & "test" ConsoleWrite($sInputString & @CRLF) ; string with tabs ConsoleWrite(_TabsToSpaces($sInputString) & @CRLF) ; string with only spaces (no tabs) Func _TabsToSpaces($sString, $iTabLen = 8) StringReplace($sString, Chr(9), Chr(9)) ; this is to "count" the number of @tab in the string Local $iNrOfTabs = @extended, $iMod ; number of tabs in the string (if any) is in @extended ; this loop processes all the @tab ; (if there are no tabs the loop is NOT executed at all and script goes directly to the return) For $i = 1 To $iNrOfTabs $iTabPos = StringInStr($sString, @TAB) ; position of the @tab, chr(9) within the string $iMod = Mod($iTabPos, $iTabLen) ; $iMod is the "number of chars already used" (of the total tab len) $iSpaceLeft = $iTabLen - $iMod ; $iSpaceLeft are spaces left before the next tabstop $iSpaceLeft *= ($iMod <> 0) ; this is same as IF $iMod = 0 then $iSpaceLeft = 0 $sString = StringReplace($sString, Chr(9), StringFormat('%' & ($iSpaceLeft + 1) & 's', ""), 1) Next ; process next @tab Return $sString EndFunc ;==>_TabsToSpaces
    1 point
×
×
  • Create New...