Jump to content

reload the same script


Recommended Posts

The original idea was to criticize the button and the script disappears for a few seconds at least 5 seconds ... and what they tell me.

Ai galera, I am the newest user to register in the forum and I need a little help in this script

 

#include <misc.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>


Opt("GUIOnEventMode", 1)

$gui = GUICreate("  ·.·.·", 100, 100, @DesktopWidth - (700 + 100), @DesktopHeight - (700 + 100), $WS_POPUP, $WS_EX_TOOLWINDOW)

$button1 = GUICtrlCreateButton("Button1", 5, 65, 40, 20)
GUICtrlSetOnEvent(-1, "Button1")
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1, 0xff0000); Red

DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $gui, "int", 200, "long", 0x00040008); slide-in
GUISetState()

While 1
   Sleep(50)
WEnd



Func button1()
   ShellExecute("AutoIt3.exe", "/autoit1.au3", @ScriptDir)
EndFunc

 

Edited by JLogan3o13
Added Code Formatting
Link to comment
Share on other sites

Try this one:

Func button1()
    If @Compiled Then
        ShellExecute(@ScriptFullPath)
    Else
        ShellExecute(@AutoItExe, @ScriptFullPath)
    EndIf
    Exit
EndFunc
Quote

Ai galera

BR? :sweating:

Edited by Jefrey

My stuff

Spoiler

My UDFs  _AuThread multithreading emulation for AutoIt · _ExtInputBox an inputbox with multiple inputs and more features · forceUTF8 fix strings encoding without knowing its original charset · JSONgen JSON generator · _TCPServer UDF multi-client and multi-task (run on background) event-based TCP server easy to do · _TCPClient_UDF multi-server and multi-task (runs on background) event-based TCP client easy to do · ParseURL and ParseStr functions ported from PHP · _CmdLine UDF easily parse command line parameters, keys or flags · AutoPHP Create documents (bills, incomes) from HTML by sending variables/arrays from AutoIt to PHP · (Un)Serialize Convert arrays and data into a storable string (PHP compatible) · RTTL Plays and exports to MP3 Nokia-format monophonic ringtones (for very old cellphones) · I18n library Simple and easy to use localization library · Scripting.Dictionary OOP and OOP-like approach · Buffer/stack limit arrays to N items by removing the last one once the limit is reached · NGBioAPI UDF to work with Nitgen fingerprint readers · Serial/Licensing system require license key based on unique machine ID from your users · HTTP a simple WinHTTP library that allows GET, POST and file uploads · Thread true AutoIt threads (under-dev) · RC4 RC4 encryption compatible with PHP and JS ·  storage.au3 localStorage and sessionStorage for AutoIt Classes _WKHtmlToX uses wkhtmlto* to convert HTML files and webpages into PDF or images (jpg, bmp, gif, png...) Snippets _Word_DocFindReplaceByLongText replace strings using Word UDF with strings longer than 255 characters (MSWord limit) rangeparser parser for printing-like pages interval (e.g.: "1,2,3-5") EnvParser parse strings/paths with environment variables and get full path GUICtrlStaticMarquee static text scrolling Random stuff Super Mario beep sound your ears will hurt

 

Link to comment
Share on other sites

Now how do I make it faster and drag free on the screen

 

#include <misc.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>

Opt("GUIOnEventMode", 1)

$gui = GUICreate("  ·.·.·", 100, 100, @DesktopWidth - (700 + 100), @DesktopHeight - (700 + 100), $WS_POPUP, $WS_EX_TOOLWINDOW)

$button1 = GUICtrlCreateButton("fresh", 5, 65, 40, 20)
GUICtrlSetOnEvent(-1, "Button1")

$button2 = GUICtrlCreateButton("Off", 50, 65, 40, 20)
GUICtrlSetOnEvent(-1, "Button2")


DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $gui, "int", 200, "long", 0x00040008); slide-in
WinSetOnTop("  ·.·.·", "", 1)
TraySetState()
GUISetState()

Func button2()
       Exit
EndFunc

