Leaderboard
Popular Content
Showing content with the highest reputation on 12/28/2024 in all areas
-
transparent movable windows with drop shadow
ioa747 reacted to pixelsearch for a topic
I tried to adapt Nine's idea (found in his post) to subclass the imaged button, not using... _WinAPI_SetWindowLong() and its $GWL_WNDPROC parameter... ...but using the 2nd way for subclassing, e.g. the 3 functions : _WinAPI_SetWindowSubclass _WinAPI_DefSubclassProc _WinAPI_RemoveWindowSubclass LarsJ wrote a lot about the 2 ways of subclassing in different threads. Also here is a msdn link which explains and compares these 2 ways. In case you don't already have them, the 4 pics used in the script can be found elsewhere in this thread, here (2 pics) and there (2 pics) #include <GDIPlus.au3> #include <GuiConstants.au3> #include <WinAPIShellEx.au3> #include <WinAPISys.au3> Opt("MustDeclareVars", 1) OnAutoItExitRegister('OnAutoItExit') Global $g_hDll, $g_pDll, $g_hBtn Example() ;============================================== Func Example() _GDIPlus_Startup() Local $hGUI = GUICreateEx("main.png", 100, 100) _WinAPI_SetWindowLong($hGUI, $GWL_EXSTYLE , BitOR(_WinAPI_GetWindowLong($hGUI, $GWL_EXSTYLE), $WS_EX_CONTROLPARENT)) Local $hGUI2 = GUICreateEx("item.png", 150, 400, $hGUI) Local $hGUI3 = GUICreateEx("item.png", 400, 400, $hGUI) Local $hGUI4 = GUICreate("", 52, 51, 100, 100, $WS_POPUP, $WS_EX_MDICHILD, $hGUI) Local $idBtn = GUICtrlCreateButton("", 0, 0, 52, 51, $BS_BITMAP) GUICtrlSetImage($idBtn, @ScriptDir & "\Cancel 52-51.bmp") $g_hBtn = GUICtrlGetHandle($idBtn) Global $g_hDll = DllCallbackRegister('_BtnProc', 'lresult', 'hwnd;uint;wparam;lparam;uint_ptr;dword_ptr') Global $g_pDll = DllCallbackGetPtr($g_hDll) _WinAPI_SetWindowSubclass($g_hBtn, $g_pDll, 1000, $idBtn) ; remember how the 4th param. is used in this script (+++) GUISetState(@SW_SHOW, $hGUI4) While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $idBtn ConsoleWrite("Button pressed" & @crlf) EndSwitch WEnd _GDIPlus_Shutdown() EndFunc ;==>Example ;============================================== Func _BtnProc($hWnd, $iMsg, $wParam, $lParam, $IdSubclass, $dwRefData) Local Static $bHover Switch $iMsg Case $WM_MOUSEMOVE If Not $bHover Then GUICtrlSetImage($dwRefData, @ScriptDir & "\OK 52-51.bmp") $bHover = True EndIf Case $WM_MOUSELEAVE GUICtrlSetImage($dwRefData, @ScriptDir & "\Cancel 52-51.bmp") $bHover = False EndSwitch Return _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam) EndFunc ;==>_BtnProc ;============================================== Func OnAutoItExit() _WinAPI_RemoveWindowSubclass($g_hBtn, $g_pDll, 1000) DllCallbackFree($g_hDll) EndFunc ;==>OnAutoItExit ;============================================== Func GUICreateEx($sImage, $iPosX = -1, $iPosY = -1, $hParent = 0) Local $hWnd = GUICreate("", -1, -1, $iPosX, $iPosY, $WS_POPUP, BitOR($WS_EX_LAYERED, $hParent ? $WS_EX_MDICHILD : 0), $hParent) GUIUpdate($hWnd, $sImage) GUISetState() Return $hWnd EndFunc ;==>GUICreateEx ;============================================== Func GUIUpdate($hWnd, $sImage) Local $hImage = _GDIPlus_ImageLoadFromFile($sImage) Local $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) _WinAPI_UpdateLayeredWindowEx($hWnd, -1, -1, $hBitmap) _WinAPI_DeleteObject($hBitmap) _GDIPlus_ImageDispose($hImage) EndFunc ;==>GUIUpdate Hope I scripted it correctly, fingers crossed Please indicate if something needs to be modified, thanks !1 point -
Speed-up GUI Launch and Exit
mr-es335 reacted to pixelsearch for a topic
I see you edited your last post to ask this : In fact, in all the functions we create, there IS a default return value returned to the calling function. This value is 0 (except if you indicate by yourself that you want to return another value). For example, in this script... Local $iReturn1 = _Form1() ConsoleWrite("$iReturn1 = " & $iReturn1 & @crlf) ; displays False (0) Local $iReturn2 = _Form2() ConsoleWrite("$iReturn2 = " & $iReturn2 & @crlf) ; displays False (0) Func _Form1() ; whatever EndFunc ;==>_Form1 Func _Form2() ; whatever Return 0 ; or simply Return, that's equivalent EndFunc ;==>_Form1 ... 0 was returned from both functions, even from _Form1() which doesn't have a Return statement in it. So to answer your question, if you don't need to return a special value to the calling function, then a simple Return statement will be enough, but always have in mind that 0 will be returned in this case.1 point -
Speed-up GUI Launch and Exit
mr-es335 reacted to pixelsearch for a topic
Hello, 1) Concerning your Example2a (displayed in your last post) The script is ok, apart from the Global $MainGui2 which doesn't have a value in all the script, you probably forgot it here : ; GUICreate("", 40, 35, 640, 280, $WS_POPUP, $WS_EX_TOPMOST) $MainGui2 = GUICreate("", 40, 35, 640, 280, $WS_POPUP, $WS_EX_TOPMOST) And in the way the script is coded, you don't need it Global as the variable is only found in Func _MainGui2() so this should be enough : Local $MainGui2 = GUICreate("", 40, 35, 640, 280, $WS_POPUP, $WS_EX_TOPMOST) In this script, you're correctly ending Func _MainGui2() so the Return to Func _MainGui1() is correctly done. 2) Concerning your both attached scripts "Example1.au3" and "Example2.au3" They're both incorrect because you never end any function Func _Form1() or Func _Form2() The way you scripted them looks like this : _Form1() Func _Form1() _Form2() ConsoleWrite("Form1 : this line will never be displayed in Console") EndFunc ;==>_Form1 Func _Form2() _Form1() ConsoleWrite("Form2 : this line will never be displayed in Console") EndFunc ;==>_Form2 When you run this script, then you start a recursion process (calling functions from functions without ending any function) which will end abruptly at a certain time with this error message in the Console : ==> Recursion level has been exceeded - AutoIt will quit to prevent stack overflow. >Exit code: 11 point -
True. The only way to get rid of all these unsolvable TZ+DST issues would be to use only UTC everywhere for all purposes. Of course it would need that almost all humans change their "clock" habits, and accept that their "normal" wake up time is no more e.g. 06:30 but 01:00 or 17:45 depending on where they are.1 point
-
Thanks again ioa747. Works fine, though leaves the 'temp' folder behind. Easy enough to sort. Thanks again.1 point
-
Speed-up GUI Launch and Exit
mr-es335 reacted to pixelsearch for a topic
No it is not, plenty of _MainGui1 windows will be opened at same time. I commented / added / modified some lines in your script : #cs In this example, the "AddSoundFile" script will be adapted to the "Launch_TAC_Deployed_Version" script. Purpose: The "Launch_TAC_Deployed_Version" script employs the Switch|Case commands. Observations: Status: Date: #ce ; ----------------------------------------------- #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> ; ----------------------------------------------- #AutoIt3Wrapper_Au3Check_Parameters=-q -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 ; ----------------------------------------------- Opt("MustDeclareVars", 1) ; ----------------------------------------------- Global $MainGui2 ; Global $sCol1Row1 ; no need Global $sColRow ; ----------------------------------------------- _MainGui1() ; ----------------------------------------------- Func _MainGui1() ConsoleWrite("_MainGui1()" & @CRLF) GUICreate("_MainGui1", 145, 75) GUISetFont(14, 800, 0, "Calibri") ; ----------------------------------------------- Local $sCol1Row1 = GUICtrlCreateButton("AddSoundFile", 10, 10, 125, 25) ; added Local to this line Local $sCol1Row2 = GUICtrlCreateButton("Exit Me", 10, 40, 125, 25) ; ----------------------------------------------- GUISetState(@SW_SHOW) ; ----------------------------------------------- While 1 Local $nMsg = GUIGetMsg() ; ----------------- Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $sCol1Row1 GUICtrlSetState($sCol1Row1, $GUI_DISABLE) _MainGui2() GUICtrlSetState($sCol1Row1, $GUI_ENABLE) ; added this line Case $sCol1Row2 _ExitMe() EndSwitch WEnd EndFunc ;==>_MainGui1 ; ----------------------------------------------- Func _MainGui2() ConsoleWrite("_MainGui2()" & @CRLF) $MainGui2 = GUICreate("", 115, 20, 115, 52, $WS_POPUP, $WS_EX_TOPMOST) GUISetFont(14, 800, 0, "Calibri") GUISetBkColor(0x3D3D3D) ; ----------------------------------------------- $sColRow = GUICtrlCreateLabel("Enable HotKey", 0, 0, 115, 20, $SS_CENTER) GUICtrlSetColor(-1, 0xFFFFFF) ; ----------------------------------------------- GUISetState(@SW_SHOW) ; ----------------------------------------------- While 1 Local $nMsg = GUIGetMsg() ; ----------------- Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $sColRow ; _EnableHotKey() ; this original line is not enough Local $bHotKeyStatus = _EnableHotKey() ; we need a return value ($bHotKeyStatus) to know how to continue If $bHotKeyStatus = True Then ExitLoop ; this will finally return to _MainGui1() loop EndSwitch WEnd EndFunc ;==>_MainGui2 ; ----------------------------------------------- Func _Close_MainGui2() ConsoleWrite("_Close_MainGui2()" & @CRLF) GUIDelete($MainGui2) ; _MainGui1() ; certainly not, you got to return to _MainGui1() one way or another, but not by calling it again from here ; or you'll get 2 _MainGui1 windows opened at same time, then 3, 4 etc... EndFunc ;==>Close_MainGui2 ; ----------------------------------------------- Func _EnableHotKey() ConsoleWrite("_EnableHotKey()" & @CRLF) Local Static $hbHotKeyEnabled = True ; ----------------------------------------------- If $hbHotKeyEnabled = True Then GUICtrlSetData($sColRow, "Exit") $hbHotKeyEnabled = False Else GUICtrlSetData($sColRow, "Enable HotKey") _Close_MainGui2() $hbHotKeyEnabled = True EndIf Return $hbHotKeyEnabled ; we return this value to the line that called _EnableHotKey() in _MainGui2() loop EndFunc ;==>_EnableHotKey ; ----------------------------------------------- Func _ExitMe() ConsoleWrite("_ExitMe()" & @CRLF) Exit EndFunc ;==>_ExitMe ; -----------------------------------------------1 point -
World Time for the CLI
argumentum reacted to CarlD for a topic
Oh, that's great! I always wondered how to do that and never took the time to find it in the documentation. Many thanks!1 point -
transparent movable windows with drop shadow
argumentum reacted to ioa747 for a topic
ConsoleWrite("MustDeclareVars:" & Opt("MustDeclareVars") & " :=" & VarGetType(Opt("MustDeclareVars")) & @CRLF)1 point -
transparent movable windows with drop shadow
argumentum reacted to Nine for a topic
Works for me with True and it is way more elegant than a placid 1...1 point -
World Time for the CLI
CarlD reacted to argumentum for a topic
Yes I am. Just add that line to your script. It will not brake anything and will allow to press Shift-F8 in SciTE, and add the command line. Allowing to test from the comfort of SciTE without touching the script1 point -
World Time for the CLI
CarlD reacted to argumentum for a topic
If $CmdLine[0] Then $sWhere = $CmdLineRaw If StringInStr($sWhere, @ScriptFullPath) Then $sWhere = StringStripWS(StringTrimLeft($sWhere, StringInStr($sWhere, @ScriptFullPath) + StringLen(@ScriptFullPath)), 3) ConsoleWrite('>' & $sWhere & '<' & @CRLF) Looks good. 👍1 point -
For a more or less detailed history of timescales, see https://www.ucolick.org/~sla/leapsecs/timescales.html About timezones, rules, regions are changing so fast theat it's impossible in practice to be correct in the general case. Just for recent years: https://time.is/fr/time_zone_news1 point
-
Then most probably solution from @Dan_555 will work for you.1 point
-
Or based on notification : #include <WinAPIConv.au3> #include <GUIConstants.au3> #include <Constants.au3> Global $idComboBox Example() Func Example() Local $hGUI = GUICreate("Example", 300, 200) $idComboBox = GUICtrlCreateCombo("1", 10, 10, 185, 20) Local $idButton_Close = GUICtrlCreateButton("Close", 210, 170, 85, 25) GUICtrlSetData($idComboBox, "2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48") GUISetState() GUIRegisterMsg($WM_COMMAND, WM_COMMAND) While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $idButton_Close ExitLoop EndSwitch WEnd EndFunc ;==>Example Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) Local $idCtrl = _WinAPI_LoWord($wParam), $iCode = _WinAPI_HiWord($wParam) If $idCtrl = $idComboBox And ($iCode = $CBN_KILLFOCUS Or $iCode = $CBN_SELCHANGE) Then DoSomething($idCtrl) Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND Func DoSomething($idComboBox) Local Static $sSelection Local $sComboRead = GUICtrlRead($idComboBox) If $sSelection <> $sComboRead Then If GUICtrlSendMsg($idComboBox, $CB_FINDSTRINGEXACT, -1, $sComboRead) = -1 Then GUICtrlSendMsg($idComboBox, $CB_SETCURSEL, -1, 0) $sSelection = "" ConsoleWrite("Invalid data" & @CRLF) Else $sSelection = $sComboRead ConsoleWrite("The combobox is currently displaying: " & $sComboRead & @CRLF) EndIf EndIf EndFunc ;==>DoSomething1 point
-
Here is my contribution #include <MsgBoxConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Example() Func Example() ; Create a GUI with various controls. Local $hGUI = GUICreate("Example", 300, 200) Local $Template1 = "1" Local $Combo_template1 = GUICtrlCreateCombo($Template1, 10, 10, 185, 20) Local $Button_Close = GUICtrlCreateButton("Close", 210, 170, 85, 25) Local $Button_Add1 = GUICtrlCreateButton("Set +1", 10, 170, 85, 25) GUICtrlSetData($Combo_template1, "2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48") GUISetState(@SW_SHOW, $hGUI) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $Button_Close ExitLoop Case $Button_Add1 Local $Val = Int(GUICtrlRead($Combo_template1)) GUICtrlSetData($Combo_template1, $Val >= 48 ? 48 : $Val + 1) Case $Combo_template1 ConsoleWrite("$Combo_template1=" & GUICtrlRead($Combo_template1) & @CRLF) EndSwitch If $Template1 <> GUICtrlRead($Combo_template1) Then $Template1 = GUICtrlRead($Combo_template1) ConsoleWrite("$Template1=" & $Template1 & @CRLF) EndIf WEnd GUIDelete($hGUI) EndFunc ;==>Example1 point
-
This would add typed items into the combo box whenever something is typed/pasted after a certain amount of time. The timer starts new whenever the data is different, and when it runs out, it writes the data into the combo box. Currently i have set the timer on 2 seconds. I took the base code from https://www.autoitscript.com/forum/topic/190196-add-element-in-a-combobox-if-its-not-in-the-combobox-data/ and added the timing functions. #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <MsgBoxConstants.au3> ; Create a Global variable to hold the combo data Global $sComboData = "" Global $hGui, $Cco, $cAdd $hGui = GUICreate("test ", 250, 100, -1, -1, $GUI_SS_DEFAULT_GUI) ; Create combo and load with saved data $Cco = GUICtrlCreateCombo("", 10, 10, 200, 20) GUICtrlSetData($Cco, $sComboData) ; Create a button to add new data $cAdd = GUICtrlCreateButton("Add", 10, 50, 80, 30) GUISetState() $oldC = GUICtrlRead($Cco) $Ctimer = TimerInit() $ccw = 0 While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $cAdd ; Add new data to the combo _AddComboData() $oldC = GUICtrlRead($Cco) $ccw = 0 Case $Cco ; Just to show that the data is selectable $ccw = 0 $oldC = GUICtrlRead($Cco) ConsoleWrite("Selected " & $oldC) EndSwitch If $oldC <> GUICtrlRead($Cco) Then $oldC = GUICtrlRead($Cco) ConsoleWrite("Data is different" & @CRLF) $Ctimer = TimerInit() $ccw = 1 EndIf If TimerDiff($Ctimer) > 2000 Then If $ccw > 0 Then ConsoleWrite("Writing data to the combo box" & @CRLF) _AddComboData() $oldC = GUICtrlRead($Cco) $ccw = 0 EndIf EndIf WEnd Func _AddComboData() ; Read the content of the combo edit $sComboSel = GUICtrlRead($Cco) ; Check if in saved data If Not StringInStr($sComboData, "|" & $sComboSel) Then ; If not then add to saved data and load into the combo $sComboData &= "|" & $sComboSel GUICtrlSetData($Cco, $sComboData) EndIf EndFunc ;==>_AddComboData1 point
-
Hello there, I hope this message finds you well. I am relatively new to AutoIt and have been exploring its capabilities for automating tasks on Windows. I have a specific project that I am working on, and I would greatly appreciate any guidance or advice from the experienced members of this community. I need to launch a specific web browser (preferably Chrome or Firefox) and navigate to the login page of the web application. The script should automatically fill in the username and password fields and submit the login form. The login page may include additional elements such as CAPTCHA, which could be a challenge to automate. After successfully logging in, the script should navigate through the web application to reach a specific page where the required data is displayed. What is the best approach to handle web automation with AutoIt for the aforementioned tasks? Are there any recommended libraries or tools that work well with AutoIt for web automation, particularly for handling dynamic web elements and CAPTCHA? Also, I have gone this post: https://www.autoitscript.com/forum/topic/205542-solved-extract-data-from-website-aws-devops-export-to-excel-moved/ which definitely helped me out a lot. Can anyone share sample scripts or code snippets that demonstrate similar automation processes? What are the common pitfalls I should be aware of when automating web interactions using AutoIt? Thank you in advance for your help and assistance.1 point
-
I hope you like it. #Region _GuiCtrlSetFont.au3 ;Copyrights to funkey !! #include <WinAPI.au3> OnAutoItExitRegister("_FontCleanUp") Global $ahFontEx[1] = [0] Func _GuiCtrlSetFont($controlID, $size, $weight = 400, $attribute = 0, $rotation = 0, $fontname= "", $quality = 2) Local $fdwItalic = BitAND($attribute, 1) Local $fdwUnderline = BitAND($attribute, 2) Local $fdwStrikeOut = BitAND($attribute, 4) ReDim $ahFontEx[UBound($ahFontEx) + 1] $ahFontEx[0] += 1 $ahFontEx[$ahFontEx[0]] = _WinAPI_CreateFont($size, 0, $rotation * 10, $rotation, $weight, _ $fdwItalic, $fdwUnderline, $fdwStrikeOut, -1, 0, 0, $quality, 0, $fontname) GUICtrlSendMsg($controlID, 48, $ahFontEx[$ahFontEx[0]], 1) EndFunc Func _FontCleanUp() For $i = 1 To $ahFontEx[0] _WinAPI_DeleteObject($ahFontEx[$i]) Next EndFunc #EndRegion Global $hGui1 = GuiCreate("AutoIt Main-GUI", 300, 340, 100, 100, -1, 0); For $i = 0 To 350 Step 30 GUICtrlCreateLabel("This is rotating", 50, 0, 300, 220, 0x201) _GuiCtrlSetFont(-1, 15, 1000, 1, $i) GUICtrlSetBkColor(-1, -2) Next GUICtrlCreateLabel("This is a vertical label", 10, 30,200, 200, 0x001) _GuiCtrlSetFont(-1, 15, 400, 1, -90) GUICtrlSetBkColor(-1, -2) GUICtrlCreateLabel("This too!!", 130, 50, 200, 200, 0x202) _GuiCtrlSetFont(-1, 15, 400, 1, 90) GUICtrlSetBkColor(-1, -2) GuiCtrlCreateButton("This is a cool button text", 10, 220, 275, 60, 0x0800); _GuiCtrlSetFont(-1, 20, 1000, 1, 8) GuiCtrlCreateCombo("Hello", 10, 290, 275, 80, 0x3, -1); _GuiCtrlSetFont(-1, 15, 1000, 1, -3) GUICtrlSetData(-1, "Item2|Item3") GuiSetState(@SW_SHOW, $hGui1); Do Until GUIGetMsg() = -31 point