Jump to content

Show my form, only when certain controls are visible.


Recommended Posts

Hello, I'm automating part of the note taking ability of my old bad POS, I managed to do much of the heavy lifting in the past weeks, I can finally do everything i want and more.

Now I have a form with two buttons that expand the form to show a note taking beast that can lets us escape the hell of the one way editing the POS actually support (no cursor just delete. want to change the time on that order better delete everything and start the note from scratch, well not anymore)

Now i'm stuck, my form shows up as two buttons over the POS window, however I need it to go away when I minimized the POS or switch to a different page or application, I was able to do so by doing a while loop, it worked badly as it will repeat the show command infinitely and if i break the loop then there's no way to restart the loop if the user didn't interact with the buttons directly.

I have many ways I could know when controls are visible and it worked, I just don't have a way of constantly checking for this without straining the CPU, I know if I work it somehow I could do a while loop that can work, but it'll be CPU intensive. (Bad POS entails BAD PC)

Should I make another form that does the loop? can I make the loop slower ?

I'm using  VB.net VS 2017 with AutoitX dll.

EDIT: Hello anyone who searched for this, if you're and idiot like me and forgot that Timers exist then this will jog your memory

 

Add a timer to your form, set the timer for 1 sec intervals (dealers choice)

start your timer (within form load or manually)

Timer1.start()

then double click the timer to create a Timer tick (for my case the control visibility test i want to make each second)

it should look something like this :

    Private Sub timer1_Tick(sender As Object, e As EventArgs) Handles timer1.Tick
        dim visibleform = ait.ControlCommand("my app", "", "[NAME:wacontact]", "IsVisible", "")
        If visibleform = 0 Then
            Me.Hide()
    ElseIf visibleform = 1 And Me.Visible = False Then ' to prevent the timer ticks from interupting any sendkeys or something we put two conditions.
            Me.Show()
        End If
    End Sub

remarks: ait. is the call I set for Autoit DLL.
 

 

 

Edited by undcover
Solved it myself. showing how for future searchers.
Link to post
Share on other sites

If i understood correctly, you could check the Z order of the window.

Check the POS window is minimized, if it is, hide the buttons, else, show.

There may be more than 2 ways of doing this.

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to post
Share on other sites
10 minutes ago, careca said:

If i understood correctly, you could check the Z order of the window.

Check the POS window is minimized, if it is, hide the buttons, else, show.

There may be more than 2 ways of doing this. 

I have so many ways to check if the window is minimized or the control hidden, It works fine... my problem is with constantly checking that state and adjusting my form shown, hidden status accordingly. (the app has no windows)

every loop i do ends up crashing.

Link to post
Share on other sites
Public Class Form2
    Dim ait As New AutoItX3
    Public visibleform

    Function firstloop()
        visibleform = ait.ControlCommand("mytest app", "", "[NAME:wacontact]", "IsVisible", "")
        If visibleform = 1 And Form1.Visible = True Then
            Form1.Hide()
        End If
        secondloop()
    End Function
    Function secondloop()
        visibleform = ait.ControlCommand("mytestapp", "", "[NAME:wacontact]", "IsVisible", "")
        If visibleform = 0 And Form1.Visible = False Then
            Form1.Show()
        End If
        firstloop()
    End Function
    Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        firstloop()
    End Sub
End Class

This self made loop didn't work for me either, but should give you an idea of my problem.

Link to post
Share on other sites

Only now i noticed this is autoitX.

I was thinking about the "regular" autoit.