Func button1()
    If @Compiled Then
        ShellExecute(@ScriptFullPath)
    Else
        ShellExecute(@AutoItExe, @ScriptFullPath)
    EndIf
    Exit
EndFunc


While 1
    Sleep(10)
WEnd

Edited by PeterOctavio
Link to comment
Share on other sites

Quote

vlw

Yes, you are BR :P

Quote

drag free on the screen

Do the following patches:

$gui = GUICreate("  ·.·.·", 100, 100, @DesktopWidth - (700 + 100), @DesktopHeight - (700 + 100), -1, $WS_EX_TOOLWINDOW)

$button1 = GUICtrlCreateButton("fresh", 5, 65, 40, 20)
GUICtrlSetOnEvent(-1, "Button1")

$button2 = GUICtrlCreateButton("Off", 50, 65, 40, 20)
GUICtrlSetOnEvent(-1, "Button2")

; disable close button
$hMenu = _GUICtrlMenu_GetSystemMenu($gui)
_GUICtrlMenu_EnableMenuItem($hMenu, $SC_CLOSE, $MF_GRAYED, False)


DllCall ...
Quote

make it faster

You mean, having the "fresh" button to reload the script faster? You can't...

It's not possible to control how fast a file will open, as it depends on Windows, and not on AutoIt. However you could create a function that reloads your script, resets variables to their default values and windows to the standard position. You said you want the script (I assume GUI) to disappear for 5 secs, so here's how:

#include <misc.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <GUIMenu.au3>

Opt("GUIOnEventMode", 1)

Global $gui

Func _Main()
    $gui = GUICreate("  ·.·.·", 100, 100, @DesktopWidth - (700 + 100), @DesktopHeight - (700 + 100), -1, $WS_EX_TOOLWINDOW)

    $button1 = GUICtrlCreateButton("fresh", 5, 65, 40, 20)
    GUICtrlSetOnEvent(-1, "Button1")

    $button2 = GUICtrlCreateButton("Off", 50, 65, 40, 20)
    GUICtrlSetOnEvent(-1, "Button2")

    ; disable close button
    $hMenu = _GUICtrlMenu_GetSystemMenu($gui)
    _GUICtrlMenu_EnableMenuItem($hMenu, $SC_CLOSE, $MF_GRAYED, False)


    DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $gui, "int", 200, "long", 0x00040008); slide-in
    WinSetOnTop($gui, "", 1) ; it's better to use the window hwnd, it's safer and faster than using the window title
    TraySetState()
    GUISetState()
EndFunc

_Main()

Func button2()
       Exit
EndFunc

Func button1()
    GUIDelete($gui)
    Sleep(5000) ; 5000 miliseconds = 5 secs
    _Main()
EndFunc


While 1
    Sleep(10)
WEnd

In this case, you can set the amount of seconds that your script will disappear on the Sleep() inside the button1() function.

My stuff

Spoiler

My UDFs  _AuThread multithreading emulation for AutoIt · _ExtInputBox an inputbox with multiple inputs and more features · forceUTF8 fix strings encoding without knowing its original charset · JSONgen JSON generator · _TCPServer UDF multi-client and multi-task (run on background) event-based TCP server easy to do · _TCPClient_UDF multi-server and multi-task (runs on background) event-based TCP client easy to do · ParseURL and ParseStr functions ported from PHP · _CmdLine UDF easily parse command line parameters, keys or flags · AutoPHP Create documents (bills, incomes) from HTML by sending variables/arrays from AutoIt to PHP · (Un)Serialize Convert arrays and data into a storable string (PHP compatible) · RTTL Plays and exports to MP3 Nokia-format monophonic ringtones (for very old cellphones) · I18n library Simple and easy to use localization library · Scripting.Dictionary OOP and OOP-like approach · Buffer/stack limit arrays to N items by removing the last one once the limit is reached · NGBioAPI UDF to work with Nitgen fingerprint readers · Serial/Licensing system require license key based on unique machine ID from your users · HTTP a simple WinHTTP library that allows GET, POST and file uploads · Thread true AutoIt threads (under-dev) · RC4 RC4 encryption compatible with PHP and JS ·  storage.au3 localStorage and sessionStorage for AutoIt Classes _WKHtmlToX uses wkhtmlto* to convert HTML files and webpages into PDF or images (jpg, bmp, gif, png...) Snippets _Word_DocFindReplaceByLongText replace strings using Word UDF with strings longer than 255 characters (MSWord limit) rangeparser parser for printing-like pages interval (e.g.: "1,2,3-5") EnvParser parse strings/paths with environment variables and get full path GUICtrlStaticMarquee static text scrolling Random stuff Super Mario beep sound your ears will hurt

 

