Leaderboard
Popular Content
Showing content with the highest reputation on 01/08/2018 in all areas
-
I saw this code here: http://zoomquilt.org/ and here: http://arkadia.xyz and thought how this can be implemented in AutoIt. Here the results. The Zoomquilt: ;coded by UEZ build 2018-01-10, idea and images taken from http://zoomquilt.org/ ;thanks to spudw2k for the MouseZoom function #pragma compile(Icon, "c:\Program Files (x86)\AutoIt3\Icons\au3.ico") #AutoIt3Wrapper_Run_Au3Stripper=y #Au3Stripper_Parameters=/so /pe /rm #AutoIt3Wrapper_Run_After=del /f /q "%scriptdir%\%scriptfile%_stripped.au3" #include <GDIPlus.au3> #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> _GDIPlus_Startup() Global $hGUI, $iFPS = 0, $iShowFPS = 0, $bExit, $iW, $iH Global Const $sTitle = "GDI Image Zoom v2.1.2 coded by UEZ" AutoItSetOption("GUIOnEventMode", 1) Downloader() GDIPlus_ZoomImage() AutoItSetOption("GUIOnEventMode", 0) _GDIPlus_Shutdown() Func GDIPlus_ZoomImage($bMultimonitor = False) $bExit = False Local $i, $aImages[46], $hImage, $hObj ConsoleWrite("Loading images from local disk..." & @CRLF) Local $fTimer = TimerInit() For $i = 0 To UBound($aImages) - 1 $hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\Images\TheZoomquilt" & StringFormat("%02i.jpg", $i)) $aImages[$i] = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) _GDIPlus_ImageDispose($hImage) Next ConsoleWrite(UBound($aImages) & " images loaded in " & TimerDiff($fTimer) & " ms" & @CRLF) Local $tDim = DllStructCreate($tagBITMAP) DllCall("GDI32.dll", 'int', 'GetObject', 'int', $aImages[0], 'int', DllStructGetSize($tDim), 'ptr', DllStructGetPtr($tDim)) $iW = $tDim.bmWidth $iH = $tDim.bmHeight Local $hFullScreen = WinGetHandle("[TITLE:Program Manager;CLASS:Progman]"), $aFullScreen[4], $iW_Dt, $iH_Dt $aFullScreen = WinGetPos($hFullScreen) If $bMultimonitor Then $iW_Dt = $aFullScreen[2] $iH_Dt = $aFullScreen[3] Else $iW_Dt = @DesktopWidth $iH_Dt = @DesktopHeight $aFullScreen[0] = "" $aFullScreen[1] = "" EndIf $hGUI = GUICreate($sTitle, $iW_Dt, $iH_Dt, $aFullScreen[0], $aFullScreen[1], $WS_POPUP, $WS_EX_TOPMOST) GUISetState(@SW_SHOW, $hGUI) GUISetCursor(16, 1) ;create canvas elements Local Const $hDC = _WinAPI_GetDC($hGUI) Local Const $hHBitmap = _WinAPI_CreateCompatibleBitmap($hDC, $iW_Dt, $iH_Dt) Local Const $hDC_backbuffer = _WinAPI_CreateCompatibleDC($hDC) Local Const $DC_obj = _WinAPI_SelectObject($hDC_backbuffer, $hHBitmap) Local Const $hMemDC = _WinAPI_CreateCompatibleDC($hDC) _WinAPI_SetStretchBltMode($hDC_backbuffer, $STRETCH_DELETESCANS) Local Const $hCanvas = _GDIPlus_GraphicsCreateFromHDC($hDC_backbuffer) _GDIPlus_GraphicsSetSmoothingMode($hCanvas, $GDIP_SMOOTHINGMODE_HIGHQUALITY) _GDIPlus_GraphicsSetPixelOffsetMode($hCanvas, $GDIP_PIXELOFFSETMODE_HIGHQUALITY) Local Const $hBrush_Clr = _GDIPlus_BrushCreateSolid(0xFF000000), _ $hBrush_FPS = _GDIPlus_BrushCreateSolid(0xFFFFFFFF), _ $hFormat_FPS = _GDIPlus_StringFormatCreate(), _ $hFamily_FPS = _GDIPlus_FontFamilyCreate("Arial"), _ $hFont_FPS = _GDIPlus_FontCreate($hFamily_FPS, 8), _ $tLayout_FPS = _GDIPlus_RectFCreate(0, 0, 130, 16) $iFPS = 0 GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit_About") AdlibRegister("CalcFPS", 1000) Local $a[3], $b = 1, $c, $x, $e, $y, $w, $h, $w2 = $iW_Dt / 2, $h2 = $iH_Dt / 2, $q, $r If $iW_Dt > 1.5 * $iH_Dt Then $q = $iW_Dt $r = 0.75 * $iW_Dt Else $q = 1.5 * $iH_Dt $r = 0.75 * $iH_Dt EndIf Do For $e = 0 To 2 $a[$e] = $aImages[Mod(Floor($b) + $e, UBound($aImages))] Next $c = 2^(Mod($b, 1)) For $e = 0 To 2 $x = $w2 - $q / 2 * $c $y = $h2 - $r / 2 * $c $w = $q * $c $h = $r * $c $hObj = _WinAPI_SelectObject($hMemDC, $a[$e]) _WinAPI_StretchBlt($hDC_backbuffer, $x, $y, $w, $h, $hMemDC, 0, 0, $iW, $iH, $SRCCOPY) $c *= 0.5 Next $b += MouseZoom() IF $b < 0 Then $b = UBound($aImages) - $b _GDIPlus_GraphicsDrawStringEx($hCanvas, "FPS: " & $iShowFPS & " @ " & $iW_Dt & "x" & $iH_Dt & " px", $hFont_FPS, $tLayout_FPS, $hFormat_FPS, $hBrush_FPS) _WinAPI_BitBlt($hDC, 0, 0, $iW_Dt, $iH_Dt, $hDC_backbuffer, 0, 0, $SRCCOPY) $iFPS += 1 If $bExit Then ExitLoop Until Not Sleep(0) AdlibUnRegister("CalcFPS") ;release resources _GDIPlus_FontDispose($hFont_FPS) _GDIPlus_FontFamilyDispose($hFamily_FPS) _GDIPlus_StringFormatDispose($hFormat_FPS) _GDIPlus_BrushDispose($hBrush_Clr) _GDIPlus_BrushDispose($hBrush_FPS) _GDIPlus_GraphicsDispose($hCanvas) _WinAPI_SelectObject($hMemDC, $hObj) _WinAPI_DeleteDC($hMemDC) _WinAPI_SelectObject($hDC_backbuffer, $DC_obj) _WinAPI_DeleteDC($hDC_backbuffer) _WinAPI_DeleteObject($hHBitmap) _WinAPI_ReleaseDC($hGUI, $hDC) For $i = 0 To UBound($aImages) - 1 _WinAPI_DeleteObject($aImages[$i]) Next GUIDelete($hGUI) EndFunc ;==>GDIPlus_ZoomImage Func MouseZoom() ;https://www.arduino.cc/reference/en/language/functions/math/map/ Local $iInput = MouseGetPos(1), $iInMin = 0, $iInMax = @DesktopHeight, $iOutMin = 1, $iOutMax = -1, $iStep = 0.025 Return (($iInput - $iInMin) * ($iOutMax - $iOutMin) / ($iInMax - $iInMin) + $iOutMin) * $iStep EndFunc ;MouseZoom() Func _Exit_About() $bExit = True EndFunc ;==>_Exit_About Func CalcFPS() ;display FPS $iShowFPS = $iFPS $iFPS = 0 EndFunc ;==>CalcFPS Func Downloader() Local $i, $A = StringSplit("FUjD9hf gbHhxTR 8YyzJdR xP3aNkR 2Qi4fQr E6pW5Ky zmtWIBF Af7LtYp TuXy30d 3nKGLr2 hNoWscB mSBvv3K f4wJ70e mIt9XmM M4TkAyh P4L4qhd hNM6bTv VoT8JXM jqcGH0B DYVoN8n bOPQkOI NeaTfJ1 18ppMNr FZ3d8Jv HsoX2RP mjv4kzI 6rpJbef pySKauq WjNQYRV Ffooo8y Xei5XfD T5A415r LiV0VNB nGcwiO4 b1Gdjjy GE828iy eSQ7SLe 1mPyGgL GNtwJIr KxBlU7E aKXhms5 9Quu2wu Y07quDf r0yC5Qa 273fCkD 2wMyCUw FUjD9hf", " ", 2) Local $sURL For $i = 0 To UBound($A) - 1 If Not FileExists(@ScriptDir & "\Images\TheZoomquilt" & StringFormat("%02i.jpg", $i)) Then If Not FileExists(@ScriptDir & "\Images") Then DirCreate(@ScriptDir & "\Images") $sURL = "http://imgur.com/" & $A[Mod(20 + $i, 46)] & ".jpg" ConsoleWrite("Downloading " & $sURL & ": " & InetGet($sURL, @ScriptDir & "\Images\TheZoomquilt" & StringFormat("%02i.jpg", $i), 8) & " bytes" & @CRLF) ToolTip("Downloading images...Please wait! -> " & $i + 1 & " / " & UBound($A), MouseGetPos(0), MouseGetPos(1)) EndIf Next ToolTip("") EndFunc ;==>Downloader Arkadia: ;coded by UEZ build 2018-01-10, idea and images taken from http://arkadia.xyz ;thanks to spudw2k for the MouseZoom function #pragma compile(Icon, "c:\Program Files (x86)\AutoIt3\Icons\au3.ico") #AutoIt3Wrapper_Run_Au3Stripper=y #Au3Stripper_Parameters=/so /pe /rm #AutoIt3Wrapper_Run_After=del /f /q "%scriptdir%\%scriptfile%_stripped.au3" #include <GDIPlus.au3> #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> _GDIPlus_Startup() Global $hGUI, $iFPS = 0, $iShowFPS = 0, $bExit, $iW, $iH Global Const $sTitle = "GDI Image Zoom v2.2.1 coded by UEZ" AutoItSetOption("GUIOnEventMode", 1) Downloader() GDIPlus_ZoomImage() AutoItSetOption("GUIOnEventMode", 0) _GDIPlus_Shutdown() Func GDIPlus_ZoomImage($bMultimonitor = False) $bExit = False Local $i, $aImages[49], $hImage, $hObj ConsoleWrite("Loading images from local disk..." & @CRLF) Local $fTimer = TimerInit() For $i = 0 To UBound($aImages) - 1 $hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\Images\Arkadia" & $i & ".jpg") $aImages[$i] = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) _GDIPlus_ImageDispose($hImage) Next ConsoleWrite(UBound($aImages) & " images loaded in " & TimerDiff($fTimer) & " ms" & @CRLF) Local $tDim = DllStructCreate($tagBITMAP) DllCall("GDI32.dll", "int", "GetObject", "int", $aImages[0], "int", DllStructGetSize($tDim), "ptr", DllStructGetPtr($tDim)) $iW = $tDim.bmWidth $iH = $tDim.bmHeight Local $hFullScreen = WinGetHandle("[TITLE:Program Manager;CLASS:Progman]"), $aFullScreen[4], $iW_Dt, $iH_Dt $aFullScreen = WinGetPos($hFullScreen) If $bMultimonitor Then $iW_Dt = $aFullScreen[2] $iH_Dt = $aFullScreen[3] Else $iW_Dt = @DesktopWidth $iH_Dt = @DesktopHeight $aFullScreen[0] = "" $aFullScreen[1] = "" EndIf $hGUI = GUICreate($sTitle, $iW_Dt, $iH_Dt, $aFullScreen[0], $aFullScreen[1], $WS_POPUP, $WS_EX_TOPMOST) GUISetState(@SW_SHOW, $hGUI) GUISetCursor(16, 1) ;create canvas elements Local Const $hDC = _WinAPI_GetDC($hGUI) Local Const $hHBitmap = _WinAPI_CreateCompatibleBitmap($hDC, $iW_Dt, $iH_Dt) Local Const $hDC_backbuffer = _WinAPI_CreateCompatibleDC($hDC) Local Const $DC_obj = _WinAPI_SelectObject($hDC_backbuffer, $hHBitmap) Local Const $hMemDC = _WinAPI_CreateCompatibleDC($hDC) _WinAPI_SetStretchBltMode($hDC_backbuffer, $STRETCH_DELETESCANS) Local Const $hCanvas = _GDIPlus_GraphicsCreateFromHDC($hDC_backbuffer) _GDIPlus_GraphicsSetSmoothingMode($hCanvas, $GDIP_SMOOTHINGMODE_HIGHQUALITY) _GDIPlus_GraphicsSetPixelOffsetMode($hCanvas, $GDIP_PIXELOFFSETMODE_HIGHQUALITY) Local Const $hBrush_Clr = _GDIPlus_BrushCreateSolid(0xFF000000), _ $hBrush_FPS = _GDIPlus_BrushCreateSolid(0xFFFFFFFF), _ $hFormat_FPS = _GDIPlus_StringFormatCreate(), _ $hFamily_FPS = _GDIPlus_FontFamilyCreate("Arial"), _ $hFont_FPS = _GDIPlus_FontCreate($hFamily_FPS, 8), _ $tLayout_FPS = _GDIPlus_RectFCreate(0, 0, 130, 16) $iFPS = 0 GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit_About") AdlibRegister("CalcFPS", 1000) Local $a[3], $b = 1, $c, $x, $e, $y, $w, $h, $w2 = $iW_Dt / 2, $h2 = $iH_Dt / 2, $q, $r If $iW_Dt > 1.5 * $iH_Dt Then $q = $iW_Dt $r = 0.75 * $iW_Dt Else $q = 1.5 * $iH_Dt $r = 0.75 * $iH_Dt EndIf Do For $e = 0 To 2 $a[$e] = $aImages[Mod(Floor($b) + $e, UBound($aImages))] Next $c = 2^(Mod($b, 1)) For $e = 0 To 2 $x = $w2 - $q / 2 * $c $y = $h2 - $r / 2 * $c $w = $q * $c $h = $r * $c $hObj = _WinAPI_SelectObject($hMemDC, $a[$e]) _WinAPI_StretchBlt($hDC_backbuffer, $x, $y, $w, $h, $hMemDC, 0, 0, $iW, $iH, $SRCCOPY) $c *= 0.5 Next $b += MouseZoom() IF $b < 0 Then $b = UBound($aImages) - $b _GDIPlus_GraphicsDrawStringEx($hCanvas, "FPS: " & $iShowFPS & " @ " & $iW_Dt & "x" & $iH_Dt & " px", $hFont_FPS, $tLayout_FPS, $hFormat_FPS, $hBrush_FPS) _WinAPI_BitBlt($hDC, 0, 0, $iW_Dt, $iH_Dt, $hDC_backbuffer, 0, 0, $SRCCOPY) $iFPS += 1 If $bExit Then ExitLoop Until Not Sleep(0) AdlibUnRegister("CalcFPS") ;release resources _GDIPlus_FontDispose($hFont_FPS) _GDIPlus_FontFamilyDispose($hFamily_FPS) _GDIPlus_StringFormatDispose($hFormat_FPS) _GDIPlus_BrushDispose($hBrush_Clr) _GDIPlus_BrushDispose($hBrush_FPS) _GDIPlus_GraphicsDispose($hCanvas) _WinAPI_SelectObject($hMemDC, $hObj) _WinAPI_DeleteDC($hMemDC) _WinAPI_SelectObject($hDC_backbuffer, $DC_obj) _WinAPI_DeleteDC($hDC_backbuffer) _WinAPI_DeleteObject($hHBitmap) _WinAPI_ReleaseDC($hGUI, $hDC) For $i = 0 To UBound($aImages) - 1 _WinAPI_DeleteObject($aImages[$i]) Next GUIDelete($hGUI) EndFunc ;==>GDIPlus_ZoomImage Func MouseZoom() ;https://www.arduino.cc/reference/en/language/functions/math/map/ Local $iInput = MouseGetPos(1), $iInMin = 0, $iInMax = @DesktopHeight, $iOutMin = 1, $iOutMax = -1, $iStep = 0.025 Return (($iInput - $iInMin) * ($iOutMax - $iOutMin) / ($iInMax - $iInMin) + $iOutMin) * $iStep EndFunc ;MouseZoom() Func _Exit_About() $bExit = True EndFunc ;==>_Exit_About Func CalcFPS() ;display FPS $iShowFPS = $iFPS $iFPS = 0 EndFunc ;==>CalcFPS Func Downloader() Local $sURL, $i For $i = 0 To 48 If Not FileExists(@ScriptDir & "\Images\Arkadia" & $i & ".jpg") Then If Not FileExists(@ScriptDir & "\Images") Then DirCreate(@ScriptDir & "\Images") $sURL = "http://arkadia.xyz/images/arkadia" & $i & ".jpg" ConsoleWrite("Downloading " & $sURL & ": " & InetGet($sURL, @ScriptDir & "\Images\Arkadia" & $i & ".jpg", 8) & " bytes" & @CRLF) ToolTip("Downloading images...Please wait! -> " & $i + 1 & " / " & $i, MouseGetPos(0), MouseGetPos(1)) EndIf Next ToolTip("") EndFunc ;==>Downloader The missing images will be download and saved to script dir in folder images. Due to internal integer format of the GDI functions the screen is little bit wobbling. Happy watching.2 points
-
How does pixelsearch work?
JLogan3o13 and one other reacted to Somerset for a topic
There is a help file?2 points -
NOTE: TOPIC HAS BEEN MERGED TO HERE: MapIt Quest I am currently developing NPCs they cannot yet be added. Items only exist in database. Enemies only in sprite. This project has been on the shelf a couple years. I decided to learn DLLStruct at the beginning of this project. I'm not sure if using them was a good idea or not. I'm open to converting them to pure array and Enum. Developing multiplayer system UDP clients / server. I'm looking for some advice on how to setup the packets. I was thinking the best way was to convert packets to Hex and convert back at the destination. That's probably the way I have it setup. Anyhow they all talk to each other, clients and server. Where the avatars appear on screens doesn't work. My Enums are used for data members of arrays. I exclude the 'g' even though they are all Global. I put the array names they describe in the Enum: ePlayer_x. In some cases I abbreviate the array name; aWorld_info probably has: aWorld_info[eWi_layers] Most gaming things are done better with a nice engine: GameMaker, Unity, Unreal. My buddy made a time machine in BASIC. I know you can make a better time machine in other languages, but there is something to be said for doing it in BASIC. Many things are ugly with this, just broken, or extraneous blocks of code I threw together for some one-off task. I put this here to see if it generates interest. I'm happy to change this thing around. I do many things in favor of speed, but I know some of it's crap. Package contains a Server and a Map Editor. The Map Editor is meant to be able to add and edit: World Files, worlds have 2 layers. 0.txt background 1.txt forground. The files are formatted with a header: width, height, and the largest tile number. The largest tile number is used to pad the world files. So that the world files could be edited by hand. WorldN Tile X_Y.txt (a subset cord of tile to specify frame): World Tile X_Y is stored in a separate file per layer so that the world layer files remain pretty. World Directory Structure: Example: World_1_Overworld. In folder above we can notice only layer 1 has a Tile_X_Y file. This is because atm only trees use the system and trees are foreground. Areas: areas are to subdivide worlds in effort to section the worlds and divide lists for: hotspots, NPCs, Items, and area properties such as: Out-of-Bounds: Destination and Repeat Tile, enemy encounters, etc.. Areas have: Global Enum $eArea_x, $eArea_y, $eArea_w, $eArea_h, _ ; Area World Bound Rect $eArea_ob_tile, $eArea_ob_world, $eArea_ob_x, $eArea_ob_y, _ ; Out of Bounds Repeat Tile and World Destination if Out of Bounds $eArea_hotspots, $eArea_items, $eArea_NPCs ; Total Hotspots per Area, Items and People Hotspots: hotspots are locations on the board that relocate the player Global Enum $eHotspot_x, $eHotspot_y, _; the spot in world that moves player $eHotspot_dest_world, $eHotspot_dest_x, $eHotspot_dest_y; the destination world and position Board: A rectangle of world tiles is pre-drawn on aBoard[layer_max] centered on player, you can change the size to consume less RAM but requires drawing world to board more often. Animated Background: Before anything is drawn a moving BG image is drawn. Creating beautiful water AI. So if no tiles are drawn from world, BG water animation is shown. Map Editor should be able to test all of the systems of the game: Player, Worlds, Areas, Hotspots, NPCs, Items, Shops, Battles, Netplay, etc.. (Not all systems exist yet) Download site: http://songersoft.com/programming/dw3_remake/dw3_remake_about.phtml It's going to say that the files might be malicious. Probably b/c of the DLLs and I hosted an unmoderated forum from the site years ago were people posted malicious links. Let me know if it's malicious! PS: I tried posting the source but I keep getting errors. I think the source might be too large to post. 6308 lines. Idk.1 point
-
That wasn't quite the answer i was looking for, something more in the lines of: The error checking prevents a "critical" error if a pixel is not found, because without it, it's gonna crash trying to read a non existing variable. But i think you got that.1 point
-
HTML Pretty Print UDF
natedog102 reacted to genius257 for a topic
Hi @natedog102. So i took a stab at it for 30mins, and got it to work with google html. (I was doing something related anyway, and i got to address a problem in my hTMLParser.au3 lib i can implement when i find a way to make it less messy) the file you need to run in the same folder as the two other files is prettyhtml.au3 the html you need to parse, currently need to be in a file named: prettyhtml.txt the output will be in the same folder and be named: prettyhtml_output.txt Hope you can use it. Btw. there might be some strange that can give you trouble still, and if you find them, be sure to let me know, i will appreciate it. prettyhtml.au3 HTMLParser.au3 TokenList.au3 Edit: credit to @Zedna for the StringRepeat Function1 point -
How does pixelsearch work?
Earthshine reacted to Jos for a topic
Funny to see you even interpret that statement as if it is about the others and not about you asking for cookies like a child. Over and out.1 point -
How does pixelsearch work?
Earthshine reacted to Jos for a topic
Great and all of that without the @error checking ... wish you all the luck you can get and hope that pixel is found each time or you will be screwed. I was fun to deal with you and rest assured I will not bother you any further and leave you the code slaves that are willing to help people that fail to think for themselves. Jos1 point -
Because it is the answer to your question and to be as blunt as you: What about you kick you brains into gear and start thinking for a bit in stead of constantly asking for cookies ? So what is it going to be? Answer my last question or being defensive because I am hurting your feeling? (Which I am not, just trying to sort it issues out yourself in stead of actually giving those cookies ) Jos1 point
-
Ok... BACK to the helpfile: which part of this extensive part of the helpfile code did you NOT implement? ; Find a pure red pixel in the range 0,0-20,300 Local $aCoord = PixelSearch(0, 0, 20, 300, 0xFF0000) If Not @error Then MsgBox($MB_SYSTEMMODAL, "", "X and Y are: " & $aCoord[0] & "," & $aCoord[1]) EndIf ... and WHY is that so damn important? Jos1 point
-
Issue with windows "Windows Security" in Windows 10
PunkoHead reacted to Earthshine for a topic
disable the LSA. I DO NOT recommend this. I leave it on and UAC on all client machines, always.1 point -
Well, just detect the type of OS @OSVersion and act uppon that.1 point
-
@PunkoHead: I think the op knows how it works, seems he asked specifically the way it works @Jos: Ah! you are of course correct, i overlooked the '<' I just need to switch the values to search in the other direction. So in order to search from left to right i need to set the left value as the smaller one, and the right as the bigger. And in searching from right to left, the opposite, is that it?1 point
-
Hello, you can always use the: WinActivate("My CS Server Window") And in regards to the resizing, yes, there is a way and you can read all about it here. Check the example: WinMove($hWnd, "", 0, 0, 200, 200)1 point
-
_IEQuit All tabs.
XaelloNegative reacted to Danp2 for a topic
You could use _IEQuit in a loop, like this -- #include <IE.au3> Const $navOpenInNewTab = 0x0800 Local $oIE = _IECreate('http://www.google.com/') $oIE.Navigate2('http://www.yahoo.com/', $navOpenInNewTab) $oIE.Navigate2('http://autoitforum.com/', $navOpenInNewTab) While 1 $oIE = _IEAttach ("", "instance", 1) If @error = $_IEStatus_NoMatch Then ExitLoop _IEQuit($oIE) WEnd1 point -
Mostly it execute expression (Like Execute("$F")) if it find error ( Variable not declared ). it return a non zero @error rather then crashing the script.1 point
-
Here is an Example. #AutoIt3Wrapper_Run_AU3Check=n Func AssignCOMEnums($sApp, $bShow = 0) Local $oTLA, $oTLI, $CstEnum, $CstObj, $oApp $oApp = ObjCreate($sApp) $oTLA = ObjCreate("TLI.TLIApplication") If IsObj($oTLA) Then ConsoleWrite("objName of bjCreate(""TLI.TLIApplication"") is " & ObjName($oTLA) & @CRLF) $oTLI = $oTLA.InterfaceInfoFromObject($oApp).Parent Else Local Const $sCLSID_TLI = "{8B21775E-717D-11CE-AB5B-D41203C10000}" Local Const $sIID_ITLI = "{8B21775D-717D-11CE-AB5B-D41203C10000}" $oTLA = ObjCreateInterface($sCLSID_TLI, $sIID_ITLI) $oTLI = $oTLA.InterfaceInfoFromObject($oApp).Parent If isobj($oTLA) Then ConsoleWrite("$oTLA object name is " & ObjName($oTLA) & @CRLF) Else ConsoleWrite("$oTA is still not an object"&@CRLF) exit EndIf EndIf For $CstEnum In $oTLI.Constants ConsoleWrite($CstEnum.Name & @CRLF) If "_" <> StringLeft($CstEnum.Name, 1) Then For $CstObj In $CstEnum.Members Assign( $CstObj.Name, $CstObj.Value, 2) If $bShow Then ConsoleWrite("$" & $CstObj.Name & " = " & Eval($CstObj.Name) & @CRLF) Next EndIf ExitLoop Next EndFunc ;==>AssignCOMEnums Local $objx = "Excel.application" AssignCOMEnums($objx, 1) MsgBox(0,"","$xlDrawingObject IsDeclared = " & IsDeclared("xlDrawingObject") & @CRLF & "$xlDrawingObject Value= " & $xlDrawingObject) Saludos1 point
-
1 point
-
Extract input to an Excel file
benners reacted to KickStarter15 for a topic
@benners, This is a work of genius with 1000% above level of coding.... I never though you could make it more interesting. REALLY , higher with thumbs up is what you are benners. This is the first time I gave 3 likes in one person in one thread. Worth to have it!!!! Thank you very very very much benners, you've made my day complete with a smile. Indeed a nightmare, but an angel. I really need to learn a lot, I mean a lotsssssss!!! hahaha. When can I have this kind of nightmare. Func GetFullName($sUserName) ; I can't test this ;~ $strComputer = 'localhost' ; do you need to specify this???? ;~ Local $objWMIService = ObjGet('winmgmts:\\' & $strComputer & '\root\CIMV2') Local $objWMIService = ObjGet('winmgmts:\\localhost\root\CIMV2') Local $colItems = $objWMIService.ExecQuery('SELECT * FROM Win32_UserAccount WHERE Name = '' & $sUserName & ''', 'WQL', 0x10 + 0x20) If Not IsObj($colItems) Then Return SetError(1, 0, '') For $objItem In $colItems Return $objItem.FullName Next EndFunc ;==>GetFullName Full name is not showing, but I think I can manage this.1 point -
[GUI] Gui Function Help Needed
DynamicRookie reacted to careca for a topic
When it gets to: Func _D4N4M11CCKR010K133() The variable $StringVal116 = 0 So, because you have a condition: If _IsPressed('4B') And $StringVal116 = 1 Then It's never gonna go past this and jump to ExecuteFunction_0_0_0_1 where it sends the inputbox contents.1 point -
DragonWarrior3_Remake
Xandy reacted to DynamicRookie for a topic
I never meant to say that. I mean that it didn't ran in my PC.1 point -
Your map editor has done nothing for my d&d.1 point
-
Extract input to an Excel file
KickStarter15 reacted to benners for a topic
Getting quite addictive this. Added the option of choosing from the two layouts you added in post #9. Was a nightmare but interesting learning #Region #### Includes ################################ #include <ButtonConstants.au3> #include <ColorConstants.au3> #include <EditConstants.au3> #include <Excel.au3> #include <FontConstants.au3> #include <GUIConstantsEx.au3> #include <GUIScrollbars_Ex.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <Array.au3> #EndRegion #### Includes ################################ Opt('GUIOnEventMode', 1) HotKeySet('{ESC}', 'CloseProgram') #Region #### Globals ################################# ; these are integers that relate to where the controliDs are located in $g_aidControls. ; The control ID can be retrieved like so, $g_aidControls[$EMPPROCESS_INP] Global Enum _ ; values are 0 to 13 $FRONTMATTERGUI, _ ;_ gui 1 $BODYMATTERGUI, _ ;_ gui 2 $BACKMATTERGUI, _ ;_ gui 3 $TABCOUNT, _ ; #### IMPORTANT #### this must be after the last gui. it signifies how many tabs there will be and is used in other functions $EMPNUMBER_INP, _ ;_ employee number input id $EMPNAME_INP, _ ;_ employee name input id $EMPPROCESS_INP, _ ;_ employee process input id $MYSTERY_LBL, _ ;_ some label I don't know if you use id $AGREE_CHK, _ ;_ I agree checkbox id $ACCEPT_CHK, _ ;_ accept checkbox id $REJECT_CHK, _ ;_ reject checkbox id $LAYOUTONE_RDO, _ ;_ radio button for layout 1 selection $SUBMIT_BTN, _ ;_ submit button id $MAIN_TAB, _ ;_ main tab id $ARRAYMAXROWS ;_ number of rows to give the array its 0 based ; create the array to hold the remaining controlIDs. These can be referenced ; later when writing their values to the excel sheet Global $g_aidControls[$ARRAYMAXROWS] ; create the arrays to hold the all controlIDs that will be created on the tab guis by CreateTabGUIs() called by Draw_Tabs() function ; These can be referenced later when writing their values to the excel sheet Global _ $aid_FrontMatterGUI = '', _ $aid_BodyMatterGUI = '', _ $aid_BackMatterGUI = '' ; these are the tab names and will be used as the spreadsheet names when the report is submitted ; these have the same value as the Global Enum $FRONTMATTERGUI to $BACKMATTERGUI and are used in varios functions Global $g_asTabNames[$TABCOUNT] = [ _ ; values are 0 to 2 'Front Matter', _ 'Body Matter', _ 'Back Matter'] ; these are integers that relate to where the rows are for each set of controls in the $aid_FrontMatterGUI array etc ; they are also the same values as their matching strings index in the $g_asTabHeaderText array Global Enum _ ; values are 0 to 6 $ENTRYS_COL, _ $NA_COL, _ $NOERROR_COL, _ $WITHERROR_COL, _ $REMARKS_COL, _ $ARRAYMAX_COLS ; this is the array that holds the tab header text strings. These are written to the first row of the array that matches the tab and gui ; I.E - ; Tab = 'Front Matter' ; Array with the controlIDs = $aid_FrontMatterGUI Global $g_asTabHeaderText[$ARRAYMAX_COLS] = [ _ ; 0 based array 'Entry(s)', _ 'N/A', _ 'No Error', _ 'With Error', _ 'Remarks'] Global $g_iMultipleSheets = 1 Global _ $g_sHeaderCells = '', _ $g_sSectionCells = '', _ $g_sTabNameCells = '' #EndRegion #### Globals ################################# Draw_GUI() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch Sleep(50) WEnd ; create an excel range from 2 numbers Func CellRange_CreateFromInteger($i_Start, $i_End) ; convert any numbers to excel column letters Return _Excel_ColumnToLetter($i_Start) & ':' & _Excel_ColumnToLetter($i_End) EndFunc ;==>CellRange_CreateFromInteger Func CellRange_CreateFromString($s_Range, $v_AddRange) ; if $v_AddRange is a number then convert the number to a letter for the range If IsNumber($v_AddRange) Then $v_AddRange = _Excel_ColumnToLetter($v_AddRange) ; trim any leading\trailing comma symbols before splitting $s_Range = StringRegExpReplace($s_Range, "\A[,]+|[,]+\Z", "") ; split the comma delimited range Local $as_Split = StringSplit($s_Range, ',') ; loop through the array For $i = 1 To $as_Split[0] ; update the array element $as_Split[$i] = $as_Split[$i] & ':' & StringRegExpReplace($as_Split[$i], '[[:alpha:]]+', $v_AddRange) Next ; return a string that will be used as a cell range Return _ArrayToString($as_Split, ',', 1) EndFunc ;==>CellRange_CreateFromString Func CellRange_GetValues($s_Range = 'A') ; set the path to the file that has the values for the inputs Local $s_ExcelFile = @ScriptDir & '\Sample.xlsx' ; #### add some error checking for these excel functions #### Local $o_Excel = _Excel_Open(False) Local $o_WorkBook = _Excel_BookOpen($o_Excel, $s_ExcelFile) Local $as_RangeRead = _Excel_RangeRead($o_WorkBook, Default, $o_WorkBook.ActiveSheet.Usedrange.Columns($s_Range), 2) _Excel_Close($o_Excel) ;~ _ArrayDisplay($as_RangeRead, 'CellRange_GetValues') ; for debugging Return $as_RangeRead EndFunc ;==>CellRange_GetValues Func CellRange_ResetGlobalValues() $g_sHeaderCells = '' $g_sSectionCells = '' $g_sTabNameCells = '' EndFunc ;==>CellRange_ResetGlobalValues Func CloseProgram() Exit EndFunc ;==>CloseProgram ; create an array of values that are read from the controls on the tabs GUI Func CreateArrayOfControlValues(ByRef $aid_ControlID, $i_Row) Local $v_Value = '' Local $s_BoldCells = '' ; loop through the array columns For $i = $ENTRYS_COL To $REMARKS_COL ; get the value from the supplied array $v_Value = $aid_ControlID[$i_Row][$i] ; check if the value is a controlID If IsNumber($v_Value) Then If Not $v_Value Then ; it's 0 so no control to read $v_Value = '' ; set a blank string Else $v_Value = GUICtrlRead($aid_ControlID[$i_Row][$i]) ; assume it's a header or heading indentifier string If StringIsUpper(StringRegExpReplace($v_Value, '[^A-Za-z]', '')) Then $g_sSectionCells &= 'A' & $i_Row + 1 & ',' If StringInStr($v_Value, $g_asTabHeaderText[0]) Then $g_sHeaderCells &= 'A' & $i_Row + 1 & ',' EndIf Else ; assume it's a tab name $aid_ControlID[$i_Row][$i] = $v_Value If StringInStr($v_Value, $g_asTabHeaderText[0]) Then $g_sHeaderCells &= 'A' & $i_Row + 1 & ',' If StringInStr(_ArrayToString($g_asTabNames, '|'), $v_Value) Then $g_sTabNameCells &= 'A' & $i_Row + 1 & ',' ExitLoop EndIf ; do different things based on the specified control If $i = $ENTRYS_COL Or $i = $REMARKS_COL Then ; these are input controls ; write the value to the array $aid_ControlID[$i_Row][$i] = $v_Value Else ; these are checkbox controls ; get the checked state of the control $aid_ControlID[$i_Row][$i] = GetCheckBoxValue($aid_ControlID[$i_Row][$i]) EndIf Next EndFunc ;==>CreateArrayOfControlValues ; create the scrolling guis and their controls that go on each of the tabs Func CreateTabGUIs(ByRef $as_RangeRead, $i_ArrayRow, $h_MainGUI) ; create the gui for the controls and add it to the global controls array $g_aidControls[$i_ArrayRow] = GUICreate('', 770, 370, 23, 270, $WS_POPUP, $WS_EX_MDICHILD, $h_MainGUI) GUISetBkColor($COLOR_WHITE) ; create the temp array. This will hold all the controlIDs Local _ $aid_Temp[70][$ARRAYMAX_COLS] = [[0]] ; this is a 0 based array Local _ $s_Value = '' ; value to give the control Local _ $i_ArrayRowCount = 0 ; keeps track of number of array rows (controls rows added) Local _ ; variables for the control spacing $i_Left = 0, _ ;_ starting left position $i_Rows = 60, _ ;_ initial number of rows $i_Spacing = 60, _ ;_ control padding $i_Top = 18 ;_ initial top position For $i = 0 To UBound($aid_Temp) - 1 ; 0 to 70 rows of controls . if you add more this number will need to change ; get the value to add to the control from the array returned by CellRange_GetValues() $s_Value = $as_RangeRead[$i][$i_ArrayRow] ; array is 0 based and has 53 elements filled ; don't create anymore controls if the value is blanks If Not $s_Value Then ExitLoop ; calculate additional spacing $i_Left = (Int($i / $i_Rows)) + $i_Spacing $i_Top = (30.7 * Mod($i, $i_Rows)) ; - 30 ; check if the string is upper case. Strip any none letter characters out for testing ; as digits/punctuation/whitespace will cause StringIsUpper() to return 0. If StringIsUpper(StringRegExpReplace($s_Value, '[^A-Za-z]', '')) Then ; assume its a heading ; draw the input and add the controlID to the correct gui array $aid_Temp[$i][$ENTRYS_COL] = GUICtrlCreateLabel($s_Value, $i_Left - 50, $i_Top, 730, 20, $WS_EX_CLIENTEDGE) GUICtrlSetFont(-1, 8, 800) GUICtrlSetColor(-1, $COLOR_BLACK) GUICtrlSetBkColor(-1, $COLOR_SILVER) ; set the other columns to 0 as there are no other controls being added $aid_Temp[$i][$NA_COL] = 0 $aid_Temp[$i][$NOERROR_COL] = 0 $aid_Temp[$i][$WITHERROR_COL] = 0 $aid_Temp[$i][$REMARKS_COL] = 0 Else ; assume it's a sub ; draw the input $aid_Temp[$i][$ENTRYS_COL] = GUICtrlCreateInput($s_Value, $i_Left - 50, $i_Top, 155, 20, BitOR($GUI_SS_DEFAULT_INPUT, $ES_READONLY), $WS_EX_TRANSPARENT) ; use an input GUICtrlSetBkColor(-1, $COLOR_WHITE) ;~ $aid_Temp[$i][0] = GUICtrlCreateLabel($s_Value, $i_Left - 50, $i_Top, 155, 40) ; use a label if you want ; draw the N/A check box $aid_Temp[$i][$NA_COL] = GUICtrlCreateCheckbox('', $i_Left + 165, $i_Top, 15, 20) ; draw the no error check box $aid_Temp[$i][$NOERROR_COL] = GUICtrlCreateCheckbox('', $i_Left + 260, $i_Top, 15, 20) ; draw the with error check box $aid_Temp[$i][$WITHERROR_COL] = GUICtrlCreateCheckbox('', $i_Left + 355, $i_Top, 15, 20) ; draw the edit control $aid_Temp[$i][$REMARKS_COL] = GUICtrlCreateEdit('', $i_Left + 440, $i_Top, 240, 24, BitOR($ES_AUTOVSCROLL, $ES_WANTRETURN)) EndIf $i_ArrayRowCount += 1 ; increase the number of rows added to the array Next ; add scroll bars to the current gui _GUIScrollbars_Generate($g_aidControls[$i_ArrayRow], 0, 2000) ; redim the array to remove any blanks ReDim $aid_Temp[$i_ArrayRowCount][$ARRAYMAX_COLS] ;~ _ArrayDisplay($aid_Temp, 'CreateTabGUIs ($aid_Temp)') ; for debugging ; returns a 0 based array of controlIDs Return $aid_Temp EndFunc ;==>CreateTabGUIs Func Draw_GUI() Local $h_MainGUI = GUICreate('Test Form', 820, 740, -1, -1) GUISetBkColor(0x38A7D2) GUISetOnEvent($GUI_EVENT_CLOSE, 'CloseProgram') GUICtrlCreatePic(@ScriptDir & '\Image.jpg', 690, 15, 120, 120) GUICtrlCreateLabel('Welcome: ' & GetFullName(@UserName), 17, 135, 500, 16) GUICtrlSetColor(-1, $COLOR_WHITE) GUICtrlSetFont(-1, 9, $FW_BOLD) #Region #### Main Menu ########################### Local $id_Menu = GUICtrlCreateMenu('File') GUICtrlCreateMenuItem('Close', $id_Menu) GUICtrlSetOnEvent(-1, 'CloseProgram') GUICtrlCreateMenuItem('Export', $id_Menu) GUICtrlSetOnEvent(-1, 'MainMenu_FileExport') $id_Menu = GUICtrlCreateMenu('Edit') GUICtrlSetState(-1, $GUI_Disable) $id_Menu = GUICtrlCreateMenu('Option') GUICtrlSetState(-1, $GUI_Disable) $id_Menu = GUICtrlCreateMenu('View') GUICtrlCreateMenuItem('Exit', $id_Menu) GUICtrlSetState(-1, $GUI_Disable) GUICtrlSetOnEvent(-1, 'MainMenu_ViewExit') $id_Menu = GUICtrlCreateMenu('Help') GUICtrlCreateMenuItem('About', $id_Menu) GUICtrlSetOnEvent(-1, 'MainMenu_HelpAbout') #EndRegion #### Main Menu ########################### #Region #### Employee Info ####################### GUICtrlCreateGroup('Employee Information', 16, 8, 281, 121) GUICtrlCreateLabel('Emp#:', 33, 35, 35, 17) $g_aidControls[$EMPNUMBER_INP] = GUICtrlCreateInput('1234567', 72, 32, 217, 21) GUICtrlSetState(-1, $GUI_Disable) GUICtrlCreateLabel('Name:', 33, 59, 35, 17) $g_aidControls[$EMPNAME_INP] = GUICtrlCreateInput(GetFullName(@UserName), 72, 56, 217, 21) GUICtrlSetState(-1, $GUI_Disable) GUICtrlCreateLabel('Process:', 24, 83, 45, 17) $g_aidControls[$EMPPROCESS_INP] = GUICtrlCreateInput('First Process', 72, 80, 217, 21) GUICtrlSetState(-1, $GUI_Disable) GUICtrlCreateGroup('', -99, -99, 1, 1) #EndRegion #### Employee Info ####################### #Region #### whatever this is #################### GUICtrlCreateLabel('AID:', 25, 170, 25, 17) GUICtrlSetFont(-1, 10, $FW_BOLD) $g_aidControls[$MYSTERY_LBL] = GUICtrlCreateLabel('ABZ123456', 60, 170, 90, 17) ; remove this if you don't alter the text GUICtrlSetColor(-1, $COLOR_WHITE) GUICtrlSetFont(-1, 10, $FW_BOLD) #EndRegion #### whatever this is #################### #Region #### Confirmation Checkboxes ############# $g_aidControls[$AGREE_CHK] = GUICtrlCreateCheckbox(' I agree that I have checked the entry(s) above.', 25, 655, 265, 17) $g_aidControls[$ACCEPT_CHK] = GUICtrlCreateCheckbox(' Accept', 25, 675, 60, 17) GUICtrlCreateLabel('*', 85, 680, 40, 17) GUICtrlSetColor(-1, $COLOR_RED) GUICtrlSetFont(-1, 10, $FW_BOLD) $g_aidControls[$REJECT_CHK] = GUICtrlCreateCheckbox(' Reject', 25, 695, 60, 17) GUICtrlCreateLabel('*', 85, 695, 40, 17) GUICtrlSetColor(-1, $COLOR_RED) GUICtrlSetFont(-1, 10, $FW_BOLD) #EndRegion #### Confirmation Checkboxes ############# #Region #### Submit Report Group ################# $Group1 = GUICtrlCreateGroup("Submit Report", 600, 647, 200, 65) $g_aidControls[$LAYOUTONE_RDO] = GUICtrlCreateRadio("Layout 1", 615, 665, 70, 17) GUICtrlSetState(-1, $GUI_CHECKED) GUICtrlSetOnEvent(-1, 'Layout1_Selected') GUICtrlCreateRadio("Layout 2", 615, 685, 70, 17) GUICtrlSetOnEvent(-1, 'Layout2_Selected') $g_aidControls[$SUBMIT_BTN] = GUICtrlCreateButton('Submit Report', 690, 667, 100, 33) GUICtrlSetOnEvent(-1, 'Report_Submit') GUICtrlCreateGroup("", -99, -99, 1, 1) #EndRegion #### Submit Report Group ################# #Region #### Create Tabs ######################### Draw_Tabs($h_MainGUI) #EndRegion #### Create Tabs ######################### GUISetState(@SW_SHOW, $h_MainGUI) ; show the main gui Sleep(80) ; add a sleep to try and get them to show at the same time GUISetState(@SW_SHOW, $g_aidControls[$FRONTMATTERGUI]) ; show the first tab gui EndFunc ;==>Draw_GUI ; draw the group on controls that sit above the tab guis Func Draw_TabHeaders() ; this draws the headers over the columns on the tab gui. The values are pulled from the $g_asTabHeaderText array GUICtrlCreateGroup('', 30, 215, 755, 50) GUICtrlCreateLabel($g_asTabHeaderText[$ENTRYS_COL], 50, 232, 80, 20, BitOR($SS_CENTER, $SS_CENTERIMAGE, $WS_BORDER)) GUICtrlCreateLabel($g_asTabHeaderText[$NA_COL], 238, 232, 40, 20, BitOR($SS_CENTER, $SS_CENTERIMAGE, $WS_BORDER)) GUICtrlCreateLabel($g_asTabHeaderText[$NOERROR_COL], 315, 232, 70, 20, BitOR($SS_CENTER, $SS_CENTERIMAGE, $WS_BORDER)) GUICtrlCreateLabel($g_asTabHeaderText[$WITHERROR_COL], 405, 232, 85, 20, BitOR($SS_CENTER, $SS_CENTERIMAGE, $WS_BORDER)) GUICtrlCreateLabel($g_asTabHeaderText[$REMARKS_COL], 590, 232, 90, 20, BitOR($SS_CENTER, $SS_CENTERIMAGE, $WS_BORDER)) EndFunc ;==>Draw_TabHeaders Func Draw_Tabs($h_MainGUI) ; create the main tab control and add it's ID to the control array $g_aidControls[$MAIN_TAB] = GUICtrlCreateTab(20, 190, 780, 455, $WS_EX_MDICHILD) GUICtrlSetOnEvent(-1, 'TabChange') ; do summat on tab change ; get the strings that will populate the gui controls from the excel sheet. These will be the "Entry{s}" ; set the range as the first column 'A', to the last column that contains the layout for the guis (currently 'C') ; ### add some error checking for CellRange_GetValues #### Local $as_RangeRead = CellRange_GetValues(CellRange_CreateFromInteger($FRONTMATTERGUI + 1, $TABCOUNT)) ; loop to create the required number of tabs, guis and their controls For $i = $FRONTMATTERGUI To $TABCOUNT - 1 ; - 1 because $g_asTabNames is a 0 based array GUICtrlCreateTabItem($g_asTabNames[$i]) ; create the headers for each tab. These are listed in $g_asTabHeaderText Draw_TabHeaders() Switch $i Case $FRONTMATTERGUI ; gui 1 ; create the array containing the controlIDs. returns a 0 based array of controlIDs $aid_FrontMatterGUI = CreateTabGUIs($as_RangeRead, $i, $h_MainGUI) Case $BODYMATTERGUI ; gui 2 ; create the array containing the controlIDs $aid_BodyMatterGUI = CreateTabGUIs($as_RangeRead, $i, $h_MainGUI) Case $BACKMATTERGUI ; gui 3 ; create the array containing the controlIDs $aid_BackMatterGUI = CreateTabGUIs($as_RangeRead, $i, $h_MainGUI) EndSwitch ; switch to the main gui and tab after creating the new guis or else the control creation gets bollocksed Up ; and the tabs or controls are not visible GUISwitch($h_MainGUI, $g_aidControls[$MAIN_TAB]) Next GUICtrlCreateTabItem('') EndFunc ;==>Draw_Tabs ; get the state of the checkbox Func GetCheckBoxValue($id_ControlID) If GUICtrlRead($id_ControlID) = $GUI_CHECKED Then Return 'Checked' Return '' EndFunc ;==>GetCheckBoxValue Func GetFullName($sUserName) ; I can't test this ;~ $strComputer = 'localhost' ; do you need to specify this???? ;~ Local $objWMIService = ObjGet('winmgmts:\\' & $strComputer & '\root\CIMV2') Local $objWMIService = ObjGet('winmgmts:\\localhost\root\CIMV2') Local $colItems = $objWMIService.ExecQuery('SELECT * FROM Win32_UserAccount WHERE Name = '' & $sUserName & ''', 'WQL', 0x10 + 0x20) If Not IsObj($colItems) Then Return SetError(1, 0, '') For $objItem In $colItems Return $objItem.FullName Next EndFunc ;==>GetFullName Func Layout1_Selected() $g_iMultipleSheets = 1 EndFunc ;==>Layout1_Selected Func Layout2_Selected() $g_iMultipleSheets = 0 EndFunc ;==>Layout2_Selected Func MainMenu_FileExport() ; add commands later EndFunc ;==>MainMenu_FileExport Func MainMenu_HelpAbout() ; add commands later EndFunc ;==>MainMenu_HelpAbout Func MainMenu_ViewExit() ; add commands later EndFunc ;==>MainMenu_ViewExit Func TabChange() Switch GUICtrlRead($g_aidControls[$MAIN_TAB]) Case $FRONTMATTERGUI ; Front Matter tab GUISetState(@SW_SHOW, $g_aidControls[$FRONTMATTERGUI]) GUISetState(@SW_HIDE, $g_aidControls[$BODYMATTERGUI]) GUISetState(@SW_HIDE, $g_aidControls[$BACKMATTERGUI]) Case $BODYMATTERGUI ; body Matter tab GUISetState(@SW_HIDE, $g_aidControls[$FRONTMATTERGUI]) GUISetState(@SW_SHOW, $g_aidControls[$BODYMATTERGUI]) GUISetState(@SW_HIDE, $g_aidControls[$BACKMATTERGUI]) Case $BACKMATTERGUI ; back matter tab GUISetState(@SW_HIDE, $g_aidControls[$FRONTMATTERGUI]) GUISetState(@SW_HIDE, $g_aidControls[$BODYMATTERGUI]) GUISetState(@SW_SHOW, $g_aidControls[$BACKMATTERGUI]) EndSwitch EndFunc ;==>TabChange ; gets the currently selected layout type for the report Func Report_GetLayout() ; return the state of the layout 1 radio button If GUICtrlRead($g_aidControls[$LAYOUTONE_RDO]) = $GUI_CHECKED Then Return 1 Return 2 EndFunc ;==>Report_GetLayout ; submit your report Func Report_Submit() SplashTextOn("submit", "Submitting report...", 300, 50, -1, -1, $DLG_NOTITLE + $DLG_TEXTVCENTER, '', '', $FW_BOLD) ;~ Local $o_WorkBook = '' ; open an excel instance Local $o_Excel = _Excel_Open(False) If @error Then Return SetError(1, _ MsgBox($MB_SYSTEMMODAL, _ '_Excel_Open', _ 'Error creating the Excel application object' & @CRLF & '@error = ' & @error & ', @extended = ' & @extended), 0) ; set the number of sheets to add when opening a new workbook Local $iSheets = $TABCOUNT If Not $g_iMultipleSheets Then $iSheets = 1 ; open a new excel book Local $o_WorkBook = _Excel_BookNew($o_Excel, $iSheets) ; $TABCOUNT is the number of tabs in your program and so the number of sheets we create for submitting If @error Then Return SetError(2, _ MsgBox($MB_SYSTEMMODAL, _ '_Excel_BookNew', _ 'Error creating new workbook' & @CRLF & '@error = ' & @error & ', @extended = ' & @extended), _Excel_Close($o_Excel)) ;~ ; this will read the control values to an array and write the array to an excel file WriteArrayValuesToSpreadsheet($o_WorkBook) If Not @error Then ; create a file path based on time. If you want to keep overwriting the files the create a definite file name ; and use the commented line Local $s_FilePath = @ScriptDir & '\Report_' & @YEAR & '-' & @MON & '-' & @MDAY & '_' & @HOUR & @MIN & @SEC & '.xlsx' ; ; save the created report and overwrite the previous ;~ _Excel_BookSaveAs($o_WorkBook, $s_FilePath, $xlWorkbookDefault, True) ; save the created report to a new file _Excel_BookSaveAs($o_WorkBook, $s_FilePath, $xlWorkbookDefault) If @error Then MsgBox($MB_SYSTEMMODAL, _ "_Excel_BookSaveAs", _ "Error saving workbook to '" & $s_FilePath & "'." & @CRLF & "@error = " & @error & ", @extended = " & @extended) EndIf _Excel_Close($o_Excel) ; update the splash text ControlSetText("submit", "", "Static1", 'Opening report...') ; open the report, remove if you don't need to ShellExecute($s_FilePath) SplashOff() EndFunc ;==>Report_Submit ; go through the tabs and controls and write the values to a spreadsheet Func WriteArrayValuesToSpreadsheet($o_WorkBook, $i_Layout = Report_GetLayout()) Local _ ; $aa_ControlArrays is an array of arrays. The arrays have the controlIDs for the relevant tab gui controls $aa_ControlArrays[$TABCOUNT + 1] = [$TABCOUNT, $aid_FrontMatterGUI, $aid_BodyMatterGUI, $aid_BackMatterGUI], _ $as_Values = 0, _ ; the array that will hold the values of the gui controls $as_Temp = 0 ;_ a temp array for modding ; set the number of loop to perform when writing. ; If layout 1 is used, there will be a seperate spreadsheet for each tab so 3 loops ; if layout 2 is used all the tabs are written to one spreadsheet so only 1 loop is needed Local _ $i_Total = $aa_ControlArrays[0], _ ;_ set as default layout 1 and loop through the all the arrays $i_Concatenated = 0 ;_ Set the state of the array being processed 0 = multiple 1 = 1 concatenated array ; Change if the layout is 2 and just loop through the concatenated array If $i_Layout > 1 Then $i_Total = 1 ; layout 2 selected #Region #### only needed for cell outside borders if not interested the code can be deleted ### Local _ ; Excel constants not in ExcelConstants.au3 $i_xlAutomatic = -4105, _ $i_xlContinuous = 1, _ $i_xlThin = 2, _ $i_xlEdgeLeft = 7, _ $i_xlEdgeTop = 8, _ $i_xlEdgeBottom = 9, _ $i_xlEdgeRight = 10 #EndRegion #### only needed for cell outside borders if not interested the code can be deleted ### ; loop through the arrays For $i = 1 To $i_Total ; on each loop copy the nested array to a temp one, this will be filled with the values of the controls $as_Values = $aa_ControlArrays[$i] ; set a starting array _ArrayInsert($as_Values, 0, _ArrayToString($g_asTabHeaderText, '|')) ; add the headers to each array #Region #### This determines which array(s) to use for the write #### If $i_Layout = 2 Then _ArrayInsert($as_Values, 0, $g_asTabNames[0]) ; add the first tab name to the array ; loop through the remaining arrays For $j = 2 To $TABCOUNT ; $TABCOUNT = 3 $as_Temp = $aa_ControlArrays[$j] ; copy to a temp array so we can add the tab names and headet text _ArrayInsert($as_Temp, 0, $g_asTabNames[$j - 1]) ; add the next tab name to the array _ArrayInsert($as_Temp, 1, _ArrayToString($g_asTabHeaderText, '|')) ; add the next header text ; joining them $as_Values _ArrayConcatenate($as_Values, $as_Temp) Next EndIf #EndRegion #### This determines which array(s) to use for the write #### ; loop through the temp array For $j = 0 To UBound($as_Values) - 1 ; update the array row with the control values CreateArrayOfControlValues($as_Values, $j) Next ; activate the sheet $o_WorkBook.Sheets($i).Activate ; write the array to an excel spreadsheet _Excel_RangeWrite($o_WorkBook, $i, $as_Values) If @error Then Return SetError(@error, @extended, 'Error Writing ' & $g_asTabNames[$i - 1] & ' to sheet') ; adjust the sheet properties whilst it's active With $o_WorkBook.ActiveSheet If $g_iMultipleSheets Then ; we are writing multiple sheets ; set the sheet name .Name = $g_asTabNames[$i - 1] EndIf ; set the column letters that will auto size to fit the text .Columns(CellRange_CreateFromInteger($ENTRYS_COL + 1, $ARRAYMAX_COLS)).AutoFit ; this is where the cells that have the tab names in get nodified #Region #### Tab Name Cells #### If $g_sTabNameCells Then $g_sTabNameCells = CellRange_CreateFromString($g_sTabNameCells, $ARRAYMAX_COLS) ; set the font weight as bold .Range($g_sTabNameCells).Font.FontStyle = 'Bold' ; set the tab name cells back colour .Range($g_sTabNameCells).Interior.Color = 0xBFBFBF ; merge the cells .Range($g_sTabNameCells).Merge ; centre align the cells .Range($g_sTabNameCells).HorizontalAlignment = $xlCenter EndIf #EndRegion #### Tab Name Cells #### ; this is where the cells that have Entry(s), N/A, No Error etc get modified #Region #### Header Cells #### If $g_sHeaderCells Then $g_sHeaderCells = CellRange_CreateFromString($g_sHeaderCells, $ARRAYMAX_COLS) ; set the font weight as bold .Range($g_sHeaderCells).Font.FontStyle = 'Bold' ; centre align the cells .Range($g_sHeaderCells).HorizontalAlignment = $xlCenter ; set the header cells back colour .Range($g_sHeaderCells).Interior.Color = 0xFFE6CC EndIf #EndRegion #### Header Cells #### ; this is where the cells that have the section text like CATEGORY, HISTORY DATES etc get modified #Region #### Section Cells #### If $g_sSectionCells Then $g_sSectionCells = CellRange_CreateFromString($g_sSectionCells, $ARRAYMAX_COLS) ; set the font weight as bold .Range($g_sSectionCells).Font.FontStyle = 'Bold' ; set the header cells back colour .Range($g_sSectionCells).Interior.Color = 0xDAEFE2 ; add outside borders .Range($g_sSectionCells).Borders($i_xlEdgeTop).LineStyle = $i_xlContinuous .Range($g_sSectionCells).Borders($i_xlEdgeLeft).LineStyle = $i_xlContinuous .Range($g_sSectionCells).Borders($i_xlEdgeRight).LineStyle = $i_xlContinuous .Range($g_sSectionCells).Borders($i_xlEdgeBottom).LineStyle = $i_xlContinuous EndIf #EndRegion #### Section Cells #### EndWith CellRange_ResetGlobalValues() Sleep(20) Next $o_WorkBook.Sheets(1).Activate ; activate the first sheet CellRange_ResetGlobalValues() EndFunc ;==>WriteArrayValuesToSpreadsheet1 point -
Trying to click a link in a web page
MarcoMonte reacted to junkew for a topic
https://www.autoitscript.com/wiki/FAQ 31 and 40 will get you started. Uia automation works fine with edge browser.1 point -
Version 1.3.2.0 of the UDF has been released. Please test before using in production! For download please see my signature.1 point
-
Version 1.3.2.0 of the UDF has been released. Please test before using in production! For download please see my signature.1 point
-
DragonWarrior3_Remake
argumentum reacted to JLogan3o13 for a topic
If you look back through the OP's record of work on this forum you will see a constantly high level of intellect and coding acumen, which led to @TheSaint's comment (which I happen to agree with). Just curious what astounding contributions you could point to, that you feel it is okay to disparage a long time member of this forum?1 point -
As you don't specify the values to be checked here is a random try _Compare("sample1.txt", "sample2.txt", "G_RFTX_F2") Func _Compare($file1, $file2, $test) $txt1 = FileRead($file1) $txt2 = FileRead($file2) $value_1 = StringRegExpReplace($txt1, '(?s).*' & $test & '.*?ValNum="([\d.]+).*', "$1") $value_2 = StringRegExpReplace($txt2, '(?s).*' & $test & '.*?ValNum="([\d.]+).*', "$1") Msgbox(0,"", $test & " values are :" & @crlf & @crlf & _ $value_1 & " in " & $file1 & @crlf & _ $value_2 & " in " & $file2) EndFunc #cs $txt1 = FileRead("sample1.txt") $txt2 = FileRead("sample2.txt") $test = "G_RFTX_F1" $G_RFTX_F1_1 = StringRegExpReplace($txt1, '(?s).*' & $test & '.*?ValNum="([\d.]+).*', "$1") $G_RFTX_F1_2 = StringRegExpReplace($txt2, '(?s).*' & $test & '.*?ValNum="([\d.]+).*', "$1") Msgbox(0,"", $test & " are :" & @crlf & @crlf & _ $G_RFTX_F1_1 & " (sample1)" & @crlf & _ $G_RFTX_F1_2 & " (sample2)") #ce1 point
-
This function is very fast compared to standard _StringRepeat() when number of repeated chars is big. In my tests this version is faster than original for > 50 chars. Time needed for this new StringRepeat() is constant no matter how many chars you repeat (nCount) so for big numbers of repeated characters it's MUCH FASTER (hundred times). StringRepeat Function: Func StringRepeat($sChar, $nCount) $tBuffer = DLLStructCreate("char[" & $nCount & "]") DllCall("msvcrt.dll", "ptr:cdecl", "memset", "ptr", DLLStructGetPtr($tBuffer), "int", Asc($sChar), "int", $nCount) Return DLLStructGetData($tBuffer, 1) EndFunc Testing example for compare speed with standard _StringRepeat (try to change number of chars): #include <String.au3> $start = TimerInit() _StringRepeat('a',1000) ConsoleWrite(TimerDiff($start)& @CRLF) $start = TimerInit() StringRepeat('a',1000) ConsoleWrite(TimerDiff($start)& @CRLF) Func StringRepeat($sChar, $nCount) $tBuffer = DLLStructCreate("char[" & $nCount & "]") DllCall("msvcrt.dll", "ptr:cdecl", "memset", "ptr", DLLStructGetPtr($tBuffer), "int", Asc($sChar), "int", $nCount) Return DLLStructGetData($tBuffer, 1) EndFunc EDIT: There is one difference/limitation from original _StringRepeat(): This new StringRepeat() can repeat only one character, so it's not posiible to do: StringRepeat('abc',3) --> result is 'aaa' Maybe I should change its name from StringRepeat() to CharRepeat() EDIT2: Here is MemSet in form of UDF: Func MemSet($pDest, $nChar, $nCount) DllCall("msvcrt.dll", "ptr:cdecl", "memset", "ptr", $pDest, "int", $nChar, "int", $nCount) If @error Then Return SetError(1,0,False) Return True EndFunc1 point
-
Set default on checkbox as checked?
AnonymousX reacted to wakillon for a topic
have you try guictrlsetstate ( $checkCN, $GUI_CHECKED ) ?1 point