-
Posts
7 -
Joined
-
Last visited
Everything posted by Daavis
-
Great idea! It works fine but there is a title and some other windows stuff. #include <GUIConstantsEx.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> #include <Constants.au3> $hGUIMain = GUICreate("Parent", 800, 600) GUISetState(@SW_SHOW, $hGUIMain) Opt("WinTitleMatchMode", 2) $hGUITool = WinGetHandle("Firefox") If $hGUITool = 0 Then MsgBox(0,"","Run firefox first!") Exit EndIf $Toolbarfenster = WinGetPos($hGUITool) GUISetStyle(BitOR($WS_CHILD, $WS_BORDER), 0, $hGUITool) ; den Style ändern _WinAPI_SetParent($hGUITool, $hGUIMain) ; einbetten WinMove($hGUITool, "", 0, 0, 800, 600) ; an 0,0 des Hauptfensters schieben _WinAPI_RedrawWindow($hGUITool) ; neu zeichenen _WinAPI_RedrawWindow($hGUIMain) ; neu zeichenen While 1 $avMsg = GUIGetMsg(1) Switch $avMsg[1] Case $hGUIMain Switch $avMsg[0] Case -3 Exit EndSwitch EndSwitch WEnd
-
Clipboard cleaner tool
Daavis replied to hiteshluthraauto's topic in AutoIt General Help and Support
Wait until key is released: #include <Misc.au3> #include <MsgBoxConstants.au3> #include <Timers.au3> #include <Date.au3> #include <File.au3> #include <Clipboard.au3> #include <GUIConstantsEx.au3> #include <SendMessage.au3> #include <WindowsConstants.au3> #include <FileConstants.au3> #include <Array.au3> Global $g_idMemo, $g_hNext = 0 Global $Timeout = 10 Global $CopyTime Global $CurrentTime Global $LogDir = @UserProfileDir & "\Appdata\Roaming\Cliplog" Global $LogBackup = @UserProfileDir & "\Appdata\Roaming\Cliplog\Backup" Global $IsPasted = True Local $LogFile = @UserProfileDir & "\Appdata\Roaming\Cliplog\Cliplog.txt" Local $FileCreateDate = FileGetTime($LogFile, 1) If FileExists($LogDir) Then If FileExists($LogFile) Then If $FileCreateDate[1] < @MON Or $FileCreateDate[0] < @YEAR Then FileMove(@UserProfileDir & "\Appdata\Roaming\Cliplog\Cliplog.txt", @UserProfileDir & "\Appdata\Roaming\Cliplog\Cliplog_" & @MDAY & @MON & @YEAR & ".txt", 8) If FileExists($LogBackup) Then FileMove(@UserProfileDir & "\Appdata\Roaming\Cliplog" & "\*.txt", @UserProfileDir & "\Appdata\Roaming\Cliplog\Backup", $FC_OVERWRITE + $FC_CREATEPATH) Else DirCreate($LogBackup) FileMove(@UserProfileDir & "\Appdata\Roaming\Cliplog" & "\*.txt", @UserProfileDir & "\Appdata\Roaming\Cliplog\Backup", $FC_OVERWRITE + $FC_CREATEPATH) EndIf EndIf Else Example() EndIf Else DirCreate($LogDir) EndIf Example() Func Example() Local $hGUI ; Create GUI $hGUI = GUICreate("Clipboard", 600, 400) $g_idMemo = GUICtrlCreateEdit("", 2, 2, 596, 396, $WS_VSCROLL) GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New") GUISetState(@SW_SHOWMINIMIZED) ; Initialize clipboard viewer $g_hNext = _ClipBoard_SetViewer($hGUI) GUIRegisterMsg($WM_CHANGECBCHAIN, "WM_CHANGECBCHAIN") GUIRegisterMsg($WM_DRAWCLIPBOARD, "WM_DRAWCLIPBOARD") MemoWrite("Clipboard utility ....: AON") MemoWrite("Clipboard owner ....: " & @UserName) MemoWrite(":...............................................................................:") ; Loop until the user exits. Local $GetMsg = True While 1 Local $currMsg = GUIGetMsg() Clear() ; if $currMsg = $GUI_EVENT_CLOSE then $GetMsg = False WEnd ; Shut down clipboard viewer _ClipBoard_ChangeChain($hGUI, $g_hNext) EndFunc ;==>Example ; Write message to memo Func MemoWrite($sMessage = "", $IsDate = True) If $IsDate Then GUICtrlSetData($g_idMemo, _Now() & " " & $sMessage & @CRLF, 1) Else GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1) EndIf EndFunc ;==>MemoWrite ; Handle $WM_CHANGECBCHAIN messages Func WM_CHANGECBCHAIN($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg ; Show that message was received MemoWrite("***** $WM_CHANGECBCHAIN *****") ; If the next window is closing, repair the chain If $wParam = $g_hNext Then $g_hNext = $lParam ; Otherwise pass the message to the next viewer ElseIf $g_hNext <> 0 Then _SendMessage($g_hNext, $WM_CHANGECBCHAIN, $wParam, $lParam, 0, "hwnd", "hwnd") EndIf EndFunc ;==>WM_CHANGECBCHAIN ; Handle $WM_DRAWCLIPBOARD messages Func WM_DRAWCLIPBOARD($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg ; Display any text on clipboard MemoWrite(_ClipBoard_GetData()) ; Pass the message to the next viewer If $g_hNext <> 0 Then _SendMessage($g_hNext, $WM_DRAWCLIPBOARD, $wParam, $lParam) EndFunc ;==>WM_DRAWCLIPBOARD Func Clear() If _IsPressed("11") And _IsPressed("56") Then If Not $IsPasted Then $CMD = "echo off | clip" ;you start your script here RunWait(@ComSpec & " /c " & $CMD, @WindowsDir, @SW_SHOW) EndIf $IsPasted = True Else If _IsPressed("11") And _IsPressed("43") Then Global $sData = ClipGet() ; Retrieve the data stored in the clipboard. $CopyTime = _NowCalc() ; Store copytime to variable ;Msgbox ($MB_SYSTEMMODAL, "", "The following tmp" & @CRLF & ClipGet() , $Timeout) _FileWriteLog($LogFile, $sData) ;Write Log to log file $IsPasted = False While _IsPressed("11") And _IsPressed("43") Sleep(250) WEnd EndIf $CurrentTime = _NowCalc() If Not $IsPasted Then If _DateDiff('s', $CopyTime, $CurrentTime) > 10 And _DateDiff('s', $CopyTime, $CurrentTime) < 12 Then $CMD = "echo off | clip" ;you start your script here RunWait(@ComSpec & " /c " & $CMD, @WindowsDir, @SW_SHOW) $IsPasted = True EndIf EndIf If _IsPressed("11") And _IsPressed("10") And _IsPressed("23") Then Exit EndIf EndIf Break(0) ; Disable Break/Pause/Exit of script GUIGetMsg() ; to cool out CPU when CTRL+V is not pressed. It was not kept in loop of while so that it can be called everytime but not when CTRL+ V is pressed.If not added then CPU usage will be 25% EndFunc ;==>Clear Last text <> Current text: #include <Misc.au3> #include <MsgBoxConstants.au3> #include <Timers.au3> #include <Date.au3> #include <File.au3> #include <Clipboard.au3> #include <GUIConstantsEx.au3> #include <SendMessage.au3> #include <WindowsConstants.au3> #include <FileConstants.au3> #include <Array.au3> Global $g_idMemo, $g_hNext = 0 Global $Timeout = 10 Global $CopyTime Global $CurrentTime Global $LogDir = @UserProfileDir & "\Appdata\Roaming\Cliplog" Global $LogBackup = @UserProfileDir & "\Appdata\Roaming\Cliplog\Backup" Global $IsPasted = True Local $LogFile = @UserProfileDir & "\Appdata\Roaming\Cliplog\Cliplog.txt" Local $FileCreateDate = FileGetTime($LogFile, 1) Global $LastText = "" If FileExists($LogDir) Then If FileExists($LogFile) Then If $FileCreateDate[1] < @MON Or $FileCreateDate[0] < @YEAR Then FileMove(@UserProfileDir & "\Appdata\Roaming\Cliplog\Cliplog.txt", @UserProfileDir & "\Appdata\Roaming\Cliplog\Cliplog_" & @MDAY & @MON & @YEAR & ".txt", 8) If FileExists($LogBackup) Then FileMove(@UserProfileDir & "\Appdata\Roaming\Cliplog" & "\*.txt", @UserProfileDir & "\Appdata\Roaming\Cliplog\Backup", $FC_OVERWRITE + $FC_CREATEPATH) Else DirCreate($LogBackup) FileMove(@UserProfileDir & "\Appdata\Roaming\Cliplog" & "\*.txt", @UserProfileDir & "\Appdata\Roaming\Cliplog\Backup", $FC_OVERWRITE + $FC_CREATEPATH) EndIf EndIf Else Example() EndIf Else DirCreate($LogDir) EndIf Example() Func Example() Local $hGUI ; Create GUI $hGUI = GUICreate("Clipboard", 600, 400) $g_idMemo = GUICtrlCreateEdit("", 2, 2, 596, 396, $WS_VSCROLL) GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New") GUISetState(@SW_SHOWMINIMIZED) ; Initialize clipboard viewer $g_hNext = _ClipBoard_SetViewer($hGUI) GUIRegisterMsg($WM_CHANGECBCHAIN, "WM_CHANGECBCHAIN") GUIRegisterMsg($WM_DRAWCLIPBOARD, "WM_DRAWCLIPBOARD") MemoWrite("Clipboard utility ....: AON") MemoWrite("Clipboard owner ....: " & @UserName) MemoWrite(":...............................................................................:") ; Loop until the user exits. Local $GetMsg = True While 1 Local $currMsg = GUIGetMsg() Clear() ; if $currMsg = $GUI_EVENT_CLOSE then $GetMsg = False WEnd ; Shut down clipboard viewer _ClipBoard_ChangeChain($hGUI, $g_hNext) EndFunc ;==>Example ; Write message to memo Func MemoWrite($sMessage = "", $IsDate = True) If $IsDate Then GUICtrlSetData($g_idMemo, _Now() & " " & $sMessage & @CRLF, 1) Else GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1) EndIf EndFunc ;==>MemoWrite ; Handle $WM_CHANGECBCHAIN messages Func WM_CHANGECBCHAIN($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg ; Show that message was received MemoWrite("***** $WM_CHANGECBCHAIN *****") ; If the next window is closing, repair the chain If $wParam = $g_hNext Then $g_hNext = $lParam ; Otherwise pass the message to the next viewer ElseIf $g_hNext <> 0 Then _SendMessage($g_hNext, $WM_CHANGECBCHAIN, $wParam, $lParam, 0, "hwnd", "hwnd") EndIf EndFunc ;==>WM_CHANGECBCHAIN ; Handle $WM_DRAWCLIPBOARD messages Func WM_DRAWCLIPBOARD($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg ; Display any text on clipboard MemoWrite(_ClipBoard_GetData()) ; Pass the message to the next viewer If $g_hNext <> 0 Then _SendMessage($g_hNext, $WM_DRAWCLIPBOARD, $wParam, $lParam) EndFunc ;==>WM_DRAWCLIPBOARD Func Clear() If _IsPressed("11") And _IsPressed("56") Then If Not $IsPasted Then $CMD = "echo off | clip" ;you start your script here RunWait(@ComSpec & " /c " & $CMD, @WindowsDir, @SW_SHOW) EndIf $IsPasted = True Else If _IsPressed("11") And _IsPressed("43") Then Global $sData = ClipGet() ; Retrieve the data stored in the clipboard. $CopyTime = _NowCalc() ; Store copytime to variable ;Msgbox ($MB_SYSTEMMODAL, "", "The following tmp" & @CRLF & ClipGet() , $Timeout) If $LastText <> $sData Then _FileWriteLog($LogFile, $sData) ;Write Log to log file $IsPasted = False $LastText = $sData EndIf $CurrentTime = _NowCalc() If Not $IsPasted Then If _DateDiff('s', $CopyTime, $CurrentTime) > 10 And _DateDiff('s', $CopyTime, $CurrentTime) < 12 Then $CMD = "echo off | clip" ;you start your script here RunWait(@ComSpec & " /c " & $CMD, @WindowsDir, @SW_SHOW) $IsPasted = True EndIf EndIf If _IsPressed("11") And _IsPressed("10") And _IsPressed("23") Then Exit EndIf EndIf Break(0) ; Disable Break/Pause/Exit of script GUIGetMsg() ; to cool out CPU when CTRL+V is not pressed. It was not kept in loop of while so that it can be called everytime but not when CTRL+ V is pressed.If not added then CPU usage will be 25% EndFunc ;==>Clear -
Clipboard cleaner tool
Daavis replied to hiteshluthraauto's topic in AutoIt General Help and Support
You can add loop in _IsPressed so program wait until key is released. Example from help: #include <Misc.au3> #include <MsgBoxConstants.au3> Local $hDLL = DllOpen("user32.dll") While 1 If _IsPressed("10", $hDLL) Then ConsoleWrite("_IsPressed - Shift Key was pressed." & @CRLF) ; Wait until key is released. While _IsPressed("10", $hDLL) Sleep(250) WEnd ConsoleWrite("_IsPressed - Shift Key was released." & @CRLF) ElseIf _IsPressed("1B", $hDLL) Then MsgBox($MB_SYSTEMMODAL, "_IsPressed", "The Esc Key was pressed, therefore we will close the application.") ExitLoop EndIf Sleep(250) WEnd DllClose($hDLL) Or you can do a variable that stored last writed text and when you write you should check if last text <> current text. -
Hi guys! I found some solution for embedded firefox so i tested it: #include <GUIConstants.au3> $oFF = ObjCreate("Mozilla.Browser") if Not Isobj($oFF) then Msgbox(0,"Mozilla","Can't get Mozilla") endif GUICreate ( "FF Embedded Web control Test", 1200, 800, Default, Default, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS) $GUIActiveX = GUICtrlCreateObj ( $oFF, 0, 0 , 1200 , 800 ) GUISetState () ;Show GUI $oFF.navigate("https://www.google.com/") MsgBox(0,"","") It works fine but only if I tried run google.com. Other pages were blank. And there is some popup all the time. Another thing is how can i get html of curret page or click on element by id like in FF.au3
-
Can I send http request to opened window of browser in autoit or other language? Or could I send some request and then open browser window with session(log in)?
-
Trying to get x and y pos of windows without borders
Daavis replied to Daavis's topic in AutoIt General Help and Support
#include <FF.au3> #include <Array.au3> _FFStart("https://www.google.com") $Handle = _FFWindowGetHandle() WinMove($Handle, "", 0, 0) $Pos = _FFGetPosition() _ArrayDisplay($Pos) This code return me this: Row|Col 0 [0]|-1 [1]|-1 [2]|-8 [3]|-31 [4]|700 [5]|650 As you can see I moved window to 0, 0 so this return position is wrong [1] should be greater then 0 not -8 FF.au3 using ControlGetPos for this function so something goes wrong. Local $aContent = ControlGetPos(_FFCmd(".title"), "", _FFWindowGetHandle()) -
Hi, I'm trying to get x and y pos of browser(firefox) but without borders and window title. I tried ControlGetPos but it doesn't work. _FFGetPostion from FF.au3 also doesn't work. I was thinking: hey can I disable the window title and border? and I found answer: yes So I copy some function of anygui.au3 and I got this: $Style = 0x00C00000 $ExStyle = -1 $result = _TargetStyle("unset", 1, $Style, $ExStyle, $handle) I like it but in windows 10 there is a little white bar on top, like 5px. I tested this on old computer with classic theme windows and it works fine. I know that I can count these pixels and it works but only on my computer. I want universal script that always work. So my question is: Can I change window theme to classic but only one which I want? Or if you know how can I get this pos in another way please let me know.