Link to comment
Share on other sites

So dude, thanks for that code. It was cool, excerpt that when I click fresh, it disappears but does not reappear in the place where I left it on the screen, it always returns to the place fixed in the script settings. How much it makes it faster, in case it was enough the background of the window to be transparent

 

#include <misc.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>

Opt("GUIOnEventMode", 1)

$gui = GUICreate("  ·.·.·", 100, 100, @DesktopWidth - (700 + 100), @DesktopHeight - (700 + 100), $WS_POPUP, $WS_EX_TOOLWINDOW)

$button1 = GUICtrlCreateButton("fresh", 5, 65, 40, 20)
GUICtrlSetOnEvent(-1, "Button1")

$button2 = GUICtrlCreateButton("Off", 50, 65, 40, 20)
GUICtrlSetOnEvent(-1, "Button2")


DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $gui, "int", 200, "long", 0x00040008); slide-in
WinSetOnTop("  ·.·.·", "", 1)
TraySetState()
GUISetState()

Func button2()
       Exit
EndFunc

Func button1()
    If @Compiled Then
        ShellExecute(@ScriptFullPath)
    Else
        ShellExecute(@AutoItExe, @ScriptFullPath)
    EndIf
    Exit
EndFunc


While 1
    Sleep(10)
WEnd

Link to comment
Share on other sites

Quote

So dude, thanks for that code. It was cool, excerpt that when I click fresh, it disappears but does not reappear in the place where I left it on the screen, it always returns to the place fixed in the script settings. How much it makes it faster, in case it was enough the background of the window to be transparent

Try this. Here we just hide the window rather than deleting/recreating it.

#include <misc.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <GUIMenu.au3>

Opt("GUIOnEventMode", 1)

Global $gui

Func _Main()
    $gui = GUICreate("  ·.·.·", 100, 100, @DesktopWidth - (700 + 100), @DesktopHeight - (700 + 100), -1, $WS_EX_TOOLWINDOW)

    $button1 = GUICtrlCreateButton("fresh", 5, 65, 40, 20)
    GUICtrlSetOnEvent(-1, "Button1")

    $button2 = GUICtrlCreateButton("Off", 50, 65, 40, 20)
    GUICtrlSetOnEvent(-1, "Button2")

    ; disable close button
    $hMenu = _GUICtrlMenu_GetSystemMenu($gui)
    _GUICtrlMenu_EnableMenuItem($hMenu, $SC_CLOSE, $MF_GRAYED, False)


    DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $gui, "int", 200, "long", 0x00040008); slide-in
    WinSetOnTop($gui, "", 1) ; it's better to use the window hwnd, it's safer and faster than using the window title
    TraySetState()
    GUISetState()
EndFunc

_Main()

Func button2()
       Exit
EndFunc

Func button1()
    GUISetState(@SW_HIDE, $gui)
    Sleep(5000) ; 5000 miliseconds = 5 secs
    GUISetState(@SW_SHOW, $gui)
EndFunc


While 1
    Sleep(10)
WEnd
Quote

Look, I had a better idea, like I do in this last script I posted, so when I click on another windows window, make the script move forward, as yours would push alt + tab???

Hm I couldn't get what you mean... do you mean setting other windows on top when you click them?

My stuff

Spoiler

