Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 10/25/2018 in all areas

  1. Tell us how you would do it in Java then we can guide you with the functions you need in AutoIt (without giving the full exercise answer ;-))
    2 points
  2. I am reaching out to you all to test this version of Tidy to see whether that works on your scripts and report back your finding. Changes in this version: Leave inline comments on the original position when the line is tidied, where possible. Handle None Breaking Spaces (NBS) for Ascii and UTF8 files: NBS characters within the leading & trailing whitespace and inside the code will be replaced by a regular space to allow tidy to properly tidy the code. NBS characters in a literal string will not be replaced as they are presumably there for a reason. NBS characters inside an inline comment will be left alone too. Added support for directive: #Tidy_ILC_Pos=nn (See below for details) Replaced /Skip_Commentblock & /scb for /Tidy_Comment block & /tcb and made the default not to tidy comment blocks, as they are frequently used for simple documentation which would making tidying impossible. /tcb=0 =>only indent the whole commentblock (default) /tcb or /tcb=1 =>Tidy inside commentblock /tcb=-1 =>leave whole commentbock alone Added support for the following tidy.ini settings: #-->Define the TabSize size tabsize=4 #--> Tidy commentblock 1=Tidy, 0=Do not tidy default=0 Tidy_commentblock=0 #-->Define the default column for inline comments, 0=keep current position icl_pos=0 Changed the logic for the comment part of #directives. See last example for an explanation Fixed issue in "Variable proper" function, sometimes not updating the variable to the proper caps. Changed the program to CUI to show console output when ran from CMD prompt. Changed the returncode to -1 when no changes are made. A change in AutoIt3Wrapper will test for this and show as such. Updated support for inline comments: One of the items that has been on my wish-/todolist for a long time was to leave inline comments as they were, instead of removing all whitespace between statement and inline comment: For example that this untidied code: global $A=1 if $a=1 then ; test $a $a=2 ; Set $a endif ; end test The current production version will change that to: Global $A = 1 If $a = 1 Then ; test $a $a = 2 ; Set $a EndIf ; end test The new Beta version will change that to: (leaving the Comment start column the same as it was) Global $A = 1 If $A = 1 Then ; test $a $A = 2 ; Set $a EndIf ; end test Tidy.Ini optional change Tidy will determine the position of the inline comment by using the tabchar & tabsize parameter from Tidy.ini: [ProgramSettings] * * * Indent 0 = Tabs >0 = Number of Space tabchar=0 tabsize=4 #-->Define the default column for inline comments, 0=keep current position icl_pos=0 #--> Tidy commentblock 0=only indent the whole commentblock (default=0) # 1=Tidy inside commentblock # -1=leave whole commentbock alone Tidy_commentblock=0 When not provided in the INI it will be defaulted to Using Tabs with a size of 4. When running from within SciTE, a warning is shown in the SciTE console, when they deviate from the SciTE Settings for: use.tabs=1 indent.size=4 It could help while testing to use Winmerge to see what exactly was changed during the Tidy run by adding this to Tidy.ini: ShowDiffPgm = """C:\Program Files (x86)\WinMerge\winmergeu.exe" "%new%" "%old%""" Support for directive #Tidy_ILC_Pos=nn Tidy will keep inline comment on their original position, but this can be overridden by the directive: #Tidy_ILC_Pos=nn When nn is greater than 0, Tidy will use the defined number as the Inline comment start column going forward. When nn= 0 then use the old ILC column. When nn= -1 then strip the spaces between Code and ILC (Old Tidy behavior) EG Original Tidied script: Global Enum _ $ADO_ERR_SUCCESS, _ ; No Error $ADO_ERR_GENERAL, _ ; General - some ADO Error - Not classified type of error $ADO_ERR_ENUMCOUNTER ; just for testing Global Const $ADO_EXT_DEFAULT ; default Extended Value Global Const $ADO_EXT_PARAM1 ; Error Occurs in Parameter #1 Global Const $ADO_EXT_PARAM2 ; Error Occurs in Parameter #2 Global Const $ADO_EXT_PARAM3 ; Error Occurs in Parameter #3 Now with new directive added to line up the inline comments: #Tidy_ILC_Pos=40 Global Enum _ $ADO_ERR_SUCCESS, _ ; No Error $ADO_ERR_GENERAL, _ ; General - some ADO Error - Not classified type of error $ADO_ERR_ENUMCOUNTER ; just for testing Global Const $ADO_EXT_DEFAULT ; default Extended Value Global Const $ADO_EXT_PARAM1 ; Error Occurs in Parameter #1 Global Const $ADO_EXT_PARAM2 ; Error Occurs in Parameter #2 Global Const $ADO_EXT_PARAM3 ; Error Occurs in Parameter #3 Example Setting the new column to different values and back to original (0) Before Tidy run: #Tidy_ILC_Pos=30 Global Enum _ $ADO_ERR_SUCCESS, _ ; No Error $ADO_ERR_GENERAL, _ ; General - some ADO Error - Not classified type of error $ADO_ERR_ENUMCOUNTER ; just for testing #Tidy_ILC_Pos=50 Global Const $ADO_EXT_DEFAULT ; default Extended Value Global Const $ADO_EXT_PARAM1 ; Error Occurs in Parameter #1 Global Const $ADO_EXT_PARAM2 ; Error Occurs in Parameter #2 Global Const $ADO_EXT_PARAM3 ; Error Occurs in Parameter #3 Global Const $ADO_EXT_PARAM4 ; Error Occurs in Parameter #4 #Tidy_ILC_Pos=0 Global Const $ADO_EXT_PARAM5 ; Error Occurs in Parameter #5 Global Const $ADO_EXT_PARAM6 ; Error Occurs in Parameter #6 Global Const $ADO_EXT_INTERNALFUNCTION ; Error Related to internal Function - should not happend - UDF Developer make something wrong ??? Global Const $ADO_EXT_ENUMCOUNTER ; just for testing After Tidy run: #Tidy_ILC_Pos=30 Global Enum _ $ADO_ERR_SUCCESS, _ ; No Error $ADO_ERR_GENERAL, _ ; General - some ADO Error - Not classified type of error $ADO_ERR_ENUMCOUNTER ; just for testing #Tidy_ILC_Pos=50 Global Const $ADO_EXT_DEFAULT ; default Extended Value Global Const $ADO_EXT_PARAM1 ; Error Occurs in Parameter #1 Global Const $ADO_EXT_PARAM2 ; Error Occurs in Parameter #2 Global Const $ADO_EXT_PARAM3 ; Error Occurs in Parameter #3 Global Const $ADO_EXT_PARAM4 ; Error Occurs in Parameter #4 #Tidy_ILC_Pos=0 Global Const $ADO_EXT_PARAM5 ; Error Occurs in Parameter #5 Global Const $ADO_EXT_PARAM6 ; Error Occurs in Parameter #6 Global Const $ADO_EXT_INTERNALFUNCTION ; Error Related to internal Function - should not happend - UDF Developer make something wrong ??? Global Const $ADO_EXT_ENUMCOUNTER ; just for testing Example what happens with the different directives Before Tidy run: #Tidy_ILC_Pos=40 #UnknowDirective test ; comment ; Know directives/preprocessor Table -> au3.keywords.properties ;~ au3.keywords.special=#endregion #forcedef #forceref #ignorefunc #pragma #region #Region test ;test ; comment there not enough spaces, so simply copy Eveything after #Region to #EndRegion #EndRegion test ; will be replaced #Region test ; comment there are 4 spaces after #region so can line it up with EndRegion #EndRegion test ; will be replaced #forcedef aaaaaa ; comment - linedup at Pos 40 #pragma compile(UPX, False) ; comment - linedup at Pos 40 ;~ au3.keywords.preprocessor=#ce #comments-end #comments-start #cs #include #include-once \ ;~ #notrayicon #onautoitstartregister #requireadmin #NoTrayIcon ; comment - linedup at Pos 40 #RequireAdmin ; comment - linedup at Pos 40 #OnAutoItStartRegister "test" ; comment - linedup at Pos 40 ; -- Special treatment in au3lexer #cs test ; comment Start - copy all after #CS to #CE #ce test ; will be replaced #comments-Start ; comment Start copy all after #CS to #CE #comments-end ; will be replaced ; Knows Direcitves/Special table -> autoit3wrapper.keywords.properties #AutoIt3Wrapper_Add_Constants=n ; comment - linedup at Pos 40 #Au3Stripper_Ignore_Variables ; comment - linedup at Pos 40 #Tidy_Parameters=1 ; comment - linedup at Pos 40 After Tidy run: #Tidy_ILC_Pos=40 #UnknowDirective test ; comment ; Know directives/preprocessor Table -> au3.keywords.properties ;~ au3.keywords.special=#endregion #forcedef #forceref #ignorefunc #pragma #region #Region test ;test ; comment there not enough spaces, so simply copy Eveything after #Region to #EndRegion #EndRegion test ;test ; comment there not enough spaces, so simply copy Eveything after #Region to #EndRegion #Region test ; comment there are 4 spaces after #region so can line it up with EndRegion #EndRegion test ; comment there are 4 spaces after #region so can line it up with EndRegion #forcedef aaaaaa ; comment - linedup at Pos 40 #pragma compile(UPX, False) ; comment - linedup at Pos 40 ;~ au3.keywords.preprocessor=#ce #comments-end #comments-start #cs #include #include-once \ ;~ #notrayicon #onautoitstartregister #requireadmin #NoTrayIcon ; comment - linedup at Pos 40 #RequireAdmin ; comment - linedup at Pos 40 #OnAutoItStartRegister "test" ; comment - linedup at Pos 40 ; -- Special treatment in au3lexer #cs test ; comment Start - copy all after #CS to #CE #ce test ; comment Start - copy all after #CS to #CE #comments-start ; comment Start copy all after #CS to #CE #comments-end ; comment Start copy all after #CS to #CE ; Knows Direcitves/Special table -> autoit3wrapper.keywords.properties #AutoIt3Wrapper_Add_Constants=n ; comment - linedup at Pos 40 #Au3Stripper_Ignore_Variables ; comment - linedup at Pos 40 #Tidy_Parameters=1 ; comment - linedup at Pos 40 I like to thank @mLipok for the testing/ideas/questions during the development of this change. Jos
    1 point
  3. I made this application at the behest of another user because it sounded like a really cool idea. I've been using it for a little over 7 months and I really like it. After Compiling: If you want to use it as a pass through you'll need to name the script Vlc.exe and the original vlc.exe to Vlc_Orig.exe. On first run it will create a settings.ini with default settings and pop up the settings dialog Running VLC.exe again only runs the script passes on the new commandline and exits the script the previous script stays running... Once you close the VLC window after a few seconds a pop up will appear F1- Help, F4 - settings, ESC - Quit without saving DEFAULTS TO: [Config] CloseOnInactive=0 MaximizeOnActivate=0 IgnoreFilesLessThanMB=0 KeyDelayMS=100 KeyDownDelayMS=50 ExecName=VLC_Orig.exe ActiveWindowCoords=0 InactiveWindowCoords=0 ExecOnActive= ExecOnInactive= KeysOnActivate=f KeysOnInactive= FileTypes=mp4,avi,mkv,wmv WindowName=VLC media player WindowTextFallback=VLC (Direct3D output) ;------------------------------------------------ [Config] CloseOnInactive=0 ;1 - Closes the vlc_orig.exe when the video ends MaximizeOnActivate=0 ;1 - Maximizes window when video is detected IgnoreFilesLessThanMB=0 ;0-1000x?? - Passthrough Ignores files less than this KeyDelayMS=100 KeyDownDelayMS=50 Exec_Name=VLC_Orig.exe ActiveWindowCoords=0 ;- moves window to this position on video stop 0 ignores or format 0,0,1000,1000 => x,y,w,h InactiveWindowCoords=0 ;- moves window to this position on video stop 0 ignores or format 0,0,1000,1000 => x,y,w,h ExecOnActive= ;execute this file when video is detected ExecOnInactive= ;execute this file when when video stops KeysOnActivate=f ;-keys to press when video is detected KeysOnInactive= ;-keys to press when video stops FileTypes=mp4,avi,mkv,wmv ;-Comma separated list of valid video files WindowName=VLC media player ; WindowText_Fallback=VLC (Direct3D output) ;if valid ext not found fallback to looking for windowname and this text If you don't want to use it as a pass through you'll probably need to change it a bit to do what you want VlcMover.ico #Region ;**** Directives created by AutoIt3Wrapper_GUI **** ;;#AutoIt3Wrapper_Icon=VlcMover.ico #AutoIt3Wrapper_Outfile=VLC86.exe #AutoIt3Wrapper_Outfile_x64=VLC64.exe #AutoIt3Wrapper_AU3Check_Parameters=-q -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** Global $gsINI_PATH = @AppDataDir & "\" & @ScriptName & "_PassThrough.ini" ;Needs to be in @AppDataDir to have write access Global Const $gsINI_SEC = "Config" If FileExists(@ScriptDir & "\" & @ScriptName & "_PassThrough.ini") Then $gsINI_PATH = @ScriptDir & "\" & @ScriptName & "_PassThrough.ini" EndIf ;Override with ini file in script directory, probably not writeable though ;------------------------------------------------------------------------------------ ;GUIConstantsEx Global Const $GUI_EVENT_CLOSE = -0x3 Global Const $giACTWAIT = 5 ;wait #seconds for window to become active Global Enum $ge_bClose = 0, $ge_bMaximize, $ge_iMinSize, $ge_iKeyDelay, $ge_iKeyDnDelay, $ge_sExecute, _ $ge_sActCoord, $ge_sInACoord, $ge_sActExec, $ge_sInAExec, $ge_sSendKeysAct, $ge_sSendKeysInA, _ $ge_sFileTypes, $ge_sWndName, $ge_sWndFbTxt, $ge_LASTCFG Global Const $gaIniKeys[$ge_LASTCFG] = ["CloseOnInactive", "MaximizeOnActivate", "IgnoreFilesLessThanMB", "KeyDelayMS", _ "KeyDownDelayMS", "ExecName", "ActiveWindowCoords", "InactiveWindowCoords", "ExecOnActive", "ExecOnInactive", _ "KeysOnActivate", "KeysOnInactive", "FileTypes", "WindowName", "WindowTextFallback"] ;------------------------------------------------------------------------------------ Global $g_aCfg[$ge_LASTCFG] ;Holds settings for the program $g_aCfg[$ge_bClose] = (Cfg_Read($ge_bClose, 0) = 0 ? False : True) $g_aCfg[$ge_bMaximize] = (Cfg_Read($ge_bMaximize, 0) = 0 ? False : True) $g_aCfg[$ge_iMinSize] = Cfg_Read($ge_iMinSize, "0") ;Mb $g_aCfg[$ge_iKeyDelay] = Cfg_Read($ge_iKeyDelay, 100) $g_aCfg[$ge_iKeyDnDelay] = Cfg_Read($ge_iKeyDnDelay, 50) $g_aCfg[$ge_sExecute] = Cfg_Read($ge_sExecute, StringTrimRight(@ScriptName, 4) & "_Orig.exe") $g_aCfg[$ge_sActCoord] = Cfg_Read($ge_sActCoord, "0") $g_aCfg[$ge_sInACoord] = Cfg_Read($ge_sInACoord, "0") $g_aCfg[$ge_sSendKeysAct] = Cfg_Read($ge_sSendKeysAct, "f") ;(#Win)(+Shift)(arrow)(f)ull screen $g_aCfg[$ge_sSendKeysInA] = Cfg_Read($ge_sSendKeysInA, "") $g_aCfg[$ge_sActExec] = Cfg_Read($ge_sActExec, "") $g_aCfg[$ge_sInAExec] = Cfg_Read($ge_sInAExec, "") $g_aCfg[$ge_sFileTypes] = Cfg_Read($ge_sFileTypes, "mp4,avi,mkv,wmv") ;What files should be intercepted? $g_aCfg[$ge_sWndName] = Cfg_Read($ge_sWndName, "VLC media player") $g_aCfg[$ge_sWndFbTxt] = Cfg_Read($ge_sWndFbTxt, "VLC (Direct3D output)") ;------------------------------------------------------------------------------------ Global $gsMatchFileTypes = BuildFileTypes($g_aCfg[$ge_sFileTypes]) Global $gsMatchWnd = "[REGEXPTITLE:(?i)(" & $gsMatchFileTypes & ")(.*" & $g_aCfg[$ge_sWndName] & ")]" Global $gsMatchWnd_Fb = "[REGEXPTITLE:(?i)(.*" & $g_aCfg[$ge_sWndName] & ")]" ;Fallback Matching Global $gaWndPosAct = GetRectFromString($g_aCfg[$ge_sActCoord]) Global $gaWndPosInact = GetRectFromString($g_aCfg[$ge_sInACoord]) Global $gbActivated = False Global $gPID = 0, $gsErr = "", $ghWndApp _Main() ;-------------------------------------------------------------------------------------- Func _Create_Message($sMessage) Local $iMsg = WinAPI_RegisterWindowMessage($sMessage) If $iMsg = 0 Then $gsErr &= "IPC Message Creation Failure " & $sMessage & @CRLF Return $iMsg EndFunc ;==>_Create_Message Func _Create_MessageHandler($iMsg, $sFunction) If $iMsg <> 0 Then Opt("GUIOnEventMode", 1) GUICreate(@ScriptName & "_IPC", 0, 0, 0, 0, 0, 0) ; create a top level window GUIRegisterMsg($iMsg, $sFunction) EndIf EndFunc ;==>_Create_MessageHandler Func _Exit() ;sets hotkeys and saves settings HotKeySet("{F4}", Settings_GUI) HotKeySet("{F1}", _Help) HotKeySet("{ESC}", _Exit_Now) ToolTip("Pass Through F1 - Help, F4 - Settings, ESC - Quit without saving", 0, 0) Sleep(5000) ToolTip("", 0, 0) HotKeySet("{F4}") HotKeySet("{F1}") HotKeySet("{ESC}") Settings_Save() Exit EndFunc ;==>_Exit Func _Exit_Now() OnAutoItExitUnRegister("_Exit") Exit EndFunc ;==>_Exit_Now Func _Help() MsgBox(0, "Pass Through", "Settings stored in:" & @CRLF & $gsINI_PATH & _ @CRLF & @CRLF & _ "Invoked: " & @ScriptDir & "\" & $g_aCfg[$ge_sExecute] & " " & $CmdLineRaw & _ @CRLF & "FileTypes: " & $gsMatchFileTypes & @CRLF & _ "Errors:" & $gsErr & @CRLF) EndFunc ;==>_Help Func _IsCompiled() ;wakillon Return @Compiled EndFunc ;==>_IsCompiled Func _Main() If Not FileExists($gsINI_PATH) Then ;FIRST RUN Settings_Save() Settings_GUI() EndIf Opt("SendKeyDelay", $g_aCfg[$ge_iKeyDelay]) Opt("SendKeyDownDelay", $g_aCfg[$ge_iKeyDnDelay]) If _IsCompiled() Then Local $iActMsg = _Create_Message("@ScriptFullPath" & "_msg") RunPassThrough($iActMsg) _Create_MessageHandler($iActMsg, "Activated_Ext") EndIf OnAutoItExitRegister("_Exit") Do $ghWndApp = WaitActive_Wnd($gaWndPosAct, $g_aCfg[$ge_sSendKeysAct]) Until (WaitNotExists_Wnd($ghWndApp, $gaWndPosInact, $g_aCfg[$ge_sSendKeysInA]) Or $g_aCfg[$ge_bClose]) If $g_aCfg[$ge_bClose] And WinExists($ghWndApp) Then WinClose($ghWndApp) Exit EndFunc ;==>_Main Func _Singleton_NOCHILD($sOccurrenceName, $iFlag = 0) ;Valik ;Without SECURITY_ATTRIBUTES;;; Local Const $ERROR_ALREADY_EXISTS = 183 Local $aHandle = DllCall("kernel32.dll", "handle", "CreateMutexW", "struct*", 0, "bool", 1, "wstr", $sOccurrenceName) If @error Then Return SetError(@error, @extended, 0) Local $aLastError = DllCall("kernel32.dll", "dword", "GetLastError") If @error Then Return SetError(@error, @extended, 0) If $aLastError[0] = $ERROR_ALREADY_EXISTS Then If BitAND($iFlag, 1) Then DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $aHandle[0]) If @error Then Return SetError(@error, @extended, 0) Return SetError($aLastError[0], $aLastError[0], 0) Else Exit -1 EndIf EndIf Return $aHandle[0] EndFunc ;==>_Singleton_NOCHILD ;------------------------------------------------------------------------------------------ Func Activated_Ext() ;($hWnd, $iMsg, $wParam, $lParam) ;Message Posted from other instances ;call this to notify of an active file $gbActivated = True EndFunc ;==>Activated_Ext Func ArrayToStr($aArray) ;returns single dimension array as comma delimited string ;on error returns 0 Local $sRet = "" Local $iCt = UBound($aArray) - 1 If $iCt < 0 Then Return SetError(1, 0, 0) For $i = 0 To $iCt $sRet &= $aArray[$i] & "," Next $sRet = StringTrimRight($sRet, 1) ;Remove the trailing ',' Return $sRet EndFunc ;==>ArrayToStr Func BuildFileTypes($sTypes) ;Build a regex string of file extensions from a comma separated one ;matches partial filenames too ;"txt,exe,.com,.avi,test.mp3" => ".*\.txt,.*\.exe,.*\.com,.*\.avi,.*test\.mp3" ;('\' escapes the '.') Local $sTmp, $sRet = "" Local $aExt = StringRegExp($sTypes, "(\w+?\.\w+)|\w+", 3) For $i = 0 To UBound($aExt) - 1 $sTmp = $aExt[$i] If StringInStr($sTmp, ".") = 0 Then $sTmp = "." & $sTmp $sRet &= ".*" & StringReplace($sTmp, ".", "\.") & "|" Next $sRet = StringTrimRight($sRet, 1) ;Remove the trailing '|' Return $sRet EndFunc ;==>BuildFileTypes Func Cfg_Read($iSetting, $sDefault) Return IniRead($gsINI_PATH, $gsINI_SEC, $gaIniKeys[$iSetting], $sDefault) EndFunc ;==>Cfg_Read Func Cfg_Write($iSetting, $sValue) If Not _IsCompiled() Then ConsoleWrite($gaIniKeys[$iSetting] & " = " & $sValue & @CRLF) Else IniWrite($gsINI_PATH, $gsINI_SEC, $gaIniKeys[$iSetting], $sValue) EndIf EndFunc ;==>Cfg_Write Func Execute_App($sPath) If FileExists( $sPath) Then Run(Chr(34) & $sPath & Chr(34), "") EndIf EndFunc Func GetRectFromString($sCoords) ;takes rect passed in string 'x, y, w, h' converts to array ;Returns [x, y, w, h] if string is valid or 0 if invalid ;You should check if return is an array with IsArray() Return StringRegExp($sCoords, "(\d+)\D+(\d+)\D+(\d+)\D+(\d+)", 1) EndFunc ;==>GetRectFromString Func RunPassThrough($iActMsg = 0) ;calls the original file passing through commandline arguments Local $sPath = @ScriptDir & "\" & $g_aCfg[$ge_sExecute] Local $sSwitches = $CmdLineRaw ;MsgBox(0, "Pass Through", $sPath & @CRLF & $sSwitches) $gPID = Run(Chr(34) & $sPath & Chr(34) & " " & $sSwitches, "") ; Run If $gPID Then RunSingleInstance($iActMsg) Sleep(1000) ;Wait a moment for the file to load EndFunc ;==>RunPassThrough Func RunSingleInstance($iActMsg) Local Const $iSZMB = (1024 * 1024) Local Const $HWND_BROADCAST = 0xFFFF If _Singleton_NOCHILD(@ScriptName, 1) = 0 Then If $CmdLine[0] > 1 And FileExists($CmdLine[2]) Then If $g_aCfg[$ge_iMinSize] And FileGetSize($CmdLine[2]) < ($g_aCfg[$ge_iMinSize] * $iSZMB) Then ;;;If file is less than $g_aCfg[$ge_iMinSize] Megabytes treat it like an inactive file ElseIf $iActMsg <> 0 Then ; Update script by posting a message from this (new) instance If StringRegExp($CmdLine[2], $gsMatchFileTypes) Then WinAPI_PostMessage($HWND_BROADCAST, $iActMsg, 0, 0) EndIf EndIf EndIf _Exit_Now() ;single instance of script ONLY EndIf EndFunc ;==>RunSingleInstance Func Settings_GUI() Opt("GUIOnEventMode", 0) ;GUIConstantsEx Local Const $GUI_ENABLE = 0x40 Local Const $GUI_DISABLE = 0x80 Local Const $GUI_CHECKED = 0x1 Local Const $GUI_SHOW = 16 Local $nMsg Local Enum $eS_KeySend = 0, $eS_Coords, $eS_SetWHelper, $eS_Exec, $eS_LAST Local $aCtlText[$eS_LAST] = ["Send Keys", "Coordinates (x, y, w, h)", "Set With Helper", "Execute"] Local $aActivCtls[$eS_LAST] ;Holds handles for the Active State Controls Local $aInactCtls[$eS_LAST] ;Holds handles for the Inactive State Controls Local $hForm1_1 = GUICreate("Pass Through Settings", 287, 245, 192, 124) GUICtrlCreateLabel($aCtlText[$eS_Exec], 8, 2, 74, 17) Local $hI_Exec = GUICtrlCreateInput($g_aCfg[$ge_sExecute], 100, 0, 180, 20) GUICtrlCreateLabel("Win Text FB", 8, 30, 74, 17) Local $hI_FbTxt = GUICtrlCreateInput($g_aCfg[$ge_sWndFbTxt], 100, 27, 180, 20) Local $hC_IClose = GUICtrlCreateCheckbox("Close on Inactive", 8, 50, 100, 17) GUICtrlSetState($hC_IClose, $g_aCfg[$ge_bClose] ? 1 : 4) GUICtrlCreateTab(8, 75, 275, 140) If GUICtrlCreateTabItem("Activated Settings") Then GUICtrlSetState(-1, $GUI_SHOW) ; will be display first GUICtrlCreateLabel("File Extensions", 10, 103, 74, 17) Local $hI_FTyp = GUICtrlCreateInput($g_aCfg[$ge_sFileTypes], 128, 100, 150, 20) GUICtrlCreateLabel($aCtlText[$eS_KeySend], 10, 126, 55, 20) $aActivCtls[$eS_KeySend] = GUICtrlCreateInput($g_aCfg[$ge_sSendKeysAct], 128, 122, 150, 20) GUICtrlCreateLabel($aCtlText[$eS_Exec], 10, 148, 55, 20) $aActivCtls[$eS_Exec] = GUICtrlCreateInput($g_aCfg[$ge_sActExec], 128, 144, 150, 20) GUICtrlCreateLabel($aCtlText[$eS_Coords], 10, 169, 111, 20) $aActivCtls[$eS_SetWHelper] = GUICtrlCreateButton($aCtlText[$eS_SetWHelper], 128, 190, 150, 17) $aActivCtls[$eS_Coords] = GUICtrlCreateInput(ArrayToStr($gaWndPosAct), 128, 166, 150, 20) Local $hC_AMaxm = GUICtrlCreateCheckbox("Maximize", 10, 189, 89, 17) GUICtrlSetState($hC_AMaxm, $g_aCfg[$ge_bMaximize] ? 1 : 4) EndIf If GUICtrlCreateTabItem("Inactivated Settings") Then GUICtrlCreateLabel($aCtlText[$eS_KeySend], 10, 103, 55, 20) $aInactCtls[$eS_KeySend] = GUICtrlCreateInput($g_aCfg[$ge_sSendKeysInA], 128, 100, 150, 20) GUICtrlCreateLabel($aCtlText[$eS_Exec], 10, 126, 55, 20) $aInactCtls[$eS_Exec] = GUICtrlCreateInput($g_aCfg[$ge_sInAExec], 128, 122, 150, 20) GUICtrlCreateLabel($aCtlText[$eS_Coords], 10, 148, 111, 20) $aInactCtls[$eS_SetWHelper] = GUICtrlCreateButton($aCtlText[$eS_SetWHelper], 128, 169, 150, 17) $aInactCtls[$eS_Coords] = GUICtrlCreateInput(ArrayToStr($gaWndPosInact), 128, 145, 150, 20) EndIf GUICtrlCreateTabItem("") ; end tabitem definition Local $hB_Cancel = GUICtrlCreateButton("Cancel", 8, 215, 49, 17) Local $hB_Save = GUICtrlCreateButton("Save", 71, 215, 49, 17) GUISetState(@SW_SHOW, $hForm1_1) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $hB_Cancel ContinueCase Case $GUI_EVENT_CLOSE ExitLoop Case $aActivCtls[$eS_SetWHelper] ;Pops-up window to make setting coords easier GUICtrlSetState($aActivCtls[$eS_SetWHelper], $GUI_DISABLE) GUICtrlSetData($aActivCtls[$eS_Coords], Settings_PosHelper("Active Pos", _ GUICtrlRead($aActivCtls[$eS_Coords]))) GUICtrlSetState($aActivCtls[$eS_SetWHelper], $GUI_ENABLE) Case $aInactCtls[$eS_SetWHelper] ;Pops-up window to make setting coords easier GUICtrlSetState($aInactCtls[$eS_SetWHelper], $GUI_DISABLE) GUICtrlSetData($aInactCtls[$eS_Coords], Settings_PosHelper("Inactive Pos", _ GUICtrlRead($aInactCtls[$eS_Coords]))) GUICtrlSetState($aInactCtls[$eS_SetWHelper], $GUI_ENABLE) Case $hB_Save $g_aCfg[$ge_sExecute] = GUICtrlRead($hI_Exec) $g_aCfg[$ge_sWndFbTxt] = GUICtrlRead($hI_FbTxt) $g_aCfg[$ge_bClose] = (BitAND(GUICtrlRead($hC_IClose), $GUI_CHECKED) = $GUI_CHECKED) ? 1 : 0 $g_aCfg[$ge_sFileTypes] = GUICtrlRead($hI_FTyp) $g_aCfg[$ge_sSendKeysAct] = GUICtrlRead($aActivCtls[$eS_KeySend]) $g_aCfg[$ge_sActExec] = GUICtrlRead($aActivCtls[$eS_Exec]) $g_aCfg[$ge_sActCoord] = GUICtrlRead($aActivCtls[$eS_Coords]) $gaWndPosAct = GetRectFromString($g_aCfg[$ge_sActCoord]) $g_aCfg[$ge_bMaximize] = (BitAND(GUICtrlRead($hC_AMaxm), $GUI_CHECKED) = $GUI_CHECKED) ? 1 : 0 $g_aCfg[$ge_sSendKeysInA] = GUICtrlRead($aInactCtls[$eS_KeySend]) $g_aCfg[$ge_sInAExec] = GUICtrlRead($aInactCtls[$eS_Exec]) $g_aCfg[$ge_sInACoord] = GUICtrlRead($aInactCtls[$eS_Coords]) $gaWndPosInact = GetRectFromString($g_aCfg[$ge_sInACoord]) Settings_Save() ExitLoop EndSwitch WEnd GUIDelete($hForm1_1) Return ; EndFunc ;==>Settings_GUI Func Settings_PosHelper($sTitle, $sRect) ;Pops-up window to make setting coords easier ;sRect is a string format 'x, y, w, h' OR '0' ;Returns new sRect in same format ;WindowsConstants Local Const $WS_OVERLAPPEDWINDOW = 0x00CF0000 Local $nMsg Local $hForm1_2 = GUICreate($sTitle, 0, 0, -1, -1, $WS_OVERLAPPEDWINDOW) WndMoveArray($hForm1_2, GetRectFromString($sRect)) Local $hB_Set = GUICtrlCreateButton("Set", 0, 0, 50, 17) GUISetState(@SW_SHOW, $hForm1_2) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $hB_Set $sRect = ArrayToStr(WinGetPos($hForm1_2)) ContinueCase Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd GUIDelete($hForm1_2) Return $sRect ; EndFunc ;==>Settings_PosHelper Func Settings_Save() Local $vVal ; If Not _IsCompiled() Then ConsoleWrite("SETTINGS_SAVE:" & @CRLF) For $i = 0 To $ge_LASTCFG - 1 $vVal = $g_aCfg[$i] If IsBool($vVal) Then Cfg_Write($i, $vVal ? 1 : 0) ElseIf IsArray($vVal) Then Cfg_Write($i, ArrayToStr($vVal)) Else Cfg_Write($i, $vVal) EndIf Next EndFunc ;==>Settings_Save Func WinAPI_PostMessage($hWnd, $iMsg, $wParam, $lParam) Local $aResult = DllCall("user32.dll", "bool", "PostMessage", "hwnd", $hWnd, "uint", $iMsg, "wparam", $wParam, "lparam", $lParam) If @error Then Return SetError(@error, @extended, False) Return $aResult[0] EndFunc ;==>WinAPI_PostMessage Func WinAPI_RegisterWindowMessage($sMessage) Local $aResult = DllCall("user32.dll", "uint", "RegisterWindowMessageW", "wstr", $sMessage) If @error Then Return SetError(@error, @extended, 0) Return $aResult[0] EndFunc ;==>WinAPI_RegisterWindowMessage Func WaitActive_Wnd($aRect, $sKeys) ; Loops waiting for a trigger from vlc window either filename(s) ; in the title or window name and text ; if PID is defined and doesn't exist closes script ; Returns window handle Local $hWnd Do $hWnd = WndTryActivate($gsMatchWnd, "") ; Wait for active window If $hWnd = 0 Then ;Fallback $hWnd = WndTryActivate($gsMatchWnd_Fb, $g_aCfg[$ge_sWndFbTxt]) If $hWnd <> 0 Then ExitLoop If $gPID And Not ProcessExists($gPID) And Not WinExists($gsMatchWnd) Then Exit Sleep(1000) EndIf Until ($hWnd <> 0) WndMoveArray($hWnd, $aRect) WndSendKeys($hWnd, $sKeys) If $g_aCfg[$ge_bMaximize] Then WinSetState($hWnd, "", @SW_MAXIMIZE) Execute_App($g_aCfg[$ge_sActExec]) Return $hWnd EndFunc ;==>WaitActive_Wnd Func WaitNotExists_Wnd($hWnd, $aRect, $sKeys) ;Returns False if Title Does Not exist but $hWnd DOES exist ;Returns True if $hWnd + $title DOES NOT exist Do $gbActivated = False WinWaitClose(WinGetTitle($ghWndApp)) Until (Not $gbActivated) ;can be overidden by message posted from another instance If WinExists($hWnd) Then WndSendKeys($hWnd, $sKeys) If $g_aCfg[$ge_bMaximize] Then WinSetState($hWnd, "", @SW_RESTORE) WndMoveArray($hWnd, $aRect) Execute_App($g_aCfg[$ge_sInAExec]) Return False EndIf Return True EndFunc ;==>WaitNotExists_Wnd Func WndMoveArray($hWnd, $aC) ;Moves $hWnd to coords specified by array If UBound($aC) >= 4 Then WinMove($hWnd, "", $aC[0], $aC[1], $aC[2], $aC[3]) EndIf EndFunc ;==>WndMoveArray Func WndSendKeys($hWnd, $sKeys) If $sKeys <> "" Then ControlSend($hWnd, "", 0, $sKeys) Sleep(100) EndIf EndFunc ;==>WndSendKeys Func WndTryActivate($Title, $Text = "") ;attemps to activate a window / waits $giACTWAIT seconds for window to become active WinActivate($Title, $Text) Local $hWnd = WinWaitActive($Title, $Text, $giACTWAIT) ; Wait for active window for number of seconds Return $hWnd EndFunc ;==>WndTryActivate
    1 point
  4. @PunkoHead Here are the constants for the Option property of the WinHttpRequest object: Global Enum $WinHttpRequestOption_UserAgentString, _ $WinHttpRequestOption_URL, _ $WinHttpRequestOption_URLCodePage, _ $WinHttpRequestOption_EscapePercentInURL, _ $WinHttpRequestOption_SslErrorIgnoreFlags, _ $WinHttpRequestOption_SelectCertificate, _ $WinHttpRequestOption_EnableRedirects, _ $WinHttpRequestOption_UrlEscapeDisable, _ $WinHttpRequestOption_UrlEscapeDisableQuery, _ $WinHttpRequestOption_SecureProtocols, _ $WinHttpRequestOption_EnableTracing, _ $WinHttpRequestOption_RevertImpersonationOverSsl, _ $WinHttpRequestOption_EnableHttpsToHttpRedirects, _ $WinHttpRequestOption_EnablePassportAuthentication, _ $WinHttpRequestOption_MaxAutomaticRedirects, _ $WinHttpRequestOption_MaxResponseHeaderSize, _ $WinHttpRequestOption_MaxResponseDrainSize, _ $WinHttpRequestOption_EnableHttp1_1, _ $WinHttpRequestOption_EnableCertificateRevocationCheck Here are the valid values for ignoring SSL errors Global CONST $WinHttpRequestOption_SslErrorIgnoreFlags_UnknownCA = 0x0100 Global CONST $WinHttpRequestOption_SslErrorIgnoreFlags_CertWrongUsage = 0x0200 Global CONST $WinHttpRequestOption_SslErrorIgnoreFlags_CertCNInvalid = 0x1000 Global CONST $WinHttpRequestOption_SslErrorIgnoreFlags_CertDateInvalid = 0x2000 Global CONST $WinHttpRequestOption_SslErrorIgnoreFlags_IgnoreAll = 0x3300 ;IGNORE ALL OF THE ABOVE So to ignore all SSL errors, you could add the following line before your send: $oHTTP.Option($WinHttpRequestOption_SslErrorIgnoreFlags) = $WinHttpRequestOption_SslErrorIgnoreFlags_IgnoreAll or $oHTTP.Option(4) = 0x3300
    1 point
  5. Try searching from left to right? Global $Paused HotKeySet('{Insert}', 'TogglePause') WinActivate("dots - Paint") $dot = 1 $count = 1 While $count < 1187 $dot = PixelSearch(8 + $count, 146, 8 + $count, 613, 0x000000) If Not @error Then MouseMove($dot[0], $dot[1], 50) MouseClick("Left", $dot[0], $dot[1], 1, 10) EndIf $count = $count + 4 WEnd Func TogglePause() $Paused = Not $Paused While $Paused Sleep(100) WEnd EndFunc ;==>TogglePause
    1 point
  6. $str = "AX 123 26OCT ABC 23 1800 UHS TIM XON LIST A12B20C213" msgbox(0, '' , Execute(StringRegExpReplace(stringmid($str , stringinstr($str , " " , 0 , -1) + 1) , "\D" , "+")))
    1 point
  7. Why not just have a Desktop shortcut that has the Paint icon but it's path is to your .jpg?
    1 point
  8. Jos

    Send Email - Very Simple

    Yea, wonder who made that
    1 point
  9. careca

    MSPaint connecting dots.

    Hi, this is interesting, there are probably lots of ways to do it, but i think my approach would start by looping the pixelsearch until i got all points, somehow ignore points too close to each other, meaning pixels around a specific pixel, because what you have there is a circle with lots of black pixels. When i say somehow, i mean maybe add those points into an exclusion list if the difference between x1 and x2 < 10px or so. After i got all the points, i'd sort them by the X coordinate, then loop through them with the mouse click, reverse sort, and then click all back.
    1 point
  10. WilliamasKumeliukas, Sorry, I was not aware I was your personal code slave to do your bidding immediately you request it. I will look into your code as and when I have time - the real world is giving me quite enough problems to deal with at the moment. M23
    1 point
  11. Interesting, is the dll in script dir?
    1 point
×
×
  • Create New...