Sry cant help with this.

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to post
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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By WhaleJesus
      #include <FileConstants.au3> #include <MsgBoxConstants.au3> #include <file.au3> ; Create Data Folder if it doesn't exist yet If FileExists(@ScriptDir & "\Data") Then Else ShellExecute(@ScriptDir) DirCreate(@ScriptDir & "\Data") EndIf ; Playlist Name & location input Global $playlistnameinput = InputBox("Playlist", "Enter The playlist name", _ "Name") Global $playlistlocationinput = InputBox("Location", "Specify where you would like the playlist folder to be stored", @ScriptDir & "\Playlists\" & $playlistnameinput) ; Create file in Data folder and other vars Global $sDataFile = @ScriptDir & "\Data\Data.txt" Global $DataHandle = FileOpen($sDataFile, 1) Global $DataFileLine = FileReadLine($sDataFile, 1) FileClose($DataFileLine) MsgBox(0, "", $DataFileLine, 10) ; Prove it exists If FileExists($sDataFile) Then _FileWriteToLine($DataHandle, $DataFileLine, $playlistnameinput, True, True) $DataFileLine += 1 _FileWriteToLine($DataHandle, 1, $DataFileLine, True) Else MsgBox($MB_SYSTEMMODAL, "Error", "File " & $sDataFile & "Does not exist") EndIf Global $sPDataFile = @ScriptDir & "\Data\" & $playlistnameinput & "_Data.txt" Global $PDataHandle = FileOpen($sPDataFile, 1) If FileExists($sPDataFile) Then _FileWriteToLine($PDataHandle, 1, $playlistnameinput, True, True) _FileWriteToLine($PDataHandle, 2, $playlistlocationinput, True, True) Else MsgBox($MB_SYSTEMMODAL, "Error", "File " & $sPDataFile & "Does not exist") EndIf _FileWriteToLine stopped working and i don't know what it is in my code that's causing this, please help
    • By DannyJ
      $sCommands1 = 'powershell.exe Get-ChildItem' $iPid = run($sCommands1   , @WorkingDir , @SW_SHOW , 0x2) $sOutput = ""  While 1     $sOutput &= StdoutRead($iPID)         If @error Then             ExitLoop         EndIf  WEnd ;~ msgbox(0, '' , $sOutput) ConsoleWrite("$sOutput") ConsoleWrite($sOutput) ConsoleWrite(@CRLF) $aOutput = stringsplit($sOutput ,@LF , 2) For $i=0 To  UBound($aOutput) - 1 Step 1     ConsoleWrite($aOutput[$i]) Next The script above reads the whole directory into a one dimensional array, but I need to work with the array, so I need to split the array into multiple dimensions.
      I have already read some forum answers here, and I have already tried these commands:
       
      Are there any way to use the $aOutput variable like in PowerShell:
      PowerShell:
      $a = Get-ChildItem $a.Mode I imagine this in AutoIt  $aOutput
      ConsoleWrite($aOutput[i].Mode) Or if I split this command into 2 dimension like:
      For $i To UBound($aOutput)-1 Step 1 ConsoleWrite($aOutput[$i][1]) ConsoleWrite($aOutput[$i][2]) Next  
    • By DannyJ
      If I run this code, it works perfectly
      $CmdPid = Run("C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noexit " & 'Get-ChildItem',@DesktopDir, @SW_SHOW) But this code
      $CmdPid = Run("C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noexit " & 'Get-RDUserSession',@DesktopDir, @SW_SHOW) I get this error:
      Get-RDUserSession : The term 'Get-RDUserSession' is not recognized as the name of a cmdlet, function, script file, or o perable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try aga in. If I try run the command Get-RDUserSession  in normal PowerShell (started from windows start menu) the command works perfectly.
      But If I run with AutoIt I get the above mentioned error .
      Any ideas?
    • By Automania
      Hi all,
      I haven't used AutoIt in more than 10 years and I am sure a lot has improved since that long time. I hope you can give me some suggestions on my approach.
      Task: I need to extract user data (for around 1700 users) from a website tool. That tool shows an output in a table on the website. However, no export feature is available and I need the data in an Excel file, such as:
      username, serial number (of a laptop), ID number (of laptop) and some more
       
      With my knowledge from 2009 I would do this:
      1) use _IEextract with each username in the url to get the whole source code of the website with the user's data summary
      2) Work with lots of regexpressions to extract each data piece, save them into variables/array
      3) Write variable values into an Excel file
      4) rinse repeat 1700 times
       
      The relevant line for step 3 looks like this:
      <td class="resultcell"><span class="new">2021-03-23 11:05:00</span></td><td class="resultcell">Hostname-1234</td><td class="resultcell"><a href="?&Search=Search&result=summarized%20history&field=serial%20numbers&criteria=123456">123456</a></td><td class="resultcell">0987654/td><td class="resultcell"><a href="?&Search=Search&result=summarized%20history&field=usernames&criteria=myusername">myusername</a> and so on.. so here it would be Hostname-1234, 0987654 and myusername that I would need to extract.

      Although this may work it does not appear very efficient and would take a while. So I am happy for an alternate approach. Preferably, without using additional exe binary files due to company policies besides AutoIt itself.
    • By SEuBo
      Hi!
      I am just getting started with C and C++. I have created a pretty simple C code which is calling a dll function.
      When I compile and run, I get the appropriate Output. So it works fine.

       
      Now I would want to transform that to AutoIt. -> I would like to call the "RfcOpenConnection" function from AutoIt - but whatever I try with DLLCall, I can not get it to work. 
      Can someone point me in the right direction? DLL, C Sourcecode and compiled exe are attached too large to be attached, so they're uploaded here: 
      https://drive.google.com/file/d/12CUSsISl0mojiMCNxKjps1Sdoox3JlCX/view?usp=sharing
       
      Thanks a bunch!
×
×
  • Create New...