My UDFs  _AuThread multithreading emulation for AutoIt · _ExtInputBox an inputbox with multiple inputs and more features · forceUTF8 fix strings encoding without knowing its original charset · JSONgen JSON generator · _TCPServer UDF multi-client and multi-task (run on background) event-based TCP server easy to do · _TCPClient_UDF multi-server and multi-task (runs on background) event-based TCP client easy to do · ParseURL and ParseStr functions ported from PHP · _CmdLine UDF easily parse command line parameters, keys or flags · AutoPHP Create documents (bills, incomes) from HTML by sending variables/arrays from AutoIt to PHP · (Un)Serialize Convert arrays and data into a storable string (PHP compatible) · RTTL Plays and exports to MP3 Nokia-format monophonic ringtones (for very old cellphones) · I18n library Simple and easy to use localization library · Scripting.Dictionary OOP and OOP-like approach · Buffer/stack limit arrays to N items by removing the last one once the limit is reached · NGBioAPI UDF to work with Nitgen fingerprint readers · Serial/Licensing system require license key based on unique machine ID from your users · HTTP a simple WinHTTP library that allows GET, POST and file uploads · Thread true AutoIt threads (under-dev) · RC4 RC4 encryption compatible with PHP and JS ·  storage.au3 localStorage and sessionStorage for AutoIt Classes _WKHtmlToX uses wkhtmlto* to convert HTML files and webpages into PDF or images (jpg, bmp, gif, png...) Snippets _Word_DocFindReplaceByLongText replace strings using Word UDF with strings longer than 255 characters (MSWord limit) rangeparser parser for printing-like pages interval (e.g.: "1,2,3-5") EnvParser parse strings/paths with environment variables and get full path GUICtrlStaticMarquee static text scrolling Random stuff Super Mario beep sound your ears will hurt

 

Link to comment
Share on other sites

First scrip (file 1)

#include <misc.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>


Opt("GUIOnEventMode", 1)

$gui = GUICreate("hidecard", 100, 100, @DesktopWidth - (700 + 100), @DesktopHeight - (700 + 100), $WS_POPUP, $WS_EX_TOOLWINDOW)


DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $gui, "int", 200, "long", 0x00040008); slide-in
WinSetOnTop("hidecard", "", 0)
GUISetState()

HotKeySet("{ESC}","Quit") ;Press ESC key to quit

While True      ;Here start main loop
    Sleep(20)
WEnd

Func Quit()
    Exit
EndFunc

Second script (file)

#include <AutoItConstants.au3>

Example()

Func Example()
    ; Retrieve the handle of the active window.
    Local $hWnd = WinGetHandle("hidecard")

    ; Set the active window as being ontop using the handle returned by WinGetHandle.
    WinSetOnTop($hWnd, "", $WINDOWS_ONTOP)

    ; Remove the "topmost" state from the active window.
    WinSetOnTop($hWnd, "", $WINDOWS_NOONTOP)

EndFunc   ;==>Example


HotKeySet("{ESC}","Quit") ;Press ESC key to quit

While True      ;Here start main loop
    Sleep(2000)
WEnd

Func Quit()
    Exit
EndFunc

You're seeing these two files there, so why am I not making them work? You have to stay both open, one makes the other go to the front of the screen in 5 seconds, see if I'm right, that's all I want ... or the other part you did to turn into a window!

Link to comment
Share on other sites

hahahaha Almost there, I confused myself with the script, instead of Winsetontop is actually WinActive ...

 

#include <misc.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>

Opt("GUIOnEventMode", 1)

$gui = GUICreate("hidecard", 100, 100, @DesktopWidth - (700 + 100), @DesktopHeight - (700 + 100), $WS_POPUP, $WS_EX_TOOLWINDOW)

DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $gui, "int", 200, "long", 0x00040008); slide-in
WinSetOnTop($gui, "", 0)
GUISetState()

;RUM IF NOTEPAD (JUST AN EXAMPLE) IS OPEN

;BUTTON PAUSE WINACTIVATE

;BUTTON EXIT

;HAVE THE FUNCTION OF DRAGING TO ANOTHER SCREEN

OR

;BEFORE DRAWING ANYWHERE OF THE SCREEN WITH ANY SIZE

