Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 05/05/2023 in all areas

  1. Maybe NTP ?
    2 points
  2. @kurtykurtyboy - Keep going with this project and never give up. I am seriously hoping this project continues and evolves into the Main GUI Builder for AutoIt.. Just like how @water made all those MS Office UDF which has been an absolutely, excellent addition to this language.
    2 points
  3. A number of years ago I used to do address verification by automating the USPS website too, but they really frown on that. And they imposed a limit to how many addresses you can verify through the website within a certain time. Then you have to wait a little while before you can do some more. It got aggravating enough (which is the reason they do that) that I went ahead and registered for a free account with them and started using the API. That's been working great for years now.
    2 points
  4. Lepes

    Active_SaveFileDlg

    tested and works here too. If I try to open or save the file while the script is running, it is detected. Keep in mind that Open / Save Dialogs are standard windows that are inside a Windows DLL. Notepad, Scite and many other program just call that window DLL to load and show these common dialogs. That's why all "Open File windows" on any program is the same window, because is part of Windows OS, it is not made neither by Notepad nor SciTe. The Microsoft Windows common dialogs consist of the Open File, Save File, Open Folder, Find and Replace, Print, Page Setup, Font, and Color dialog boxes Let me explain a Bug that maybe you didn't think about it. Using your actual program with this code: While WinExists("[CLASS:SciTEWindow]") If WinExists("[TITLE:Save File; CLASS:#32770]") Then ConsoleWrite("scite window exists and Save Dialog is open") ; Lepes $hWnd = WinGetHandle("[TITLE:Save File; CLASS:#32770]") _Main() EndIf Sleep(500) WEnd - Open SciTe, load your script and run it - Open Notepad -> File -> Save As... Your script will print on console "scite window exists and Save Dialog is open", because WinExists detected SciTE window on the background, the second "if" will be true because the title is "Save File" and the class is 32770 because it is a common Windows OS Dialog. So, You are not detecting "Save File" inside SciTE. You are detecting "Save File Dialog" globally to Windows OS. The same happens using my code. If you only want your custom button inside SciTe, you need a different approach, for example getting the parent window of the "Save Dialog" this will tell you the application that called this Dialog. I modified your code and tested, I marked lines I have modified with "//Lepes" ; https://www.autoitscript.com/forum/topic/210165-active_savefiledlg/#comment-1517621 ; https://www.autoitscript.com/forum/topic/210165-active_savefiledlg/ ;---------------------------------------------------------------------------------------- ; Title...........: Active_SaveFileDlg.au3 ; Description.....: Add All open folder & some extra as contex menu in SaveFileDlg & OpenFileDlg of SciTE ; AutoIt Version..: 3.3.16.1 Author: ioa747 ;---------------------------------------------------------------------------------------- #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 ;~ #NoTrayIcon #include <Misc.au3> #include <WindowsConstants.au3> #include <ButtonConstants.au3> #include <Array.au3> #include <WinAPISysWin.au3> ; _WinApi_GetParent //Lepes Global $hGUI, $hDlgWnd, $hScite If _Singleton(@ScriptName, 1) = 0 Then Exit ; to avoid running it multiple times! While WinExists("[CLASS:SciTEWindow]") $hScite = WinGetHandle("[CLASS:SciTEWindow]") ; save this handle //Lepes If WinExists("[TITLE:Save File; CLASS:#32770]") Then ; ------------ Save File $hDlgWnd = WinGetHandle("[TITLE:Save File; CLASS:#32770]") If _WinApi_GetParent($hDlgWnd) == $hScite Then ; SciTE called the Save Dialog //Lepes ConsoleWrite(" parent of Save Dialog is scite" & @CRLF) ; //Lepes _CallFoldersGUI("Save") Else ConsoleWrite("parent of Save File Dialog is not scite" & @CRLF) ; //Lepes EndIf ElseIf WinExists("[TITLE:Open File; CLASS:#32770]") Then ; -------- Open File $hDlgWnd = WinGetHandle("[TITLE:Open File; CLASS:#32770]") _CallFoldersGUI("Open") EndIf Sleep(500) WEnd Exit ;---------------------------------------------------------------------------------------- Func _CallFoldersGUI($sDlgTitle) _FoldersGUI($sDlgTitle) While WinActive($hDlgWnd) ; Loop While win exits. Sleep(500) WEnd GUIDelete($hGUI) EndFunc ;==>_CallFoldersGUI ;---------------------------------------------------------------------------------------- Func _FoldersGUI($sDlgTitle) $hGUI = GUICreate("MyGUI", 40, 40, -1, -1, $WS_POPUP, BitOR($WS_EX_TOOLWINDOW, $WS_EX_NOACTIVATE), $hDlgWnd) Local $idDummy = GUICtrlCreateDummy() Local $idButton = GUICtrlCreateButton("contex button", 0, 0, 40, 40, $BS_ICON) GUICtrlSetImage(-1, "shell32.dll", -68) Local $idContext = GUICtrlCreateContextMenu($idButton) Local $OpenFolders = _EnumAllOpenFolder() ; Add some extra folder (the numbers on the front don't matter) _ArrayInsert($OpenFolders, 1, "000|") ; separator _ArrayInsert($OpenFolders, 1, "001|D:\i\Pro\.AutoIT\_Test\005_Test") ; * <--------- Fav1 folder (get one of your own) _ArrayInsert($OpenFolders, 1, "002|D:\i\Pro\.AutoIT") ; * <------------------------ Fav2 folder (get one of your own) $OpenFolders[0][0] = UBound($OpenFolders) - 1 For $i = 1 To $OpenFolders[0][0] GUICtrlCreateMenuItem($OpenFolders[$i][1], $idContext) Next GUISetState(@SW_SHOW, $hGUI) Local $Wpos = WinGetPos($hDlgWnd) ;ConsoleWrite("$Wpos " & $Wpos[0] & "; " & $Wpos[1] & "; " & $Wpos[2] & "; " & $Wpos[3] & @CRLF) Local $idMsg While WinExists($hDlgWnd) $Wpos = WinGetPos($hDlgWnd) Local $aOfset[2] ;$aOfset[0]=X ;$aOfset[1]=Y If $sDlgTitle = "Save" Then $aOfset[0] = 270 $aOfset[1] = 55 ElseIf $sDlgTitle = "Open" Then $aOfset[0] = 270 $aOfset[1] = 50 EndIf WinMove($hGUI, "", $Wpos[0] + $Wpos[2] - $aOfset[0], $Wpos[1] + $Wpos[3] - $aOfset[1]) $idMsg = GUIGetMsg() Switch $idMsg Case 6 To $OpenFolders[0][0] + 6 ;ConsoleWrite($OpenFolders[$idMsg - 5][1] & @CRLF) WinActivate($hDlgWnd) If $sDlgTitle = "Save" Then ControlCommand($hDlgWnd, "", "ToolbarWindow324", "SendCommandID", 1280) ControlSetText($hDlgWnd, "", "Edit2", $OpenFolders[$idMsg - 5][1]) ControlSend($hDlgWnd, "", "Edit2", "{ENTER}") ElseIf $sDlgTitle = "Open" Then ControlCommand($hDlgWnd, "", "ToolbarWindow323", "SendCommandID", 1280) ControlSetText($hDlgWnd, "", "Edit2", $OpenFolders[$idMsg - 5][1]) ControlSend($hDlgWnd, "", "Edit2", "{ENTER}") EndIf Case $idButton GUICtrlSendToDummy($idDummy) Case $idDummy MouseClick("right") ;ExitLoop EndSwitch Sleep(10) WEnd GUIDelete($hGUI) Return EndFunc ;==>_FoldersGUI ;---------------------------------------------------------------------------------------- Func _EnumAllOpenFolder() ; enumerating all open folders Local $oShell = ObjCreate("Shell.Application") Local $sPath, $index = 0 Local $aArray[$oShell.Windows.Count + 1][2] = [["hWnd", "Path"]] For $oWin In $oShell.Windows $index += 1 $aArray[0][0] = $index $sPath = StringTrimLeft($oWin.LocationURL, 8) ; trim 'file:///' $sPath = StringReplace($sPath, "/", "\") $sPath = _UnicodeURLDecode($sPath) $aArray[$index][0] = HWnd($oWin.HWND) $aArray[$index][1] = $sPath Next Return $aArray EndFunc ;==>_EnumAllOpenFolder ;---------------------------------------------------------------------------------------- Func _UnicodeURLDecode($toDecode) Local $strChar = "", $iOne, $iTwo Local $aryHex = StringSplit($toDecode, "") For $i = 1 To $aryHex[0] If $aryHex[$i] = "%" Then $i = $i + 1 $iOne = $aryHex[$i] $i = $i + 1 $iTwo = $aryHex[$i] $strChar = $strChar & Chr(Dec($iOne & $iTwo)) Else $strChar = $strChar & $aryHex[$i] EndIf Next Local $Process = StringToBinary($strChar) Local $DecodedString = BinaryToString($Process, 4) Return $DecodedString EndFunc ;==>_UnicodeURLDecode ;---------------------------------------------------------------------------------------- Using Hooks it is the same, you need to check the parent: ; https://www.autoitscript.com/forum/topic/210165-active_savefiledlg/#comment-1517621 ; https://www.autoitscript.com/forum/topic/210165-active_savefiledlg/?do=findComment&comment=1517595 #include <WinAPISys.au3> Global $hEventProc = DllCallbackRegister('_EventProc', 'none', 'ptr;dword;hwnd;long;long;dword;dword') OnAutoItExitRegister('OnAutoItExit') ; Hook events detecting an Open/Save Dialog that is: open, closed, start moving/resizing so we close JFF and once moved/resized we launch again JFF. Global $hEventHook = _WinAPI_SetWinEventHook($EVENT_SYSTEM_DIALOGSTART, $EVENT_SYSTEM_DIALOGEND, DllCallbackGetPtr($hEventProc)) Global $hEventHook_sized = _WinAPI_SetWinEventHook($EVENT_SYSTEM_MOVESIZESTART, $EVENT_SYSTEM_MOVESIZEEND, DllCallbackGetPtr($hEventProc)) While WinExists("[CLASS:SciTEWindow]") Sleep(500) WEnd Exit ;---------------------------------------------------------------------------------------- Func LaunchJFF($hOSDialog) ConsoleWrite("--- LaunchJFF -> $hOSDialog=" & $hOSDialog & @CRLF) EndFunc ;==>LaunchJFF ;---------------------------------------------------------------------------------------- Func OnAutoItExit() _WinAPI_UnhookWinEvent($hEventHook) _WinAPI_UnhookWinEvent($hEventHook_sized) DllCallbackFree($hEventProc) EndFunc ;==>OnAutoItExit ;---------------------------------------------------------------------------------------- Func _EventProc($hEventHook, $iEvent, $hWnd, $iObjectID, $iChildID, $iThreadId, $iEventTime) #forceref $hEventHook, $iObjectID, $iChildID, $iThreadId, $iEventTime Local $hOSDialog ConsoleWrite("-> ($hEventHook=" & $hEventHook) ConsoleWrite(", $iEvent=" & $iEvent) ConsoleWrite(", $hWnd=" & $hWnd) ConsoleWrite(", $iObjectID=" & $iObjectID) ConsoleWrite(", $iChildID=" & $iChildID) ConsoleWrite(", $iThreadId=" & $iThreadId) ConsoleWrite(", $iEventTime=" & $iEventTime & ") -> ") Switch $iEvent Case $EVENT_SYSTEM_DIALOGSTART ConsoleWrite("$EVENT_SYSTEM_DIALOGSTART" & @CRLF) If WinActive("[Class:#32770]") Then ; Open standard Windows Dialog always exist, so check active! $hOSDialog = WinGetHandle("[ACTIVE]") ; Get the handle of this exact window ; Bug: InputBox AutoIt function is a False Positive If Not @error Then If ControlGetHandle($hOSDialog, "", "[CLASS:Edit]") Then local $hParentOSDialog = _WinApi_GetParent($hOsDialog) ; //Lepes If WinExists("[CLASS:SciTEWindow]") Then ; //Lepes $hScite = WinGetHandle("[CLASS:SciTEWindow]") ; //Lepes If $hScite == $hParentOSDialog Then ; //Lepes ConsoleWrite("Detected Dialog inside scite" & @CRLF) ; //Lepes LaunchJFF($hOSDialog) Else ConsoleWrite("Detected Dialog FROM ANOTHER PROGRAM, is not scite" & @CRLF) ; //Lepes EndIf EndIf EndIf EndIf EndIf Case $EVENT_SYSTEM_DIALOGEND ConsoleWrite("$EVENT_SYSTEM_DIALOGEND" & @CRLF) ConsoleWrite("WinClose return " & WinClose("Jumping From Folder To...") & @CRLF) Case $EVENT_SYSTEM_MOVESIZESTART ConsoleWrite("$EVENT_SYSTEM_MOVESIZESTART" & @CRLF) If $hWnd == $hOSDialog Then ConsoleWrite(" winclose return " & WinClose("Jumping From Folder To...") & @CRLF) EndIf Case $EVENT_SYSTEM_MOVESIZEEND ConsoleWrite("$EVENT_SYSTEM_MOVESIZEEND" & @CRLF) If $hWnd == $hOSDialog Then LaunchJFF($hOSDialog) EndIf EndSwitch EndFunc ;==>_EventProc Hope this help.
    1 point
  5. @pixelsearch Thanks for reporting and the tip for fixing it. Your proposed solution seems to work well. Fixed for the next release!
    1 point
  6. Danp2

    Autoit address validation

    USPS offers a free API that I've used in the past to perform address verification (registration / approval is required). This is the function that I previously wrote -- #include <WinHttp.au3> #include <String.au3> ; #CONSTANTS# =============================================================================== Global Const $resultValid = 1 Global Const $resultInvalid = 2 Global Const $resultMultiple = 3 Global Const $resultVacant = 4 ;============================================================================================ ; #FUNCTION# ;=============================================================================== ; Name...........: _ValidateAddressUSPSAPI ; Description ...: ; Syntax.........: _ValidateAddress($cAddr1, $cAddr2, $cCity, $cState, $cZip = '') ; Parameters ....: $cAddr1 - String representing the street portion of address ; $cAddr2 - String representing additional street portion of address ; $cCity - String representing city portion of address ; $cState - String representing state portion of address ; $cZip - String representing zipcode portion of address ; Return values .: Success - Returns result code representing validity of address ; Failure - Returns 0 and sets @error: ; |1 - _WinHttpConnect failure. ; |2 - _WinHttpSimpleSendRequest failure. ; |3 - USPS API error ; Author ........: DanP ; Modified.......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: ;============================================================================================ Func _ValidateAddressUSPSAPI($cAddr1, $cAddr2, $cCity, $cState, $cZip = '') Const $userID = "XXXXXXXXXXXX" ; Change this to your assigned user name from USPS Const $url0 = "production.shippingapis.com" Const $url1 = '/ShippingAPI.dll?API=ZipCodeLookup&XML=<ZipCodeLookupRequest USERID="' Const $url2 = '"><Address ID="0"><Address1></Address1><Address2>' Const $url3 = "</Address2><City>" Const $url4 = "</City><State>" Const $url5 = "</State></Address></ZipCodeLookupRequest>" Const $mrkZip4_1 = '<Zip4>' Const $mrkZip4_2 = '</Zip4>' Const $mrkError_1 = '<error>' Const $mrkError_2 = '</error>' Const $mrkNumber_1 = '<number>' Const $mrkNumber_2 = '</number>' Const $mrkReturn_1 = '<ReturnText>' Const $mrkReturn_2 = '</ReturnText>' Const $codeAuthFailure = '80040b1a' Local $nResult, $aZip4, $aError ; Initialize and get session handle Local $hOpen = _WinHttpOpen() ; Get connection handle Local $hConnect = _WinHttpConnect($hOpen, $url0) If @error Then Return SetError(1, 0, 0) EndIf Local $fullUrl = $url1 & __WinHttpURLEncode($userID) & $url2 & __WinHttpURLEncode($cAddr1) & __WinHttpURLEncode($cAddr2) & $url3 & __WinHttpURLEncode($cCity) & $url4 & __WinHttpURLEncode($cState) & $url5 ConsoleWrite($fullUrl & @CRLF) ; Make a request Global $hRequest = _WinHttpSimpleSendRequest($hConnect, Default, $fullUrl) If @error Then _WinHttpCloseHandle($hRequest) Return SetError(2, 0, 0) EndIf If $hRequest Then Local $cReply $cReply = _WinHttpSimpleReadData($hRequest) ConsoleWrite($cReply & @CRLF) If StringInStr($cReply, $mrkError_1) Then $aError = _StringBetween($cReply, $mrkNumber_1, $mrkNumber_2) If @error = 0 And $aError[0] = $codeAuthFailure Then ; Authorization failure Return SetError(3, 0, 0) Else $nResult = $resultInvalid EndIf Else $aZip4 = _StringBetween($cReply, $mrkZip4_1, $mrkZip4_2, -1) If @error Or IsArray($aZip4) = 0 Or StringLen($aZip4[0]) = 0 Then ConsoleWrite('@error = ' & @error & @CRLF) ConsoleWrite('zip4 error' & @crlf) ConsoleWrite('IsArray($aZip4) = ' & IsArray($aZip4) & @CRLF) $nResult = $resultInvalid Else If StringInStr($cReply, $mrkReturn_1) Then $nResult = $resultMultiple Else $nResult = $resultValid EndIf EndIf EndIf EndIf ; ConsoleWrite('Result = ' & $nResult & @CRLF) ; Close handles _WinHttpCloseHandle($hRequest) _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) Return $nResult EndFunc
    1 point
  7. There's a possible GUI improvement in GuiBuilderPlus_formGenerateCode.au3 In this GUI ($hFormGenerateCode) there's a RichEdit control ($editCodeGeneration) which doesn't resize when we resize the GUI (which has a $WS_SIZEBOX style) @melba23 indicated in this post a way to do it (I tried it just now on your script and it works fine) As this GUI has only a Close button (no Maximize or Restore Buttons) then Melba23's script should work fine. In case one day you want to apply it to a GUI having also Maximize and Restore Buttons, then there is a 2nd Melba23's script, on same web page, which shows how to do it (as simply as his 1st script) Great job kurtykurtyboy
    1 point
  8. A substantial update is now available, so check the first post. The list of changes is quite long, so I won't add them here. Just check the first post.
    1 point
  9. Here is me playing with an upcoming feature - drawing graphic controls. This turned out to be more formidable than I had anticipated, but I think it ended up working out nicely.
    1 point
×
×
  • Create New...