Sign in to follow this  
Followers 0
Iznogoud

Create a button wich is always on top to execute an onscreen keyboard

26 posts in this topic

I want to create a button wich i can place in the bottom right corner of the screen wich is always ontop and when pressed it executes an executable.

#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiEdit.au3>
#include <ButtonConstants.au3>


    $MainWindow = GUICreate ("Example", 40, 40, "-1", "-1", 0x80880008)
    
    GUICtrlCreateButton("Button", 0, 0, 40, 40, $BS_ICON)
    GUICtrlSetImage(-1, "C:\Keyboard.ico", 22)
    GUICtrlSetState(-1, $GUI_ONTOP) 
    

    GuiSetState()

    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
    

                EndSelect
            Wend

This looks strange because the button is inside the GUI and you always see the border. I would prefer to have an image wich i can click and execute the program, but i don't know how.

In my code above you see the $GUI_ONTOP, but this doesn't work, even if i comment out the GUICtrlSetImage code it doesn't work.

In simple words i am looking for an image wich is always ontop in the bottom right corner wich i could click the show the onscreen keyboard wich is already available in windows 7.

Could someone help me with this. I am stuck at the moment.

Share this post


Link to post
Share on other sites



WinSetOnTop :)

Share this post


Link to post
Share on other sites

For some reason that const is not getting found for me.

;#include <Constants.au3>
#include <GUIConstantsEx.au3>
;#include <GuiEdit.au3>
#include <ButtonConstants.au3>


$MainWindow = GUICreate("Example", 40, 40, -1, -1, 0x80880008, 0x00000008) ;0x00000008 = WS_EX_TOPMOST

$button = GUICtrlCreateButton("Button", 0, 0, 40, 40, $BS_ICON)
GUICtrlSetImage(-1, "C:\Keyboard.ico", 22)
GUICtrlSetState(-1, $GUI_ONTOP)


GUISetState()

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $button
            Exit


    EndSwitch
WEnd

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

JohnOne,

As its WS prefix indicates, it is in WindowsConstants.au3. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

JohnOne,

Could happen to anyone..... :whistle:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

 

For some reason that const is not getting found for me.

;#include <Constants.au3>
#include <GUIConstantsEx.au3>
;#include <GuiEdit.au3>
#include <ButtonConstants.au3>


$MainWindow = GUICreate("Example", 40, 40, -1, -1, 0x80880008, 0x00000008) ;0x00000008 = WS_EX_TOPMOST

$button = GUICtrlCreateButton("Button", 0, 0, 40, 40, $BS_ICON)
GUICtrlSetImage(-1, "C:\Keyboard.ico", 22)
GUICtrlSetState(-1, $GUI_ONTOP)


GUISetState()

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $button
            Exit


    EndSwitch
WEnd

 

Thanks, that is looking alot better. Anyone an idea how to show it like an image instead of a button inside a GUI? So i don't get that ugly design?

Share this post


Link to post
Share on other sites

Or maybe a pic control.

#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
;#include <GuiEdit.au3>
#include <ButtonConstants.au3>


$MainWindow = GUICreate("Example", 40, 40, -1, -1, 0x80880008, $WS_EX_TOPMOST) ;0x00000008 =

$button = GUICtrlCreatePic("temp01.bmp", 0, 0, 40, 40)
;GUICtrlSetImage(-1, "temp01.bmp", 22)
;GUICtrlSetState(-1, $GUI_ONTOP)


GUISetState()

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $button
            Exit


    EndSwitch
WEnd

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

Weird......

How hard can it be to get this done :

#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
;#include <GuiEdit.au3>
#include <ButtonConstants.au3>


$MainWindow = GUICreate("Example", 40, 40, -1, -1, 0x80880008, $WS_EX_TOPMOST) ;0x00000008 =

$button = GUICtrlCreatePic("C:\Keyboard.jpg", 0, 0, 40, 40)
;GUICtrlSetImage(-1, "temp01.bmp", 22)
;GUICtrlSetState(-1, $GUI_ONTOP)


GUISetState()

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $button
            Run("C:\Windows\System32\osk.exe", "C:\Windows\system32\", @SW_MAXIMIZE)
    EndSwitch
WEnd

The Run command is easy and simple but it doesn't work in this script. In my other script it does, can someone help me why it doesn't work now?

Share this post


Link to post
Share on other sites

#16 ·  Posted (edited)

ShellExecute is not working either.

When i put a MsgBox in front of it, it shows the Box first.

When i change the executable to Notepad.exe it is working. Weird.........

;#include <Constants.au3>
#include <GUIConstantsEx.au3>
;#include <GuiEdit.au3>
#include <ButtonConstants.au3>


$MainWindow = GUICreate("Example", 40, 40, -1, -1, 0x80880008, 0x00000008) ;0x00000008 = WS_EX_TOPMOST

$button = GUICtrlCreateButton("Button", 0, 0, 40, 40, $BS_ICON)
GUICtrlSetImage(-1, "C:\Keyboard.ico", 22)
GUICtrlSetState(-1, $GUI_ONTOP)


GUISetState()

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $button
                         MsgBox(0, "Error", "Error")
            ShellExecute("C:\Windows\System32\osk.exe")


    EndSwitch
WEnd
Edited by Iznogoud

Share this post


Link to post
Share on other sites

Try using @SystemDir & "osk.exe" instead of C:WindowsSystem32osk.exe  and see if that makes a difference.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

#20 ·  Posted (edited)

Try using @SystemDir & "osk.exe" instead of C:WindowsSystem32osk.exe  and see if that makes a difference.

 

this also do not works on win7 x64

this other works instead:

#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>

$MainWindow = GUICreate("Example", 40, 40, -1, -1, 0x80880008, 0x00000008) ;0x00000008 = WS_EX_TOPMOST

$button = GUICtrlCreateButton("Button", 0, 0, 40, 40, $BS_ICON)
GUICtrlSetImage(-1, "C:\Keyboard.ico", 22)
GUICtrlSetState(-1, $GUI_ONTOP)

GUISetState()

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $button
            _Wow64FsRedirection(False)
            Run("osk")
            _Wow64FsRedirection(True)
    EndSwitch
WEnd
Func _Wow64FsRedirection($state)
    ; Disables or reverts the filesystem redirector for a 32 bit process running on 64bit OS
    If Not @AutoItX64 And @OSArch = 'X64' Then
        If $state Then
            DllCall("kernel32.dll", "int", "Wow64RevertWow64FsRedirection", "int", 0)
        Else
            DllCall("kernel32.dll", "int", "Wow64DisableWow64FsRedirection", "int", 0)
        EndIf
    EndIf
EndFunc

(edit: submitted complete listing instead of only a portion)

I'm all for learning to code and building and stuff but...

you could put a shortcut on your desktop and give it it's own keyboard shortcut...

just sayin'   :ermm:  ^_^

 

... how do you set a shortcut always on top?

Edited by PincoPanco

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Share this post


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
Sign in to follow this  
Followers 0