While True     
    Sleep(1000) ;1 SECOND FOR CHECK
    WinActivate ("hidecard")
WEnd

 

 

Now I have to put it to work in a specific softwre, to hide details of the screen ... my problem is that with winactive the script goes ahead preventing me from typing, so I have to pause, the window has to go to Front but do not interrupt what I was using.

Edited by PeterOctavio
Link to comment
Share on other sites

You put that at the top of your script (where the other includes are at) , check out #include in the help file 

#include <WindowsConstants.au3>
#include <WinAPI.au3>

Opt("GUIOnEventMode", 1)

$gui = GUICreate("hidecard", 100, 100, @DesktopWidth - (700 + 100), @DesktopHeight - (700 + 100), $WS_POPUP, $WS_EX_TOOLWINDOW)
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $gui, "int", 200, "long", 0x00040008) ; slide-in
GUISetState()

While 1
    Sleep(3000)
    _WinAPI_SetWindowPos($gui, $HWND_TOPMOST, 0, 0, 0, 0, BitOR($SWP_FRAMECHANGED, $SWP_NOMOVE, $SWP_NOSIZE, $SWP_NOACTIVATE))
    _WinAPI_SetWindowPos($gui, $HWND_NOTOPMOST, 0, 0, 0, 0, BitOR($SWP_FRAMECHANGED, $SWP_NOMOVE, $SWP_NOSIZE, $SWP_NOACTIVATE))
WEnd

 

Edited by Deye
Link to comment
Share on other sites

This example is legal, but using the notepad, clicking on the title bar (of the notepad) works perfectly, but clicking on the text area is not working

 

#include <WindowsConstants.au3>
#include <WinAPI.au3>

Opt("GUIOnEventMode", 1)

$gui = GUICreate("hidecard", 100, 100, @DesktopWidth - (700 + 100), @DesktopHeight - (700 + 100), $WS_POPUP, $WS_EX_TOOLWINDOW)
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $gui, "int", 200, "long", 0x00040008) ; slide-in
GUISetState()

While 1
    Sleep(3000)
    _WinAPI_SetWindowPos($gui, $HWND_TOPMOST, 0, 0, 0, 0, BitOR($SWP_FRAMECHANGED, $SWP_NOMOVE, $SWP_NOSIZE, $SWP_NOACTIVATE))
    _WinAPI_SetWindowPos($gui, $HWND_NOTOPMOST, 0, 0, 0, 0, BitOR($SWP_FRAMECHANGED, $SWP_NOMOVE, $SWP_NOSIZE, $SWP_NOACTIVATE))
WEnd
Edited by PeterOctavio
Link to comment
Share on other sites

Well if this got you closer to what you wanted then there you have it
You can use the various functions available to tailor the outcome to your needs within the limits, I guess ..

#include <misc.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>

Local $hDLL = DllOpen("user32.dll")
Local $gui = GUICreate("hidecard", 100, 100, @DesktopWidth - (700 + 100), @DesktopHeight - (700 + 100), $WS_POPUP, $WS_EX_TOOLWINDOW)
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $gui, "int", 200, "long", 0x00040008) ; slide-in
GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
    If _IsPressed("01", $hDLL) Then ;Left mouse click
        _WinAPI_SetWindowPos($gui, $HWND_TOPMOST, 0, 0, 0, 0, BitOR($SWP_FRAMECHANGED, $SWP_NOMOVE, $SWP_NOSIZE, $SWP_NOACTIVATE, $SWP_HIDEWINDOW))
        While _IsPressed("01", $hDLL)
            Sleep(3000)
        WEnd
        DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $gui, "int", 200, "long", 0x00040008) ; slide-in
        _WinAPI_SetWindowPos($gui, $HWND_NOTOPMOST, 0, 0, 0, 0, BitOR($SWP_FRAMECHANGED, $SWP_NOMOVE, $SWP_NOSIZE, $SWP_NOACTIVATE, $SWP_SHOWWINDOW))
    EndIf
    Sleep(10)
WEnd

 

Edited by Deye
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...